Java POI 的 setColumnWidth -- 字符宽度?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24313907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
POI's setColumnWidth -- character width?
提问by user3757690
public void setColumnWidth(int columnIndex, int width)
Set the width (in units of 1/256th of a character width)
public void setColumnWidth(int columnIndex, int width)
设置宽度(以字符宽度的 1/256 为单位)
1/256th the width of WHICH CHARACTER? Different characters have different widths. What am I missing here?
1/256th哪个字符的宽度?不同的字符有不同的宽度。我在这里缺少什么?
采纳答案by ndnookala
If you see the Javadoc of HSSFSheet.setColumnWidth() method, it has the explanation of the Character width. Pasting the excerpt below:
如果你看到 HSSFSheet.setColumnWidth() 方法的 Javadoc,它有对字符宽度的解释。粘贴摘录如下:
Character width is defined as the maximum digit width of the numbers 0, 1, 2, ... 9 as rendered using the default font (first font in the workbook). Unless you are using a very special font, the default character is '0' (zero), this is true for Arial (default font font in HSSF) and Calibri (default font in XSSF)
字符宽度定义为使用默认字体(工作簿中的第一种字体)呈现的数字 0、1、2、... 9 的最大数字宽度。除非您使用非常特殊的字体,否则默认字符为“0”(零),这适用于 Arial(HSSF 中的默认字体)和 Calibri(XSSF 中的默认字体)
Refer link: http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFSheet.html#setColumnWidth(int, int)
参考链接:http: //poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFSheet.html#setColumnWidth(int, int)