Skip to content

Export Table as Excel File / PDF  #168

Open

Description

@ahmedhamza47

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!

Activity

  1. himanshu0911 commented on Feb 11, 2024

    @himanshu0911

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

  2. ahmedhamza47 commented on Feb 11, 2024

    @ahmedhamza47
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions