JXL 日期时间不需要兼职



您好,我写了这段代码以在 excel 中添加日期,但是当添加单元格时,他也会显示时间。我想消除时间部分。如果有人可以提供帮助,请提前感谢您..

Tabla[tabReg][tabCol]);是字符串数组

          SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
          Date convertedDate = dateFormat.parse(Tabla[tabReg][tabCol]);
          DateFormat df = new DateFormat("yyyy/MM/dd");    
          WritableCellFormat wdf = new WritableCellFormat(df);
          cf = new WritableCellFormat(df);              
          cell = new jxl.write.DateTime(exCol,exReg, convertedDate);

          cell.setCellFormat(wdf);
          sheet2.addCell(cell);

解决方案是在创建 de cell 时放置格式。

cell = new jxl.write.DateTime(exCol,exReg, convertedDate,wdf);

相关内容

最新更新