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

Improve how igGrid exports to Excel. Maintain raw data values while applying proper formatting on Excel cells / columns #2193

Open
merjoha opened this issue May 16, 2022 · 0 comments

Comments

@merjoha
Copy link

merjoha commented May 16, 2022

On the "columns" array option of the igGrid, there are two existing properties for formatting cell data in the rendered grid... "format" and "formatter". Both work well for formatting data rendered in the grid itself, but they provide very little help when the data is exported to Excel using the &.ig.GridExcelExporter. For example, using format="currency" on a column with a number data type will yield the expected results in the grid, but when the data is exported to Excel, the raw number is sent to Excel (unformatted). Also, defining a "formatter" function yields the expected results in the grid, but the data is exported to Excel as the formatted string value, which is nice visually but aggravating if you wanted to do computations in the Excel spreadsheet with the resulting data.

My suggestion is to add a string property on igGrid column objects in columns array called "excelFormat". This would be used on columns with number and date data types primarily. Acceptable values of this excelFormat property would be valid Excel cell format codes. Then, when a grid is exported to Excel using the $.ig.GridExcelExporter, any number or date column with the excelExport property set would have it's raw number or date value in the underlying data source exported to Excel. The value provided for the excelFormat would then be applied to the cell in Excel. This way, you retain the actual data values along with the formatting you want on those values in Excel. Ideally (for performance reasons on large data sources), the formatting of the cells would take place in the exportEnding event at the column level instead of on a cell-by-cell basis in the cellExporting event.

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

No branches or pull requests

1 participant