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

Setting custom excelExportOptions.filename is not working for excelExport #655

Closed
chitwank-asu opened this issue Dec 18, 2020 · 4 comments · Fixed by #661
Closed

Setting custom excelExportOptions.filename is not working for excelExport #655

chitwank-asu opened this issue Dec 18, 2020 · 4 comments · Fixed by #661
Labels

Comments

@chitwank-asu
Copy link

chitwank-asu commented Dec 18, 2020

I'm submitting a Bug report

Your Environment

Software Version(s)
Angular 11.0.4
Angular-Slickgrid 2.24.1
TypeScript 4.0.2

Describe the Bug

Steps to Reproduce

  1. set gridoptions.excelExportOptions.filename = 'customName';;
 this.gridOptions = {
      enableAutoResize: true,
      enableExcelExport: true,
      excelExportOptions: {
        filename: 'PurchaseOrders',
        exportWithFormatter: true
      }, ....
}
  1. Click on the default export to excel from context menu, downloaded file name still showing 'export'
  2. Same thing, when we click on Export to excel from the hamburger menu, downloaded file name still showing 'export'

Expected Behavior

When we set custom filename in excelExportOptions, and click on Export to excel from context menu or hamburger menu, the downloaded file name should be the custom name that is being set.

Current Behavior

  1. Clicking on the default export to excel from context menu, downloaded file name still showing 'export'
  2. Same thing, when we click on Export to excel from the hamburger menu, downloaded file name still showing 'export'

Possible Solution

It seems to be happening because there is a hardcoded file name as export , (where as it should be picking the name from exportoptions is it is set there by the user)in angular-sclickgrid.js file file in executeGridMenuInternalCustomCommands() method for below:

  case 'export-excel':
                    this.excelExportService.exportToExcel({
                        **filename: 'export',**
                        format: FileType.xlsx,
                    });

and also is there for the context menu click method too:

  // show context menu: Export to Excel
        if (gridOptions && gridOptions.enableExcelExport && contextMenu && !contextMenu.hideExportExcelCommand) {
            const commandName = 'export-excel';
            if (!originalCustomItems.find((item) => item.hasOwnProperty('command') && item.command === commandName)) {
                menuCustomItems.push({
                    iconCssClass: contextMenu.iconExportExcelCommand || 'fa fa-file-excel-o text-success',
                    title: this.extensionUtility.translateWhenEnabledAndServiceExist(`${translationPrefix}EXPORT_TO_EXCEL`, 'TEXT_EXPORT_TO_EXCEL'),
                    disabled: false,
                    command: commandName,
                    positionOrder: 52,
                    action: () => this.excelExportService.exportToExcel({
                        **filename: 'export',**
                        format: FileType.xlsx,
                    }),
                });
            }

Code Sample

this.gridOptions = {
      enableAutoResize: true,
      enableExcelExport: true,
      excelExportOptions: {
        filename: 'PurchaseOrders',
        exportWithFormatter: true
      },
      datasetIdPropertyName: 'Id',
      autoResize: {
        containerId: 'demo-container',
        sidePadding: 10
      },
      enableFiltering: true,
      enableCheckboxSelector: true,
      checkboxSelector: {
        hideInFilterHeaderRow: false,
        hideInColumnTitleRow: true
      },
      enableRowSelection: true,
      pagination: {
        pageSizes: [10, 15, 20, 25, 30, 40, 50, 75, 100],
        pageSize: defaultPageSize,
        totalItems: 0
      },
      presets: {
        pagination: { pageNumber: 1, pageSize: 20 }
      },
      backendServiceApi: {
        service: new GridOdataService(),
        options: {
          enableCount: this.isCountEnabled,
          version: this.odataVersion
        } as OdataOption,
        preProcess: () => this.displaySpinner(true),
        process: (query) => this.getPurchaseOrderApiCall(query),
        postProcess: (response) => {
          this.displaySpinner(false);
          this.getPurchaseOrderCallback(response);
        }
      }
    };
  }
@ghiscoding
Copy link
Owner

it is indeed a bug, will look at it after the holidays, however I fixed it in my other lib in the referenced PR
If you want to help and create a PR here, that would be great, nonetheless it will be merged/released on in January ;)

@chitwank-asu
Copy link
Author

Thank you. I will try but I am on holidays too at the moment.
Compliments of the Season and Happy New Year to you :)

@ghiscoding
Copy link
Owner

This is now fixed and released in the new version 2.25.0, see Release Note.

Cheers ⭐

@chitwank-asu
Copy link
Author

Thank you so much!

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

Successfully merging a pull request may close this issue.

2 participants