I saw there is an option to do that in grid but couldn't find the equivalent methods in spreadsheet. Is this supported? what is the recommendation to do this? I just want to allow the user to click a button and download the spreadsheet as excel or csv.
Hi Michael Cheung,
We have checked your reported query of saving a file programmatically in a button click. And it can be achieved by using the ‘save’ public method of our Spreadsheet component. With this method, you can specify the saveUrl, file name, and type of file to be saved, such as Xlsx, Xls, Csv, and Pdf.
To demonstrate this functionality, we've prepared a sample in which we've provided buttons to download both .xlsx and .csv files and attached below along with the code snippet and video demonstration for your reference,
Code snippet:
|
saveAsXlsx: function() { var spreadsheet = this.$refs.spreadsheet; spreadsheet.save({ url: 'https://services.syncfusion.com/vue/production/api/spreadsheet/save', fileName: 'Excel', saveType: 'Xlsx', }); }, saveAsCsv: function() { var spreadsheet = this.$refs.spreadsheet; spreadsheet.save({ url: 'https://services.syncfusion.com/vue/production/api/spreadsheet/save', fileName: 'Worksheet', saveType: 'Csv', }); } |
Sample link: https://stackblitz.com/edit/gvkjb9-g8pndn?file=src%2FApp.vue
Video link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Save_file_on_button_click321616841
For more information, please refer the below documentation link and API reference,
Documentation link: https://ej2.syncfusion.com/vue/documentation/spreadsheet/open-save
API reference: https://ej2.syncfusion.com/vue/documentation/api/spreadsheet/
Kindly, check the above details and get back to us for further validation.
Sorry, this actually does not help. I want the ability to download the content as excel or csv on the client, not save it to the server. I ended up using https://github.com/pratik227/vue3-json-excel
Hi Michael Cheung,
We have checked your reported query. Currently, we have done the import and export server actions in the .Net framework with C# programming only using the Syncfusion XLsIO library. While import the excel file, we will make an API call to read the Workbook of the Excel file using the XLsIO library and convert it into a JSON format and returned to our Client side to load the data into the Spreadsheet with the supported data format. Likewise, for exporting the excel file from the Spreadsheet we will make an API call to convert the data from the spreadsheet into an Excel file using the XLsIO library. And so, we are making an API call for the above-mentioned process.
Based on your provided
information, we suspect that you are expecting to save the Excel file into the
Spreadsheet without calling the server-side API as well as for opening the
file. And we
would like to let you know that currently, we don’t have support for client-side
Excel importing and exporting in spreadsheet. However, we have already
considered this as a feature, and it will be available in any of our
upcoming releases. You can track the status of this feature using below
link from our feedback portal,
Feedback Portal Link: https://www.syncfusion.com/feedback/18431/need-to-provide-support-for-client-side-importing-in-spreadsheet
Meanwhile,
currently we are working on our end to integrate SheetJS library into our Spreadsheet component for
importing and exporting on the client side. But, SheetJS offers only a
minimal range of features, like handling text, formulas, and merged cells. And SheetJS
does not provide advanced features like charts, filter, and conditional
formatting.
For more details, please see the attached video
below as a proof of concept.
Video link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Client_Import_and_Export_1-831957245
And SheetJS has so many limitations, as
mentioned above. Using the SheetJS library also, we will convert
the excel file into the supported format to load the data into the Spreadsheet
but, it does not require any server-side configuration and it will not call any
API.
So, Could you please confirm whether you expecting to open and save the Excel file within the client side itself as we mentioned above ? Based on that, we will check and provide you the further updates from our end.
Open and save the Excel file from the client side would be absolute godsend!
Hi Meelis Eesoja,
Following our recent update, we are presently integrating the SheetJS library into our Spreadsheet component. Once this integration is finalized, users will gain the capability to perform import and export actions directly on the client side, eliminating the necessity for server-side configurations or API calls. We will provide further updates here once the integration is finalized on our end.