生成的 Excel 文件上的 ZK API Range.insert 出现 NullPointerException (JExcel/Apache POI)
帮朋友的忙,她的疑问如下:
嗨!我目前正在使用 jexcelapi 创建excel文件,然后我读 他们使用 zk 电子表格。我尝试过 在文档中找到的代码 插入列和移动单元格 到右边但不幸的是,一个空 每当我出现指针异常 尝试插入/移动单元格。我也 尝试上传excel文件我 使用 jexcelapi 创建到 zssapp (只是为了确定)但是一个空指针 也出现了。但当我尝试阅读时 由 MS Excel 创建的 excel 文件, 工作正常。有谁遇到过 以前有这个问题吗?任何帮助都会 非常感谢。 PS:我也 尝试使用 POI 创建文件。我 还遇到空指针 异常。
这是错误:
java.lang.NullPointerException
at org.zkoss.poi.hssf.record.XFExtRecord.cloneXFExtFrom(XFExtRecord.java:91)
at org.zkoss.poi.hssf.usermodel.HSSFCellStyle.cloneStyleFrom(HSSFCellStyle.java:835)
at org.zkoss.poi.hssf.usermodel.HSSFCellStyle.cloneStyleFrom(HSSFCellStyle.java:825)
at org.zkoss.zss.model.impl.BookHelper.copyFromStyleExceptBorder(BookHelper.java:3308)
at org.zkoss.zss.model.impl.HSSFSheetImpl.shiftColumnsRange(HSSFSheetImpl.java:601)
at org.zkoss.zss.model.impl.BookHelper.insertHSSFRange(BookHelper.java:1942)
at org.zkoss.zss.model.impl.BookHelper.insertRange(BookHelper.java:1931)
at org.zkoss.zss.model.impl.RangeImpl.insert(RangeImpl.java:649)
at data.InitWindow.onClick$shiftCellRight(InitWindow.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.zkoss.zk.ui.event.GenericEventListener.onEvent(GenericEventListener.java:81)
at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:192)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:305)
at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:328)
at org.zkoss.zk.ui.AbstractComponent$ForwardListener.onEvent(AbstractComponent.java:3022)
at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:192)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1603)
at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1387)
at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1107)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:563)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:457)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:465)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
这是我用来创建的代码 文件。我在这里所做的是创建一个 每当创建表单时都会生成 excel 文件:
public void createExcel(Integer formID, String loc){
try {
File path = new File(loc);
if (!path.exists()) {
boolean status = path.mkdirs();
}
String filename = loc + formID +".xls";
WorkbookSettings ws = new WorkbookSettings();
ws.setLocale(new Locale("en", "EN"));
WritableWorkbook workbook;
workbook = Workbook.createWorkbook(new File(filename), ws);
workbook.createSheet("Sheet1", 0);
workbook.write();
workbook.close();
} catch (IOException e) {
e.printStackTrace();
} catch (WriteException e) {
e.printStackTrace();
}
}
据我所知,她使用 gwt 框架作为使用 zk 类的桥梁。
此查询的原始帖子可以在这里找到: http://www.zkoss.org/forum/ listComment/15683
非常感谢大家!
Favor for a friend, here's her query:
Hi! I am currently using jexcelapi to
create excel files and then I read
them using zk spreadsheet. I tried the
code found in the documentation for
inserting columns and shifting cells
to the right but unfortunately, a null
pointer exception shows up whenever I
try to insert/shift cells. I also
tried uploading the excel files I
created using jexcelapi to the zssapp
(just to be sure) but a null pointer
also shows up. But when I try to read
excel files created by MS Excel, it
works fine. Has anyone encountered
this problem before? Any help would
greatly be appreciated. PS: I also
tried using POI to create files. I
also encounter a null pointer
exception.
Here is the error:
java.lang.NullPointerException
at org.zkoss.poi.hssf.record.XFExtRecord.cloneXFExtFrom(XFExtRecord.java:91)
at org.zkoss.poi.hssf.usermodel.HSSFCellStyle.cloneStyleFrom(HSSFCellStyle.java:835)
at org.zkoss.poi.hssf.usermodel.HSSFCellStyle.cloneStyleFrom(HSSFCellStyle.java:825)
at org.zkoss.zss.model.impl.BookHelper.copyFromStyleExceptBorder(BookHelper.java:3308)
at org.zkoss.zss.model.impl.HSSFSheetImpl.shiftColumnsRange(HSSFSheetImpl.java:601)
at org.zkoss.zss.model.impl.BookHelper.insertHSSFRange(BookHelper.java:1942)
at org.zkoss.zss.model.impl.BookHelper.insertRange(BookHelper.java:1931)
at org.zkoss.zss.model.impl.RangeImpl.insert(RangeImpl.java:649)
at data.InitWindow.onClick$shiftCellRight(InitWindow.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.zkoss.zk.ui.event.GenericEventListener.onEvent(GenericEventListener.java:81)
at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:192)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:305)
at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:328)
at org.zkoss.zk.ui.AbstractComponent$ForwardListener.onEvent(AbstractComponent.java:3022)
at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:192)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1603)
at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1387)
at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1107)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:563)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:457)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:465)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
And here is the code I use to create
files. What I do here is create an
excel file whenever a form is created:
public void createExcel(Integer formID, String loc){
try {
File path = new File(loc);
if (!path.exists()) {
boolean status = path.mkdirs();
}
String filename = loc + formID +".xls";
WorkbookSettings ws = new WorkbookSettings();
ws.setLocale(new Locale("en", "EN"));
WritableWorkbook workbook;
workbook = Workbook.createWorkbook(new File(filename), ws);
workbook.createSheet("Sheet1", 0);
workbook.write();
workbook.close();
} catch (IOException e) {
e.printStackTrace();
} catch (WriteException e) {
e.printStackTrace();
}
}
From what I've found out, she's using a gwt frame as a bridge to use zk classes.
The original post of this query can be found here: http://www.zkoss.org/forum/listComment/15683
Thanks very much guys!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是错误的根源:
如果我将单元格向右移动,该错误也会显示。
Here is where the error originated:
The error also shows up if I shift cells to the right.