Apache的POI自动调整大小时并不十分给足够的空间 [英] Apache POI doesn't quite give enough space when autosizing
问题描述
我建立与Apache POI的Excel文件。我想补充的内容毕竟我使用AUTOSIZE列 sheet.autoSizeColumn(我)
。
I am building an Excel file with Apache POI. After I add all of the content I autosize the columns using sheet.autoSizeColumn(i)
.
有时并不完全给予足够的空间。我曾尝试宋体
和宋体正规
(曾因为自动调整打算彻底从宋体改用宋体正规疯狂突然对我们的Windows 7盒,但是,我们的Linux机器,这是一个谜给我)的罚款。有什么我能做的解决这一问题?或者是有没有办法自动调整大小后,加少许填充?
Sometimes it doesn't quite give enough space. I have tried Verdana
and Calibri-Regular
(had to switch to Calibri-Regular from Calibri because the autosize was going completely crazy all of a sudden on our Windows 7 boxes but worked fine on our Linux boxes, which is a mystery to me). Is there something I can do to fix this? Or is there a way to add a little padding after autosizing?
修改
在我的Windows开发框我试图设置字体为宋体与 font.setFontName(宋体)
。所有的内容肯定变为宋体和列的大小是完美的。在Linux生产彩盒我用Gagravarr在下面的评论中引用打印出Java看到的字体列表的Java code的位。我试图等宽
但间距为等同于上面的截图。然后,我尝试装饰
,内容依然清晰可辨(它不应该一直),而间距为真正关闭(见下图)。
On my Windows dev box I tried setting the font to Verdana with font.setFontName("Verdana")
. All of the content definitely changes to Verdana and the sizing on the columns is perfect. On the Linux production box I used the bit of Java code that Gagravarr referenced in the below comments to print out a list of the fonts that Java sees. I tried Monospaced
but the spacing was identical to the above screenshot. I then tried Dingbats
and the content was still readable (which it shouldn't have been) while the spacing was really off (see screenshot below).
推荐答案
我不知道这是否会解决您的问题或没有,但如果你问有没有办法自动调整大小后添加一点点填充? ....是的,你可以通过下面的方式做到这一点。
I am not sure whether this will resolve your problem or not, but if you have asked about "is there a way to add a little padding after autosizing?".... yes you can do it by following way.
testSheet.autoSizeColumn(ColIndex);
testSheet.setColumnWidth(ColIndex ,testSheet.getColumnWidth(ColIndex)+PaddingWidth);
这篇关于Apache的POI自动调整大小时并不十分给足够的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!