我的Excel文件中的Sheet1上有一个模板。我可以打开它,将数据放入其中但我无法保存回Sheet1。
<cfspreadsheet
action="update"
filename = "#theFileCopy#"
name = "a"
sheetName="Sheet1">
令人愤怒的是,对于更新语句,此代码告诉我Sheet1已经存在。我知道它存在,我想覆盖它。我甚至不能使用action = write将电子表格写入一个全新的文件,因为它给了我一个空指针异常。我甚至尝试将表单添加到不同名称的同一文件中并删除sheet1但是也失败了,另一个空指针!我感到沮丧。为什么这不起作用?
Stack Trace
at cfRelocationForm2ecfc1823847668$funcPRODUCERELOCATIONFORM.runFunction(xxx/RelocationForm.cfc:152)
at cfRelocationForm2ecfc1823847668$funcPRODUCERELOCATIONFORM.runFunction(xxx/RelocationForm.cfc:152)
java.lang.NullPointerException
at org.apache.poi.xssf.usermodel.XSSFRichTextString.toCTFont(XSSFRichTextString.java:458)
at org.apache.poi.xssf.usermodel.XSSFRichTextString.getFontOfFormattingRun(XSSFRichTextString.java:397)
at org.apache.poi.xssf.usermodel.helpers.ColumnHelper.getColumnWidth(ColumnHelper.java:368)
at org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(XSSFSheet.java:337)
at coldfusion.excel.Excel.autoResize(Excel.java:1336)
at coldfusion.excel.Excel.autoResize(Excel.java:1327)
at coldfusion.excel.Excel.writeExcel(Excel.java:4824)
at coldfusion.tagext.lang.SpreadSheetTag.writeToExcel(SpreadSheetTag.java:237)
at coldfusion.tagext.lang.SpreadSheetTag.doStartTag(SpreadSheetTag.java:157)
at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2799)
at
cfRelocationForm2ecfc1823847668$funcPRODUCERELOCATIONFORM.runFunction(xxx\RelocationForm.cfc:152)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:518)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:660)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:469)
at coldfusion.filter.ComponentFilter.invoke(ComponentFilter.java:193)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:442)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:112)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:30)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:58)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.xml.rpc.CFCServlet.invoke(CFCServlet.java:155)
at coldfusion.xml.rpc.CFCServlet.doGet(CFCServlet.java:289)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:414)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:204)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
导致错误的行
<cfspreadsheet action="read" src="#theFileCopy#" name="spreadSheetVar" >
<cfset spreadsheetRemoveSheet(spreadsheetVar,"Relocation Form")>
<cfspreadsheet action="write" filename="#theFileCopy#" name="spreadsheetVar" overwrite="true" >
答案 0 :(得分:1)
cfspreadsheet读取将执行xlsx文件但写入不会。令人恼火。这是空指针发生的地方,基本上每当我试图编写电子表格时。
答案 1 :(得分:0)
行动=&#34;写&#34;结合overwrite =&#34; true&#34;应该这样做。根据Cf文档,UPDATE不允许修改现有工作表,ikt只允许您向excel添加新工作表。因此,您必须使用具有覆盖属性的动作写入。