xlsxMerge not working with JSReport API



  • Hi ,

    I'm using JsReport 2.4.0 to generate xlsx files. That's working pretty fine on JsReport and Playground.
    But using JSReport API call (from a NodeJs Application), everything inside "xlsxMerge" tags is not displayed.
    {
    "template": { "name" : "sessionRepport" },
    "data": {
    }
    }
    Here is my report configuration :

    {{!--SUMMARY SHEET--}}
    
    {{log "xl/worksheets/sheet1.xml"}}
    
    {{#xlsxMerge "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row[3].c[6]"}}
        <c t="inlineStr"><is><t>{{ref}}</t></is></c>
    {{/xlsxMerge}} 
    
    {{#xlsxMerge "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row[6].c[0]"}}
        <c t="inlineStr"><is><t>{{summary.org}}</t></is></c>
    {{/xlsxMerge}}
    {{#xlsxMerge "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row[6].c[1]"}}
        <c t="inlineStr"><is><t>{{summary.period}}</t></is></c>
    {{/xlsxMerge}}
    {{#xlsxMerge "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row[6].c[2]"}}
        <c t="inlineStr"><is><t>{{summary.reportDate}}</t></is></c>
    {{/xlsxMerge}}
    
    {{#xlsxRemove "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row" 9}}
    {{/xlsxRemove}}
    
    {{!--FILL SUMMARY TAB FOR EACH EMSP--}}
    {{#each summary.emsps}}
        {{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}}
        <row>
            <c></c>
            <c t="inlineStr" s="{{@root.$removedItem.c.[1].$.s}}"><is><t>{{name}}</t></is></c>
            <c t="n" s="{{@root.$removedItem.c.[1].$.s}}"><v>{{nbSession}}</v></c>
            <c t="inlineStr" s="{{@root.$removedItem.c.[2].$.s}}"><is><t>{{timeCumul}}</t></is></c>
            <c t="inlineStr" s="{{@root.$removedItem.c.[2].$.s}}"><is><t>{{chargeCumul}}</t></is></c>
        </row>
        {{/xlsxAdd}}
    {{/each}}
    
    {{#xlsxMerge "xl/tables/table1.xml" "table"}}
        <table ref="{{#getCellTableSummaryCoordinate summary.emsps}}{{/getCellTableSummaryCoordinate}}"/>
    {{/xlsxMerge}}
    
    
    {{!--FILL DETAIL TAB FOR EACH SESSION--}}
    {{#xlsxRemove "xl/worksheets/sheet2.xml" "worksheet.sheetData[0].row" 1}}
    {{/xlsxRemove}}
    
    
    {{#each sessions}}
        {{#xlsxAdd "xl/worksheets/sheet2.xml" "worksheet.sheetData[0].row"}}
        <row>
                    <c></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{org}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{emsp}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{sessionContextCloseDate}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{startDate}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{stopDate}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{consumption}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{startCharge}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{stopCharge}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{chargeDuration}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{idTag}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{zone}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{plug}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{uuid}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{compliance}}</t></is></c>
                    <c t="inlineStr" s="{{@root.$removedItem.c.[0].$.s}}"><is><t>{{maxPower}}</t></is></c>
        </row>
        {{/xlsxAdd}}
    {{/each}}
    
    
    {{#xlsxMerge "xl/tables/table2.xml" "table"}}
        <table ref="{{#getCellTableDetailCoordinate sessions}}{{/getCellTableDetailCoordinate}}"/>
    {{/xlsxMerge}}
    
    {{{xlsxPrint}}}
    

    Can you please help me ?

    Rgds
    Tony



  • There should be no difference in API call.

    Please try to prepare a minimal example that doesn't work for you.
    Like an excel sheet with a single cell and single merge call.
    And attach your client code.



  • Hi jan_blaha , thank you for you answer.
    You are right , the is no difference in API call. The probleme was due to open-office(on linux).
    When I use miscrosoft excel , everything is fine.

    Thanks a lot



  • Puedes ayudarme

    a mi me sale "excel no puede abrir el archivo porque el formato o la extension no son validos"



  • Hi ,

    Please make sure you are saving the file with the right file extension (.xlsx)

    Ex: fileName.xlsx

    Then you should be able to open the file , except if the file is corrupted because of bad content.

    In that case , you'll have to look at jsreport logs , then identify and fix this issue.



  • Do you have an example of sending mail with an excel file?



  • Hi MarlonFH ,

    sorry for my late answer , here is an example of sending email:

    const mailerConf = nconf.get('mailer');

    var configureTransporter = function () {
    return nodemailer.createTransport({
    secure: mailerConf.secure,
    port: mailerConf.port,
    host: mailerConf.host,
    auth: {
    user: mailerConf.user,
    pass: mailerConf.passwd
    }
    });
    }

    var transporter = configureTransporter();

    var toSend = "attachment.xlsx";

    let mailOptions = {
      from: mailerConf.user,
      to: mails,
      subject: 'G2Smart Report',
      text: 'Bonjour,\n Le fichier en pièce jointe contient le rapport ' + recurrenceTexte + ' JSREPORT.',
      attachments: [toSend]
    };
    
    await transporter.sendMail(mailOptions);

Log in to reply
 

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