Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Table as Excel File / PDF #168

Open
ahmedhamza47 opened this issue Dec 11, 2023 · 2 comments
Open

Export Table as Excel File / PDF #168

ahmedhamza47 opened this issue Dec 11, 2023 · 2 comments

Comments

@ahmedhamza47
Copy link

Hello I would like to export the table as excel file or as pdf. But I am not being able to do it. Can anyone help me with this issue. It would be really helpful!

@himanshu0911
Copy link

I am also looking for the same as well. But not found how to do that

@ahmedhamza47
Copy link
Author

There is no inbuilt method to export data as excel file

const exportReport = () => {
const pvtTable = document.getElementsByClassName('pvtTable');
const worksheet: XLSX.WorkSheet = XLSX.utils.table_to_sheet(pvtTable[0]);
const workbook: XLSX.WorkBook = {
Sheets: { data: worksheet },
SheetNames: ['data'],
};
const excelBuffer = XLSX.write(workbook, {
bookType: 'xlsx',
type: 'array',
});

const data: Blob = new Blob([excelBuffer], {
    type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8',
});
FileSaver.saveAs(data, 'ExcelReport.xlsx');

}

create a button and onClick call this function .
Make sure to install necessary package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants