How to format a column instead of cell in POI hssf

前提是你 提交于 2019-12-04 18:31:46

There is a much better way, at least when you work with the "new" Excel format. Use:

((XSSFSheet)sheet).getColumnHelper().setColDefaultStyle(col, myStyle);

Using this will ensure the styles continue even below the rows where you inserted data. And the resulting file will also be smaller.

Sam

Found the answer here

http://poi.apache.org/faq.html#faq-N1014B go to the section

  1. I am using styles when creating a workbook in POI, but Excel refuses to open the file, complaining about "Too Many Styles".

Sam

Swapnil

As you have not defined you CellStyle object outside Loop so it is creating every time new object for the Workbook so creating multiple object every time throws error.

So create CellStyle object at higher level in class & refer to same object in Loop with wb.createCellStyle();

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!