Exporting an excel file using ExcelJS has been a challenge for me.
When I checked my console in the VS Code terminal, I encountered the following errors:
ERROR in node_modules/exceljs/index.d.ts:1398:22 - error TS2307: Cannot find module 'stream'.
1398 read(stream: import('stream').Stream): Promise<Workbook>;
~~~~~~~~
node_modules/exceljs/index.d.ts:1424:23 - error TS2307: Cannot find module 'stream'.
...
Here is the content of app.component.html:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
...
</body>
</html>
And here is the code from app.component.ts:
import { Component } from '@angular/core';
import * as Excel from 'exceljs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'resttest10';
async downloadExcel() {
// Code for exporting excel
}
}
I'm puzzled by the fact that it's looking for the stream module (and even more oddly - "Cannot find namespace 'NodeJS'" - despite being able to run other Angular NodeJS projects without issues).
If anyone could shed some light on why I can't export the excel file successfully, I would greatly appreciate it.