前些天写一个功能,我在excel中定义了一个模板,用户选择数据后根据模板生产excel;但是遇到要生产多页的情况;简单的說就是sheet1的模板要复制到sheet2,于是我使用了copySheet和importSheet两个jxl的方法,其中遇到了java.lang.NullPointerException的问题;我又想直接复制cell得了,可是没法实现复制合并单元格的情况!
来我还是觉定使用copysheet和importsheet两个方法;myeclipse根据报错的提示,我从网上下载了jxl最新的源码,根据提示在src/jxl/write/biff/WritableSheetCopier.java发现了这段代码
try
{
if (c != null)
{
toSheet.addCell(c);
// Cell.setCellFeatures short circuits when the cell is copied,
// so make sure the copy logic handles the validated cells
if (c.getCellFeatures() != null &
c.getCellFeatures().hasDataValidation())
{
validatedCells.add(c);
}
}
}
很明显&没有短路机制,