Menu

#140 ZK Spreadsheet: copy&paste empty cells

open
nobody
General (11)
5
2010-04-28
2010-04-28
Sam Chuang
No

Problem: Exception in exporting after copy&paste empty cells, see the call stack below.

Steps: 1. Copy&paste some empty cells 2. do exporting

This is because a new cell object was created for each empty cell, but with null format property. A sample fix is like below in org.zkoss.zss.ui.state.pasteCellState(Sheet, Position):

tmpCell.setFormat(cellFormat[cellIndex++]);

==>

if (cellFormat[cellIndex] != null)
tmpCell.setFormat(cellFormat[cellIndex++]);
else
tmpCell.setFormat(new FormatImpl());

Callstack:

java.lang.NullPointerException
at jxl.write.biff.Styles.getFormat(Styles.java:214)
at jxl.write.biff.CellValue.addCellFormat(CellValue.java:466)
at jxl.write.biff.CellValue.setCellDetails(CellValue.java:280)
at jxl.write.biff.LabelRecord.setCellDetails(LabelRecord.java:216)
at jxl.write.biff.WritableSheetImpl.addCell(WritableSheetImpl.java:1072)
at org.zkoss.zss.model.impl.ExcelExporter.exportEachCell(ExcelExporter.java:246)
at org.zkoss.zss.model.impl.ExcelExporter.exportEachSheet(ExcelExporter.java:234)
at org.zkoss.zss.model.impl.ExcelExporter.exportEachBook(ExcelExporter.java:204)
at org.zkoss.zss.model.impl.ExcelExporter.exports(ExcelExporter.java:147)

Discussion


Log in to post a comment.