[英]Date format is written as numerical value after multiple writes in JXL
我正在使用JXL(JExcelAPI)將數據寫入excel。 列之一是日期列,我每張紙上添加了很多行(225+)。 我有3張紙,每張紙都有一個日期列。
第一張工作正常。 第二張紙可以處理多達40行,然后再代替日期格式的值,而只得到數字值,例如42217.75。 第三張紙仍然是數字。 這是我打電話的方法
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);
}
這是每個工作表的循環中正在調用offcourse的調用塊
writeCell(col,rows,task.getDateTime(),"dd-MMM-yyyy hh:mm",sheet);
知道為什么會這樣嗎?
自從我使用API已有好幾年了,但是答案是您需要重用單元格格式...在excel開始出現問題之前,您只能創建有限數量的單元格格式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.