Export excel questions

Posted by: bzhang on 10 May 2019, 3:44 am EST

    • Post Options:
    • Link

    Posted 10 May 2019, 3:44 am EST

    Hello Wijmo team,

    I am using wijmo 5 and angular 5 in our project right now.

    We are now facing a scenario that we need to support export excel for every flex grid. So, we want to develop a common function for it.

    Here is some issues we are facing.

    1. For most Grid, we use template to format what we want to show our customer, like date. Here is the code sample:

      <wj-flex-grid-column [header]=“‘Date Closed’” [binding]=“‘closedTime’” [visible]=“isNotMobile” [name]=“‘closedTime’” [isReadOnly]=“true” [align]=“‘center’” [width]=“110”>

      <ng-template wjFlexGridCellTemplate [cellType]=“‘Cell’” let-cell=“cell”>

      <div *ngIf=“cell.item.closedTime”>{{cell.item.closedTime | amUtc | amDateFormat:‘l’ }}





      My question is, how do we export the same format with in the excel as it shows on the grid?

    2. We format our dollar amount with a $ sign in front of it. Here is the code sample:

      <wj-flex-grid-column [header]=“‘Open Amt’” [binding]=“‘balance’” [visible]=“isNotMobile” [name]=“‘balance’” [isReadOnly]=“true” [width]=“110”>

      <ng-template wjFlexGridCellTemplate [cellType]=“‘Cell’” let-cell=“cell”>

      ${{cell.item.balance | number:‘1.2-6’ }}






      My question is, how do we remove the $ sign from it because our customer want to use excel’s summary function to calculate the totals.

    3. We have some columns that are using binding which required itemFormatter of the grid. As I know, if the grid is not show that column, flex grid won’t call the formatter. So, how do we export data which need itemformatter that is not showing unless you scroll to it.

    4. Some of the flex grids are using server side pagination. Which means we need to get all the records from server and export it as an excel. And some grids using in grid pagination because we know it won’t have too much data to load. We know there is a function for us to export all data in the grid. So, my question is, how do we export the data same as we export data in grid?

    Final, we want make a generic function for it. Because we have over 60 grids to add this support. We don’t want to customize for each of them. So, if you have any solution of it, please make it as generic as possible.

    By the way, my current wijmo package is C1Wijmo-Enterprise_5.20172.328.zip and angular version is 5.1.0

    Thank you.

    bzhang

  • Posted 10 May 2019, 3:51 am EST

    I forgot one question.

    We have some column that we never want to show in the excel. How do we avoid these columns?

    They are always setup as binding=‘id’ or binding=‘’.

    Here is the code sample:

    <wj-flex-grid-column [header]=“‘ID’” [binding]=“‘id’” [visible]=“false [isReadOnly]=“true”>

    <wj-flex-grid-column [header]=”‘AR’" [binding]=“‘’” [visible]=“!isNotMobile”

    [isReadOnly]=“true” [width]=“‘*’”> …

    These columns are designed for mobile version. So, we don’t want to export these columns for PC users.

    We also allow user to hidden some columns by choosing the name of the column, and we will set the visible to false. We want show that column with in the exported excel, too.

  • Posted 15 May 2019, 3:26 pm EST

    Hi,

    Sorry for the delayed response.

    By default FlexGridXlsxConverter class exports the current view of the grid i.e. currently visible data(current page and only visible columns). So if you want to export grid which is different from the current view, you need to create a clone grid and customize the clone grid to fit the export requirement. Like if you want to export all pages then remove pagination from the clone and if you want to show/hide some columns from the exported excel then set their visibility to false/true and export the clone grid.

    To customize the content of the cell during export, you could also pass an optional itemFormatter function which could be used to control what actually gets exported to the excel.

    API reference: https://www.grapecity.com/wijmo/api/interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html#formatitem

    You could create a generic function to perform these operations like in the following sample:

    https://stackblitz.com/edit/angular-faqpxm?file=src%2Fapp%2Fgrid-exporter.ts

    Regards

Need extra support?

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

Learn More

Forum Channels