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

Row Detail View adding extra rows in excel export #390

Closed
RasmusBergHogia opened this issue Jun 22, 2021 · 5 comments · Fixed by #392
Closed

Row Detail View adding extra rows in excel export #390

RasmusBergHogia opened this issue Jun 22, 2021 · 5 comments · Fixed by #392
Labels
enhancement New feature or request

Comments

@RasmusBergHogia
Copy link

RasmusBergHogia commented Jun 22, 2021

I'm submitting a Bug report

Your Environment

Software Version(s)
Slickgrid-Universal 0.14.1
Slickgrid-Universal Excel-Export 0.14.1
TypeScript 4.3.4
Aurelia-Slickgrid 3.7.1

I have test this on Aurelia Slickgrid source code with adding Slickgrid-Universal Excel-Export on example 19.

Added to options:

enableExcelExport: true,
excelExportOptions: {
  format: FileType.xlsx
},
registerExternalResources: [new ExcelExportService()]

Describe the Bug

If you expand row details view and then export to excel, you get extra rows in excel document.

Steps to Reproduce

  1. Add both Excel Export and Row Details View to a grid.
  2. Expand one or more rows details views.
  3. Click export to excel in menu.

Expected Behavior

You get original (filtered) rows in excel only.

Current Behavior

You get the hidden extra rows which is add for row details views in the excel file.

Screenshot_229

Rows added (visible by I hide row details view):
Screenshot_230

Result in excel:
Screenshot_228

Possible Solution

For some reason the extra rows has what I think empty dataview inside of them:
Screenshot_231

So one solution could be that ignore items with getItem in them in method pushAllGridRowDataToArray of excelExport.service.ts

private pushAllGridRowDataToArray(originalDaraArray: Array<string[] | ExcelCellFormat[]>, columns: Column[]): Array<string[] | ExcelCellFormat[]> {
  const lineCount = this._dataView.getLength();

  // loop through all the grid rows of data
  for (let rowNumber = 0; rowNumber < lineCount; rowNumber++) {
    const itemObj = this._dataView.getItem(rowNumber);
    if (itemObj && itemObj.getItem === undefined) {
      // Normal row (not grouped by anything) would have an ID which was predefined in the Grid Columns definition
      if (itemObj[this._datasetIdPropName] !== null && itemObj[this._datasetIdPropName] !== undefined) {
        // get regular row item data
        originalDaraArray.push(this.readRegularRowData(columns, rowNumber, itemObj));
       } else if (this._hasGroupedItems && itemObj.__groupTotals === undefined) {
        // get the group row
        originalDaraArray.push([this.readGroupedRowTitle(itemObj)]);
      } else if (itemObj.__groupTotals) {
        // else if the row is a Group By and we have agreggators, then a property of '__groupTotals' would exist under that object
        originalDaraArray.push(this.readGroupedTotalRows(columns, itemObj));
      }
    }
  }
  return originalDaraArray;
}
@ghiscoding
Copy link
Owner

ghiscoding commented Jun 22, 2021

@RasmusBergHogia
yeah what you see in your export is actually normal, there isn't much we can do with that (I also see similar behaviors even in other paid lib like syncfusion grid) and it was also discussed in Angular-Slickgrid in this discussion thread but I'm still waiting for any code to be provided.

Your suggestion to skip these lines might be the only good solution, would you like to provide a PR (Pull Request)?

BTW, the Row Detail plugin is actually how it works, you can provide a custom panelRows number which will tell the plugin how many rows from the grid we will use. When you open the row detail, you just push the other rows down but in the back they are still just regular rows. The plugin just shows something else on top of these regular rows, so it looks like a row detail panel but in reality it's nothing more than an accumulation of regular rows which we paint something different on top of them.

@RasmusBergHogia
Copy link
Author

@ghiscoding I could make a PR on that, but not today for have some other work to be done first.

@ghiscoding
Copy link
Owner

ghiscoding commented Jun 22, 2021

sure thake your time, that'd be really great to get contributions, it's always welcome 😉

@ghiscoding
Copy link
Owner

ghiscoding commented Jun 23, 2021

@RasmusBergHogia
I want to push a new release version within the next couple days and so I made the PR with your suggestion, you can take a look at PR #392

AnnetteZhang added a commit that referenced this issue Jun 24, 2021
…tail

fix(export): expanded Row Detail shouldn't be exported, fixes #390
@ghiscoding
Copy link
Owner

@RasmusBergHogia
It took me longer than expected but it's finally out for both Slickgrid-Universal and Aurelia-Slickgrid. This new version had a lot of internal changes which took longer and you can see all changes under each respective repo

Always remember to update both side at the same time.

Cheers and thanks for the feedback
Happy Coding! ⭐ 😄

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

Successfully merging a pull request may close this issue.

2 participants