如何使用Coldfusion编辑电子表格

时间:2014-04-02 07:58:31

标签: excel coldfusion

关于这方面的大量文档,我已经完成了所有这些。然而,没有人完全回答我的问题我想用Coldfusion编辑电子表格。我将在这里强调EDIT,因为基本上我想要做的是打开一个已经有模板的电子表格并插入一些数据。我见过的许多方法都涉及将数据从电子表格读入一些查询对象,编辑它然后将其写回来,这不可避免地搞砸了很好的模板格式。

我虽然这可能有用,但是当我尝试编写文件时,我得到一个NullPointerException。一个变量似乎正好拿起电子表格模板。

<cfscript> 
    a = SpreadSheetRead("#theFileCopy#");
    SpreadsheetAddRow(a,"150,ENGL,95,Poetry 1",8,1); 
    SpreadsheetWrite(a,"#theFileCopy#","yes"); 
</cfscript> 

Stack Trace
at cfRelocationForm2ecfc1823847668$funcPRODUCERELOCATIONFORM.runFunction(xxx/xxx/RelocationForm.cfc:118) 

 at   cfRelocationForm2ecfc1823847668$funcPRODUCERELOCATIONFORM.runFunction(xxx/xxx/RelocationForm.cfc:118) 

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.runtime.CFPage.SpreadSheetWrite(CFPage.java:7924)
    at coldfusion.runtime.CFPage.SpreadSheetWrite(CFPage.java:7895)
    at cfRelocationForm2ecfc1823847668$funcPRODUCERELOCATIONFORM.runFunction(xxx\xxx\xxx\RelocationForm.cfc:118)
    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,"Sheet1")>
    <cfset spreadsheetRemoveSheet(spreadsheetVar,"Sheet2")>
    <cfset spreadsheetRemoveSheet(spreadsheetVar,"Sheet3")>
    <cfspreadsheet action="write" filename="#theFileCopy#"  name="spreadsheetVar" overwrite="true" >
    <cfoutput>Finished</cfoutput>

删除sheet3行可以使这个工作。一旦我将sheet3添加到卸妆器,我就会得到一个nullpointer。 Sheet3肯定存在。

0 个答案:

没有答案