We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Import / Export to function/json instead of excelUrl

Hi

Is there a way to export and import json data instead of the exportUrl to a server? I analized the json data thtat is posted to the server and I would like to intercept this data on the client and store it somewhere and not create an excel file. I would like to import this json data later without having to call a server.

is this possible or is there a plan to implement this?

Kind regards,

Freddy

1 Reply

SI Silambarasan I Syncfusion Team February 4, 2016 12:57 PM UTC

Hi Freddy,


Thank you for your interest in Syncfusion products.


Your requirement “Spreadsheet Import in JSON Format” is feasible and can be achieved by using “loadFromJSON” client-side method.  Currently, we don’t have API for export the Spreadsheet in JSON format.  However, we have already considered this is an improvement task and created the improvement task for “Spreadsheet Export in JSON Format”.  This fix will be included in our Essential Studio 2015 Volume 4 Service pack 1.


Meanwhile, we have created a workaround for your requirement “Import and Export the Spreadsheet as JSON data” has been achieved. Please refer the below code snippets.


CODE SNIPPET:


[HTML]

<table>

<tr>

    //...

            <table>

                //...

                    <td>

                        <input type="text" id="ExportName" />

                    </td>

                    <td>

                        <button id="getJsonBtn" onclick="getJSONData()">Get JSON</button>

                    </td>

               //...

                    <td>

                        <select id="loadJsonDD" onchange="loadJSONData(this)">

                            //...

                        </select>

                    </td>

               </table>

    //...

</tr>

</table>

//...

<div id="Spreadsheet"></div>


[SCRIPT]

window.localData = {

    //...

};


$(function () {

    $("#Spreadsheet").ejSpreadsheet({

        //...

        loadComplete: "loadComplete"

    });

});


function loadComplete(args) {


    //Here extend the ejSpreadsheet.Extension

    $.extend(this, ej.spreadsheetFeatures.extension);

}


function loadJSONData(args) {

    var xlObj = $("#Spreadsheet").data("ejSpreadsheet"), name = args.value;


    if (window.localData[name])

        //Import JSON data here

        xlObj.loadFromJSON(window.localData[name]);

}


function getJSONData(args) {

    var xlObj = $("#Spreadsheet").data("ejSpreadsheet"), name = $("#ExportName").val(), JSONData;


    //Export as JSON data

    JSONData = xlObj.saveAsJSON();


    if (name.length && JSONData) {

        //Store JSON data locally

        window.localData[name] = JSONData;

        //...

    }

}


Sample Link: http://www.syncfusion.com/downloads/support/forum/121883/ze/SampleApplication1631086689


Please let us know if you have any further assistance.


Regards,

Silambarasan I


Loader.
Up arrow icon