Export to Excel

Posted by: srinivasan.lakshmanan on 5 July 2018, 6:37 pm EST

    • Post Options:
    • Link

    Posted 5 July 2018, 6:37 pm EST

    Hi,

    I have issue in exporting the excel sheet that has data from database.Only the sheet format got exported in excel we are not getting the data.

    $(document).ready(function () {

    var spread = new GC.Spread.Sheets.Workbook(document.getElementById(“ss”), { sheetCount: 3 });

    var sheet = spread.getSheet(0);

    var excelIo = new GC.Spread.Excel.IO();

    showDelayDiv();

    readData(sheet, ‘@Url.Action(“GetData”, “Forecast”)’, function () {

    hideDelayDiv();

    });

    $("#saveExcel").click(function () {
    
        var fileName = $("#exportFileName").val();
        var password = $("#password").val();
        if (fileName.substr(-5, 5) !== '.xlsx') {
            fileName += '.xlsx';
        }
        debugger;
     
       var json =spread.toJSON();
      
     
        //export
    
        excelIo.save(json , function (blob) {
            saveAs(blob, fileName);
        },
            function (e)
            {
            // process error
            console.log(e);
            },
            { password: password }
        );
    
    });
        }
    });
    
  • Posted 5 July 2018, 9:10 pm EST

    Hello,

    You need to set the parameter while serializing the Spread.Sheets to JSON as "includeBindingSource:True’. For example:

    var json = this.spread.toJSON({
    includeBindingSource: true,
    rowHeadersAsFrozenColumns: true,
    columnHeadersAsFrozenRows: true,
    ignoreFormula: true,
    ignoreStyle: false
    });
    

    Thanks,

    Deepak Sharma

  • Posted 5 July 2018, 11:20 pm EST

    Thanks Deepak for your quick response.

    now i am able to export the excel with data.While i am trying to Import an Excel the Existing Sheet with Data got replaced with Imported Excel.How to import it in Separate Sheet.

    Note : I am getting “Evaluated Version” message in one of the Sheets.Is this because of trial Version.If not how to rectify it???

  • Posted 9 July 2018, 8:51 pm EST

    Hello,

    To get the data in separate sheet you can simply call fromJSON method for sheet. For example:

    var sheet2 = spread.getActiveSheet();

    sheet2.fromJSON(JSON.parse(jsonStr));

    You must include the deployment licnese string in your project in order to get rid of the Evaluation version message.

    Thanks,

    Deepak Sharma

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels