0

I am using JXL (JExcelAPI) to write data to excel. One of the columns is date column and I am adding a lot of rows per sheet (225+). I have 3 sheets and each sheet has a date column.

First sheet works fine. Second sheet works fine up to like 40 rows and then after that, instead of a date formatted value, I get just numerical value such as 42217.75. 3rd sheet continues to be numerical. Here is the method I am call

public void writeCell(int columnPosition, int rowPosition, Date date, String format,
            WritableSheet sheet) throws RowsExceededException, WriteException{

        DateFormat customDateFormat = new DateFormat (format); 
        WritableCellFormat dateFormat = new WritableCellFormat (customDateFormat); 
        DateTime dateCell = new DateTime(columnPosition, rowPosition, date, dateFormat); 
        sheet.addCell(dateCell);
    }

And here is the calling block which offcourse is being called in a loop per sheet

writeCell(col,rows,task.getDateTime(),"dd-MMM-yyyy hh:mm",sheet);   

Any idea why this is happening?

Snake
  • 14,228
  • 27
  • 117
  • 250

1 Answers1

0

It's been years since I worked with the API, but the answer is that you need to reuse your cell formats... You can only create a limited number of them before excel starts having issues.

Alcanzar
  • 16,985
  • 6
  • 42
  • 59