jecovier / vue-json-excel

MIT License
685 stars 167 forks source link

Export multiple sheet per excel file #57

Open Julien76 opened 6 years ago

Julien76 commented 6 years ago

Hi, Is there any way to export multiple sheet page in Excel?

Or is there a possible to stack data one after the other in the same page, with each its field and data? Like an nested array for field and data will yield exported stacked on top of each other?

Thanks in advance,

Regards,

Julien

jecovier commented 5 years ago

Hello @Julien76 sorry for the late response,

I think is posible with xls files, maybe add a extra layer to the data so every first level items represents a excel sheet and in css file just stack the data (?). I don't know, let me think about it.

ljm42 commented 5 years ago

I think the simplest solution would be to switch to the "XML Spreadsheet 2003" format, described here: https://en.wikipedia.org/wiki/Microsoft_Office_XML_formats Here is a basic script that creates in that format: https://www.sencha.com/forum/showthread.php?309246-Exporting-Excel-with-Multiple-worksheets The XML format is not that different from the HTML that we have now.

The main downside is that it does NOT solve the problem of Excel complaining that the "file format and extension don't match" (unless we change the file extension to .xml)

I believe the only way around that is to switch to the full .xlsx format, but it is quite a bit more complex...

This library appears to be full-featured: https://github.com/SheetJS/js-xlsx But it is heavy! The minimized core file is 466kb, much too large for what we are trying to do in my opinion. https://github.com/SheetJS/js-xlsx/blob/master/dist/xlsx.core.min.js

This is the simplest alternative I can find: https://github.com/jsegarra1971/MyExcel But it still requires jszip, which is 350kb on its own.

I'd vote for the "XML Spreadsheet 2003" format because it allows this project to export multiple sheets in a single file while keeping the project small and simple.

Julien76 commented 5 years ago

Hello @Julien76 sorry for the late response,

I think is posible with xls files, maybe add a extra layer to the data so every first level items represents a excel sheet and in css file just stack the data (?). I don't know, let me think about it.

Hi,

Thanks for your answer. I moved away from vue-json-excel for this particular problem (but I still use it where I only to export one set of data, and it works great). I use js-xlsx to export multiple sheets. It is heavy as mentioned in the post above, but as it's wrapped in an electron app, it does not matter too much for my problem. I' struggling with time to explore your idea. When I found time, I will have a look. Thanks again.

AlenaR7 commented 4 years ago

Hello @jecovier!

I add a extra layer to the data, but it did not help.

Сode example:

json_fields1: { 'asd': { 'Complete name': 'name', 'City': 'city', 'Telephone': 'phone.mobile', 'Telephone 2' : { field: 'phone.landline', callback: (value) => { return Landline Phone - ${value}; } }, }, 'cbg': { 'Complete name': 'name', 'City': 'city', 'Telephone': 'phone.mobile', 'Telephone 2' : { field: 'phone.landline', callback: (value) => { return Landline Phone - ${value}; } }, }, }, json_data1: { 'asd' : [ { 'name': 'Tony Peña', 'city': 'New York', 'country': 'United States', 'birthdate': '1978-03-15', 'phone': { 'mobile': '1-541-754-3010', 'landline': '(541) 754-3010' } }, { 'name': 'Thessaloniki', 'city': 'Athens', 'country': 'Greece', 'birthdate': '1987-11-23', 'phone': { 'mobile': '+1 855 275 5071', 'landline': '(2741) 2621-244' } } ], "cbg" : [ { 'name': '1111', 'city': 'New York', 'country': 'United States', 'birthdate': '1978-03-15', 'phone': { 'mobile': '1-541-754-3010', 'landline': '(541) 754-3010' } }, { 'name': '11112', 'city': 'Athens', 'country': 'Greece', 'birthdate': '1987-11-23', 'phone': { 'mobile': '+1 855 275 5071', 'landline': '(2741) 2621-244' } } ], },

An error is issued: " [Vue warn]: Invalid prop: type check failed for prop "data". Expected Array, got Object "

Maybe there is still some possibility of creating tables on several excel sheets?

Thank you in advance for your response

1ucas-eng commented 3 years ago

Hello @jecovier, So, is there any way for creating the excel file with several sheets?

6000850 commented 2 years ago

Hello @jecovier, So, is there any way for creating the excel file with several sheets?

Hi . Did you find a way to make multiple sheets?