How to export flex sheet without hidden rows and columns using angular 6

Posted by: srijini.t on 27 September 2019, 5:58 am EST

    • Post Options:
    • Link

    Posted 27 September 2019, 5:58 am EST

    how to export flex sheet without hidden rows and columns using angular 6.

  • Posted 30 September 2019, 12:08 am EST

    Hi,

    This is the default behavior of the FlexSheet. If there are hidden rows or columns, they will not be exported to the excel. You may verify the same using the sample below:

    https://stackblitz.com/edit/angular-edaglv

    In this sample, the 3rd row and the 3rd column are hidden, so they will not be exported.

    Regards,

    Ashwin

  • Posted 30 September 2019, 1:54 am EST

    Hi,

    In the Above Example we can see the hidden row and column in the exported file when we dragged the column and row headers.

    we want also delete the data (row and column) when exporting.

    Regards,

    Teenu

  • Posted 1 October 2019, 2:35 am EST

    Hi,

    We are sorry for the inconvenience caused.

    To do not export the hidden rows, before saving the FlexSheet to xlsx, you may create a Workbook instance and iterate over each row. If the current row is not visible, then you may remove this row. Please refer to the code snippet below:

    let wb = sheet.saveAsync(), activeSheet = wb.sheets[wb.activeWorksheet];
        for(let i = activeSheet.rows.length - 1; i >= 0; i--) {
          let row = activeSheet.rows[i];
          if(!row.visible) {
            activeSheet.rows.splice(i, 1);
          }
        }
        wb.saveAsync('FlexSheet.xlsx');
    

    The procedure to not export the hidden columns cannot be achieved using the above behavior. You will need to create an instance of FlexGrid with only those columns which you need to export, and then use the addBoundSheet method to add a Sheet to the FlexSheet. Please refer to the code snippet below:

    let grid = new wjcGrid.FlexGrid(wjcCore.createElement(`<div></div>`), {
          autoGenerateColumns: false,
          itemsSource: this.source,
          columns: [
            { binding: 'id', header: 'ID'},
            { binding: 'country', header: 'Country'},
            { binding: 'downloads', header: 'Downloads'},
            { binding: 'checked', header: 'Checked'},
          ]
        })
        formatSheet.addBoundSheet('Data', this.source, null, grid);
    

    You may also refer to the sample below:

    https://stackblitz.com/edit/angular-3pwqz7

    ~regards

  • Posted 1 October 2019, 3:22 am EST

    thanks for your reply.:grinning:

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels