Possible to format cells with xlxs without using an xlxs template file?



  • After some tinkering I finally managed to format datetime data so Excel will interpret them as such. The only way I can get the cells in the sheet formatted as datetime is to preformat cells in an xlxs template file and copy from this row when I insert new rows. But I'd rather not have to use a template file, since it's a pita to update this everytime I want to add or remove a column in the dataset.

    {{for controlpoints}}
        {{xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}}
        <row>
            <c t="d"><v>{{:~toIsoDate(resolvedAt)}}</v></c>
        </row>
        {{/xlsxAdd}}
    {{/for}}
    
    {{xlsxPrint}}
    {{/xlsxPrint}}
    
    function toIsoDate(d) {
        if(!d) return null;
        var date = new Date(d);
        return date.toISOString();
    }
    

Log in to reply
 

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