trying to export on one excel file using this method:
private Sheet activeSheet;
public void addText(int column, int rowNumber, String s) throws Exception {
// TODO Auto-generated method stub
Row row = activeSheet.getRow(rowNumber);
if(row==null){
row = activeSheet.createRow(rowNumber);
}
Cell cell = row.createCell(column);
s = ToolUtils.nn(s);
if(s.indexOf("\n")!=-1){
int nbLines = StringUtils.countMatches(s, "\n") ;
CellStyle cs = workbook.createCellStyle();
cs.setWrapText(true);
//cs.set
cell.setCellStyle(cs);
row.setHeightInPoints(((nbLines+1)*activeSheet.getDefaultRowHeightInPoints()));
activeSheet.autoSizeColumn(column);
}
//cell.setCellValue(s);
cell.setCellValue(s == null ? "" : s);
}
I have got this error:
java.lang.IllegalStateException: Could not auto-size column. Make sure the column was tracked prior to auto-sizing the column
I have try to call this methode:
trackAllColumnsForAutoSizing()
to fix the issue but it does not work as know method for the sheet interface. Shall I upgrade the apache poi
version?
what shall I do do fix the method that insert data into the excel columns?