JXLS - Column width lost
I am using JXLS to create an Excel sheet. In the templa开发者_StackOverflowte, I have specified the column widths needed for every column. The output was HSSFWorkbook. From the HSSFWorkbook object, I am creating a byte array as shown below. The problem is, I lose the column width.
byte[] bytes = null;
HSSFWorkbook workbook = (HSSFWorkbook) transformer.transformXLS(inputStream, beans);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024);
workbook.write(byteArrayOutputStream);
bytes = byteArrayOutputStream.toByteArray();
Any suggestions to fix this issue?
Found the answer. The following part should be placed at the third line.
for(int len = 0; len < 11; len++){
workbook.getSheetAt(0).setColumnWidth(len, 5200);
}
Found the answer. The following part should be placed at the third line.
for(int len = 0; len < 11; len++){
workbook.getSheetAt(0).setColumnWidth(len, 5200);
}
精彩评论