【已解决】[简单]poi word 2007中的单位转换
- 工作小总结
- 时间:2023-10-04 11:28
- 1794人已阅读
简介
以前使用poi操作word2007时候会遇到设置页面大小等问题,当时发现1cm≈567,为什么要这样一直不清楚,今天发现一篇关于这方面的文章。 文章链接:http://startbigthinksmall.wordpress.com/2010/01/04/points-inches
🔔🔔🔔好消息!好消息!🔔🔔🔔
有需要的朋友👉:联系凯哥
1cm≈567 (567=1*20*72/2.54) 。
文章作者提供了换算的工具,链接:http://lcorneliussen.de/raw/dashboards/ooxml/ ,如下:
public class POI_单位转换_S3_Test { public static void main(String[] args) { double cm = mm2Cm(25.4); System.out.println(String.format("%s-->%s=%s", "mm", "cm", cm)); double inch = cm2Inch(cm); System.out.println(String.format("%s-->%s=%s", "cm", "inch", inch)); double pt = inch2Pt(inch); System.out.println(String.format("%s-->%s=%s", "inch", "pt", pt)); double dxa = pt2Dxa(pt); System.out.println(String.format("%s-->%s=%s", "pt", "dxa", dxa)); double emu = dxa2Emu(dxa); System.out.println(String.format("%s-->%s=%s", "dxa", "emu", emu)); double dxa2 = emu2dxa(emu); System.out.println(String.format("%s-->%s=%s", "emu", "dxa", dxa2)); System.out.println(String.format("%s-->%s=%s", "dxa", "pt", dxa2points(1440.0))); System.out.println(String.format("%s-->%s=%s", "dxa", "inch", dxa2inch(1440.0))); } public static double mm2Cm(double mm) { return mm / 10; } public static double cm2Inch(double cm) { return cm / 2.54; } public static double inch2Pt(double inch) { return inch * 72; } public static double pt2Dxa(double pt) { return pt * 20; } public static double dxa2inch(double dxa) { return dxa2points(dxa) / 72; } public static double dxa2points(double dxa) { return dxa / 20; } public static double dxa2Emu(double dxa) { return 914400 * dxa2inch(dxa); } public static double emu2dxa(double emu) { return pt2Dxa(inch2Pt(emu)) / 914400; } }
输出的结果为:
mm-->cm=2.54 cm-->inch=1.0 inch-->pt=72.0 pt-->dxa=1440.0 dxa-->emu=914400.0 emu-->dxa=1440.0 dxa-->pt=72.0 dxa-->inch=1.0