Spreadsheet - Open from Json, then open from Excel

Hi,

I'm using the Template Marker functionality for spreadsheets. My pipeline is as follows :

Front - Vue  : Open the Spreadsheet using it's JSON format
Front - Vue  : Insert markers in it
Front - Vue : Save it using the SaveAsJson functionallity

Back - .NET : Open the Spreadsheet using the json
Back - .NET : Apply the Template Marker
Back - .NET : Save the result both in JSON and Excel format
Back - .NET : Return an AWS S3 link to those 2 files

When I try opening the result in the Vue Component I get 2 different error :

- Front - Vue : Use the Excel format the open the vue component <- Fail 1
or
- Front - Vue : Use the JSON format the open the vue component <- Fail 2

Fail 1 : 
When opening updating the file in the Vue component (initially opened from JSON) with the Excel file I get the error Unsupported File
I tried opening manually after downloading the file and it works perfectly.
Question : Is it possible to open the document from a JSON and then from an Excel file in the Vue Component ?

Fail 2 :
The JSON file returned from the .NET library doesn't look like the one returned from the Vue Component and thus is not accepted. 
Here is my code :

SaveSettings saveSettingsFromJson = new SaveSettings{
FileName = "Test file name",
JSONData = JsonConvert.SerializeObject(json_object["jsonObject"]["Workbook"]),
ContentType = ContentType.Xlsx,
VersionType = VersionType.Xlsx
};

Stream fileStream = Workbook.Save<Stream>(saveSettingsFromJson);
IWorkbook workbook = application.Workbooks.Open(fileStream);
MemoryStream jsonStream = new MemoryStream();
workbook.SaveAsJson(jsonStream);
memStream.Dispose();

QuestioAm I using the SaveAsJson properly ?

The JSON returned :
https://imgur.com/a/W0BukZf



Thank you,
Tuan



3 Replies 1 reply marked as answer

SP Sangeetha Priya Murugan Syncfusion Team March 11, 2021 08:22 AM UTC

Hi Tuan Ardouin, 
 
Thank you for contacting syncfusion support. 
 
We have checked your reported requirement and we would like to let you know that we have already demonstrated this in our knowledge base section itself. In this we have saved the spreadsheet data as jsonobject in database and open the saved jsonobject in spreadsheet. Please find the link below. 
 
 
To open and saving the excel file from the server, we have used ASP.NET workbook server side action (Open, Save). For more details regarding your requirement. Please refer the below link. 
 
 
In the above link, we have done the open/save functionality in a button click event.  
 
Please check the above links and get back to us with the more details like (Excel file and Jsonobject that you have loaded), if you still facing the issue or need any further assistance on this. 
 
Regards, 
Sangeetha M 


Marked as answer

JA Jaswandi February 15, 2022 05:54 PM UTC

Hi ,

I tried to bind data in synfusion excel in AJAX call two ways 1. from database and 2. form excel

1. When I tried to bind from data source data not reflect to spread sheet

function onSheetClick() {

       var spreadsheetObj = $("#Spreadsheet").data("ejSpreadsheet");

        fetch('/Spreadsheet/SpreadsheetFeaturesAfterLoad', {

                method: 'POST',

                headers: {

                    'Content-Type': 'application/json',

                },

                body: JSON.stringify({ name: (document.getElementById("filename")).value }),

            })

                .then((response) => response.json())

                .then((data) => {

                    spreadsheetObj.openFromJson({ file: data }); // convert the json data to file and loaded into spreadsheet

                })

}

2. when I tried to import from excel- it gives me below error

Cannot read properties of undefined (reading 'openFromJson')

function onSheetClick() {

var filename = "C:/Sample/Sample1.xslx";

        var spreadsheetObj = $("#Spreadsheet").data("ejSpreadsheet");

        fetch('/Spreadsheet/SpreadsheetFeaturesAfterLoad', {

                method: 'POST',

                headers: {

                    'Content-Type': 'application/json',

                },

            body: JSON.stringify({ name: filename }),

            })

                .then((response) => response.json())

                .then((data) => {

                    spreadsheetObj.openFromJson({ file: data }); // convert the json data to file and loaded into spreadsheet

                })

}



SP Sangeetha Priya Murugan Syncfusion Team February 16, 2022 02:21 PM UTC

Hi Jaswandi, 
 
We have checked your reported issue and we suspect that you haven’t properly getting spreadsheet instance, so only the script error occurs (Cannot read properties of undefined (reading 'openFromJson'). So, please check whether the instance returns proper value in your end. Before we proceed further, please share the below details. 
 
1.Please share the details, whether you are using EJ1 or EJ2 Spreadsheet. 
2. If possible, please share the issue replicable sample and video. 
3. Please confirm whether you are using ASP. Net Webforms? 
 
Could you please check the above details and get back to us with the requested details, based on that we will check and provide you a better solution quickly. 
 
Regards, 
Sangeetha M 


Loader.
Up arrow icon