'Not able to import xlsx
I am trying to add a function to export xlsx. Though I am able to export CSV and pdf but xlsx is having issues while dynamic import
export const exportToXlsx = async (
gridElement: ReactElement,
fileName: string
) => {
const [{ utils, writeFile }, { head, body, foot }] = await Promise.all([
import('xlsx'),
getGridContent(gridElement),
]);
const wb = utils.book_new();
const ws = utils.aoa_to_sheet([...head, ...body, ...foot]);
utils.book_append_sheet(wb, ws, 'Sheet 1');
writeFile(wb, fileName);
}
Cannot find module 'xlsx' or its corresponding type declarations.ts(2307)
above is the code and error
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
