ejs , xlsx templates not working after jsreport v2 upgrade
-
Is there a way to make ejs, xlsx templates work after jsreport v2 upgrade. We have written lots of xlsx template in ejs and templates were working before the upgrades. I signed up for temporary cloud subscription and tested one of our ejs/xlsx template on
jsreportonline.net
, its working fine there which indicates that i am missing something but don't know what. After the upgrade we are seeing issues such as this. Please help!!Thanks
Error: Unable to parse xlsx template JSON string (maybe you are missing {{{xlsxPrint}}} at the end?): <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <styleSheet xmlns="http://schemas.openx... at module.exports (C:\source\jsreportapp\node_modules\jsreport-core\lib\util\createError.js:9:13) at Reporter.createError (C:\source\jsreportapp\node_modules\jsreport-core\lib\reporter.js:259:12) at C:\source\jsreportapp\node_modules\jsreport-xlsx\lib\fallback.js:45:20 at tryCatcher (C:\source\jsreportapp\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (C:\source\jsreportapp\node_modules\bluebird\js\release\promise.js:512:31) at Promise._settlePromise (C:\source\jsreportapp\node_modules\bluebird\js\release\promise.js:569:18) at Promise._settlePromise0 (C:\source\jsreportapp\node_modules\bluebird\js\release\promise.js:614:10) at Promise._settlePromises (C:\source\jsreportapp\node_modules\bluebird\js\release\promise.js:689:18) at Async._drainQueue (C:\source\jsreportapp\node_modules\bluebird\js\release\async.js:133:16) at Async._drainQueues (C:\source\jsreportapp\node_modules\bluebird\js\release\async.js:143:10) at Immediate.Async.drainQueues (C:\source\jsreportapp\node_modules\bluebird\js\release\async.js:17:14) at runCallback (timers.js:810:20) at tryOnImmediate (timers.js:768:5) at processImmediate [as _immediateCallback] (timers.
-
how would such the most simple ejs - xlsx template look like?
Like this?
<%=xlsxPrint()%>
-
I assume that it should look like this <%=xlsxPrint()%>, but ejs does not accept this.
Before upgrade, i never used <%=xlsxPrint()%> for ejs/xlsx templates. I tried adding line at the end of template, but I see following errorError while executing templating engine. ejs:245 243| 244| </worksheet> >> 245| <%=xlsxPrint()%> Cannot read property 'root' of undefined. Error on line 8:35. 6 | 7 | function print () { > 8 | ensureWorksheetOrder(this.ctx.root.$xlsxTemplate) | ^ 9 | bufferedFlush(this.ctx.root) 10 | return JSON.stringify({ 11 | $xlsxTemplate: this.ctx.root.$xlsxTemplate, TypeError: ejs:245 243| 244| </worksheet> >> 245| <%=xlsxPrint()%> Cannot read property 'root' of undefined at Object.print (evaluate-template-engine-helpers.js:8:35) at Object.xlsxPrint (evaluate-template-engine-helpers.js:404:17) at eval (eval at compile (C:\source\jsreportapp\node_modules\jsreport-ejs\node_modules\ejs\lib\ejs.js:584:12), <anonymous>:50:25) at returnedFn (C:\source\jsreportapp\node_modules\jsreport-ejs\node_modules\ejs\lib\ejs.js:615:17) at C:\source\jsreportapp\node_modules\jsreport-ejs\lib\ejsEngine.js:10:12 at Object.apply (C:\source\jsreportapp\node_modules\vm2\lib/contextify.js:288:34) at evaluate-template-engine.js:1:41 at ContextifyScript.Script.runInContext (vm.js:59:29) at VM.run (C:\source\jsreportapp\node_modules\vm2\lib\main.js:212:72) at run (C:\source\jsreportapp\node_modules\jsreport-core\lib\render\safeSandbox.js:171:19)
-
yes, so how it was working for you previously in v1 for you?
-
yes, it was working for v1, that's why we added so many ejs/xlsx templates. For v1, we did not use xlsxPrint at all
-
I asked 2 times how does your template look like with ejs and still no answer. :)
Can you replicate the issue in playground?
-
Here is how my template looks like. I can't replicate the issue in playground with same template. I replaced some keywords with "sampledata" or "some data here" as its confidential
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"> <fonts count="5" x14ac:knownFonts="1"> <font> <sz val="8"/> <color theme="1"/> <name val="Arial"/> <family val="2"/> <charset val="1"/> </font> <font> <b/> <sz val="8"/> <color theme="1"/> <name val="Arial"/> <family val="2"/> <charset val="1"/> </font> <font> <b/> <sz val="8"/> <color theme="1"/> <name val="Arial"/> <family val="2"/> <charset val="1"/> </font> <font> <b/> <i/> <sz val="8"/> <color theme="1"/> <name val="Arial"/> <family val="2"/> <charset val="1"/> </font> <font> <sz val="8"/> <color theme="1"/> <name val="Arial"/> <family val="2"/> <charset val="1"/> </font> </fonts> <fills count="3"> <fill> <patternFill patternType="none"/> </fill> <fill> <patternFill patternType="gray125"/> </fill> <fill> <patternFill patternType="solid"> <fgColor theme="6" tint="0.59999389629810485"/> <bgColor indexed="64"/> </patternFill> </fill> </fills> <borders count="3"> <border> <left/> <right/> <top/> <bottom/> <diagonal/> </border> <border> <left style="thin"> <color indexed="64"/> </left> <right style="thin"> <color indexed="64"/> </right> <top style="thin"> <color indexed="64"/> </top> <bottom style="thin"> <color indexed="64"/> </bottom> <diagonal/> </border> <border> <left/> <right style="thin"> <color indexed="64"/> </right> <top style="thin"> <color indexed="64"/> </top> <bottom style="thin"> <color indexed="64"/> </bottom> <diagonal/> </border> </borders> <cellStyleXfs count="1"> <xf numFmtId="0" fontId="0" fillId="0" borderId="0"/> </cellStyleXfs> <cellXfs count="18"> <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/> <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyBorder="0"/> <xf numFmtId="0" fontId="2" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment horizontal="center" wrapText="1"/> </xf> <xf numFmtId="0" fontId="2" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment horizontal="center"/> </xf> <xf numFmtId="0" fontId="2" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment horizontal="left" wrapText="1"/> </xf> <xf numFmtId="0" fontId="3" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment horizontal="right"/> </xf> <xf numFmtId="0" fontId="4" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment horizontal="left"/> </xf> <xf numFmtId="0" fontId="4" fillId="0" borderId="1" xfId="0" applyFont="1" applyBorder="1" applyAlignment="1"> <alignment horizontal="center"/> </xf> <xf numFmtId="0" fontId="4" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment horizontal="left" wrapText="1"/> </xf> <xf numFmtId="0" fontId="4" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment horizontal="left" wrapText="1"/> </xf> <xf numFmtId="0" fontId="4" fillId="0" borderId="1" xfId="0" applyFont="1" applyBorder="1" applyAlignment="1"> <alignment horizontal="left" wrapText="1"/> </xf> <xf numFmtId="0" fontId="4" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0"/> <xf numFmtId="0" fontId="4" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment wrapText="1"/> </xf> <xf numFmtId="0" fontId="4" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment wrapText="1"/> </xf> <xf numFmtId="0" fontId="2" fillId="2" borderId="0" xfId="0" applyFont="1" applyFill="1" applyBorder="0" applyAlignment="1"> <alignment horizontal="center"/> </xf> <xf numFmtId="0" fontId="2" fillId="2" borderId="1" xfId="0" applyNumberFormat="1" applyFont="1" applyFill="1" applyBorder="1" applyAlignment="1"> <alignment horizontal="center" wrapText="1"/> </xf> <xf numFmtId="0" fontId="2" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment horizontal="left"/> </xf> <xf numFmtId="0" fontId="2" fillId="0" borderId="0" xfId="0" applyFont="1" applyBorder="0" applyAlignment="1"> <alignment horizontal="center" wrapText="1"/> </xf> </cellXfs> <cellStyles count="1"> <cellStyle name="Normal" xfId="0" builtinId="0"/> </cellStyles> <dxfs count="0"/> <tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16"/> <extLst> <ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"> <x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1"/> </ext> <ext uri="{9260A510-F301-46a8-8635-F512D64BE5F5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"> <x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1"/> </ext> </extLst> </styleSheet> <worksheet name="ExcelExport" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <dimension ref="A1"/> <sheetViews> <sheetView workbookViewId="0"/> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <cols> <col min="3" max="3" width="30" customWidth="1" /> <col min="4" max="6" width="20" customWidth="1" /> </cols> <sheetData> <%for(var x=0;x<sampledata.length;x++){%> <row customFormat="1"> <c></c><c></c><c></c> <c t="inlineStr" s="3" ><is><t><%=filters[0]['data']%> Some data here</t></is></c> </row> <row customFormat="1"> <c></c><c></c><c></c> <c t="inlineStr" s="3" ><is><t> <%=filters[0]['data']%></t></is></c> </row> <row customFormat="1"> <c></c><c></c><c></c> <c t="inlineStr" s="3" ><is><t><%=filters[0]['date']%></t></is></c> </row> <row></row> <row customFormat="1"> <c></c><c></c> <c t="inlineStr" s="4" ><is><t><%=sampledata[x]['data']%></t></is></c> </row> <row customFormat="1"> <c></c><c></c> <c t="inlineStr" s="4" ><is><t>Some data here</t></is></c> <c t="inlineStr" s="4"><is><t>Some data here</t></is></c> <c t="inlineStr" s="4"><is><t>Some data here</t></is></c> <c t="inlineStr" s="4"><is><t>Some data here</t></is></c> </row> <% var distArr = exports[x]['...'] %> <%for(var i=0;i<test.length;i++){%> <row> <c></c><c></c> <c t="inlineStr" s="10"><is><t><%=test[i]['...']%></t></is></c> <c t="inlineStr" s="10"><is><t><%=test[i]['...']%></t></is></c> <c t="inlineStr" s="10"><is><t><%=test[x]['...']%></t></is></c> <c t="inlineStr" s="10"><is><t><%=test[i]['...']%></t></is></c> </row> <%}%> <row></row> <row></row> <%}%> </sheetData> <phoneticPr fontId="1" type="noConversion"/> <pageMargins left="0.25" right="0.25" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> <pageSetup orientation="landscape"/> </worksheet>
-
Ok, you use the deprecated old format.
Please upgrade thejsreport-xlsx
usingnpm i jsreport-xlsx@2.0.2 --save --save-exact
There is hotfix which is on jsreportonline/playground but not in jsreport@2.2.0 yet.
-
thank you!! its fixed