Converting 0.13.2 xlsx template to 1.x
-
Hi folks,
The template below no longer works in 1.x due to the xlsx enhancements. Since it's in EJS, could somebody give me the high-level instructions on how to update or what might be incompatible with 1.x?
If I try and "unzip text.xlsx" from bash, I get:
Archive: test.xlsxcaution: zipfile comment truncated error [test.xlsx]: missing 3282865094 bytes in zipfile (attempting to process anyway) error [test.xlsx]: attempt to seek before beginning of zipfile (please check that you have transferred or created the zipfile in the appropriate BINARY mode and that you have compiled UnZip properly)
The template that worked on 0.13.2 is:
<worksheet 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="13.5"/> <cols> <% if(template_options) { _.forEach(_.get(template_options, 'fields', []), function(field, index) { %><col min="<%= index+1 %>" max="<%= index+1 %>" width="<%= field.width || 18 %>" /> <% })}; %> </cols> <sheetData> <row> <% if(template_options) { _.forEach(_.get(template_options, 'fields', []), function(field, index) { %><c t="inlineStr"><is><t><%- field.label %></t></is></c> <% })}; %> </row> {{for table.data}} <row> <% if(template_options) { _.forEach(_.get(template_options, 'fields', []), function(field, index) { %> <% if ( field.type == "integer" || field.type == "number" || field.type == "float") { %> <c t="n"><v>{{><%- field.value %>}}</v></c> <% } else { %> <c t="inlineStr"><is><t>{{><%- field.value %>}}</t></is></c> <% } %> <% })}; %> </row> {{/for}} </sheetData> <phoneticPr fontId="1" type="noConversion"/> <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> <pageSetup paperSize="9" orientation="portrait" horizontalDpi="200" verticalDpi="200"/> </worksheet>
-
Please put the template with data to the playground so we can take a look.
The xlsx recipe in jsreport@1 is so far back compatible with the 0.13, so it should work.
-
https://playground.jsreport.net/studio/workspace/Hy7m2WABZ/5
NOTE: Pressing Run works fine. Must Download to see the issue
-
Thank you. The unzip works for me nice. I've tried now
- windows native
- windows total commander
- ubuntu native
- ubuntu unzip
-
What utility you use for unzip? Can you try a different one?
-
Hmm, strange -- I'm using ubuntu native (opera browser). Let me try a different browser...
-
I was using FF
-
Weird, the unzip now works on these (I wonder if the size of the data, which I trimmed down has an effect)
Did you try and open in LibreOffice? Here's what I'm seeing:
-
Yes, I doesn't work for me in Libre Office as well where the MS excel works fine. Before digging into it...
Do you have many templates like this? Even more complex? Would it be too time consuming to use the new format?
It was only like one minute to convert this one, see here
https://playground.jsreport.net/studio/workspace/Hy7m2WABZ/8Note that the new format for some reason outputs xlsx which works in Libre Office
-
Probably -- I'll have to investigate how to handle that during the upgrade. Thanks Jan!
-
Ah, the issue is the file creation is using a \ instead of a slash:
./xl\_rels/workbook.xml.rels ./xl\theme/theme1.xml ./xl\worksheets/sheet1.xml
If I move these directories
xl\_rels
toxl/_rels
(or more specifically_rels
underxl/
) then it works fine.