question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular 5 app breaks when using XLSX to export table to .xlsx file in prod build.

See original GitHub issue

I’m trying to use xlsx package for exporting files from table to .xlsx file. It works on normal build but breaks on prod build in Angular 5.

            let sheetName;
	var tbl = document.getElementById(this.activeTab);
		/* generate worksheet */
	let ws: XLSX.WorkSheet = XLSX.utils.table_to_sheet(tbl, {raw:true});

	ws['!cols'] = [
		{wpx: 200}, // "characters"
		{wpx: 200}, // "pixels"
		{wpx: 200},
		{hidden: true} // hide column
	];

		/* generate workbook and add the worksheet */
	const wb: XLSX.WorkBook = XLSX.utils.book_new();
	XLSX.utils.book_append_sheet(wb, ws, sheetName);

		/* save to file */
	XLSX.writeFile(wb, this.fileName, {type: "base64"});`

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
reviewhercommented, Jun 1, 2018

What is the error message? Can you share a sample project?

0reactions
reviewhercommented, Sep 19, 2021

Since this works with the standard new ng project setups, we can only assume the issue lies with how Angular or your specific projects work with the library in prod mode. This is unfortunately the type of issue that would require someone well-versed in Angular to diagnose.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 13 Export HTML5 Table to Excel (.XLSX) File and ...
XLSX ) File and Download it Using xlsx Library in TypeScript ... [ Building a Playlist Search App using Youtube Data Api v3] ......
Read more >
Export to Excel on Angular 5 - typescript
If you have an array you can use json_to_sheet() : import {writeFileXLSX, utils} from 'xlsx'; ///... exportToExcel(): void { const data ...
Read more >
xlsx
Most scenarios involving spreadsheets and data can be broken into 5 parts: Acquire Data: Data may be stored anywhere: local or remote files, ......
Read more >
How to Import and Export Excel XLSX Using Angular
Learn how to import and export Excel XLSX files using Angular. See more from SpreadJS today.
Read more >
Save a workbook to text format (.txt or .csv)
Sometimes, you might need to save a workbook in another file format, like a text (txt) or a comma-separated values format (csv). Just...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found