xlxs template - cell data-type is not defined by Excell



  • Hi, I have a xlxs template with dynamic data that I export to excel.
    The problem is I didn't find any way excel recognize cell data-type, I mean when I click on excel cell it displays not Generic data-type but number or date0_1684658340428_JSReportPicture.png for example
    This is my template:
    <row>
    {{#each ../data.TableHeaderMapper}}
    <c t="inlineStr">
    <is>
    <t>{{getTd ../this this}}</t>
    </is>
    </c>
    {{/each}}
    </row>



  • This is defined in the cell s attribute which is a reference to the styles.xml.

     <row>      
         <c s="1"><v>11</v></c>
    </row>
    

    You can either find out the right s value in an existing xlsx template you use or use xlsx helpers to update the styles.xml. Like here

    https://playground.jsreport.net/w/anon/nOIQZfMt

    {{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}}
        <row>      
            <c s="1"><v>11</v></c>
        </row>
    {{/xlsxAdd}}
    
    {{#xlsxReplace "xl/styles.xml" "styleSheet.cellXfs"}}
       <cellXfs count="2">
    		<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
    		<xf numFmtId="2" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>
    	</cellXfs>
    {{/xlsxReplace}}
    
    {{{xlsxPrint}}}
    

    As always with xlsx transformations, it requires you to check how the XML structure looks like inside existing xlsx files and replicate the same with xlsx helpers.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.