简体   繁体   中英

How to write excel file with chart using js-xlsx

Using SheetJS js-xlsx "xlsx": "0.15.1" js is there a way to write excel file with chart.

Basically I want to export html page that contains chart into an excel file.

HTML page is getting exported successfully but the chart in the page is not getting displayed.

Here is the code I have used

let wb =XLSX.utils.book_new();

 let element: any = document.getElementById('page1');
 let ws = XLSX.utils.table_to_sheet(element);
 XLSX.utils.book_append_sheet(wb,ws,'page1');

Are you using the Community build or the Pro?

As stated here , The Community build reflects the data cached in charts as worksheets. Other chart-related features, including writing and reading metadata, are included in the Pro compendium .

Remember to include your work as Chartsheet , just in case. It will continue to render it as a Worksheet if you are using the community version, but it will help us to understand the desired behavior that you are seeking.

If you provide more reference for the code, maybe we can show you some shortcuts to make it work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM