Hello.
I'm facing a problem that I cannot solve. I'm using a SfGrid component with the "AllowResizing" set to 'true' and the width 100%, and I want to export the grid to Excel with the same column width. If I export the grid without resizing it, the Excel columns width doesn't match with the grid ones. But if I resize some column, no matter how small the change, and then export, the Excel columns width are exactly the same as the grid.
How can I fix this and always have the Excel columns width equals the grid ones?
Hi
guigulmini,
We have confirmed this an issue and logged the defect report “The
width of the Excel columns does not match the Grid width when exporting to
Excel” for the same and this fix will be included in our upcoming
patch release .
You can now
track the current status of your request, review the proposed resolution
timeline, and contact us for any further inquiries through this
link.
The
width of the Excel columns does not match the Grid width when exporting to
Excel in Blazor | Feedback Portal (syncfusion.com)
Disclaimer: “Inclusion of this solution in
the weekly release may change due to other factors including but not limited to
QA checks and works reprioritization”
We will get back to you once the release is rolled out. Until then we
appreciate your patience.
Regards,
Prathap Senthil
Okay. Thank you very much!
Based on the reported issue, we would like to inform you that according to the table behavior, when the grid column width is not set, it applies an empty column group and adjusts based on the table behavior. Currently, on our side, we have set a width of 120px for Excel columns when the width is not defined for grid columns. Therefore, we are planning to revert the code and set the default width of the Excel document for that particular cell. Is this acceptable to you?
Note: When performing column resizing, we have statically set the column group width for grid columns according to the resize so that the exported Excel reflects the column width as the grid does. However, when the grid column width is not set, the column group value is empty, so we do not know the exact width of the grid column. In this case, Excel will use the default width.
We have attached a screen recording of this behavior for your reference.
Hello.
Sure, I think it will work perfectly.
Thank you very much for the support!
Thanks for your patience,
We are glad to announce that we have included the fix for the issue discussed in our previous update in our 26.2.4 release. So please upgrade to our latest version of Syncfusion NuGet package to resolve the reported issue. Please find the NuGet package for latest fixes and features from below.
NuGet: https://www.nuget.org/packages/Syncfusion.Blazor.Grid
Root Cause: we have set static width as 120
for excel sheet.
Action Taken : If column width is null or empty or
auto, i have set default width of excel cell.
We thank you for your support and appreciate your patience in waiting for this release.
I’ve faced the same issue with SfGrid. It seems column widths in Excel don’t match the grid unless you resize a column first.
You might try triggering a column resize or re-render before exporting to ensure accurate widths. Also, check if the export settings allow you to set column widths directly.
Hope this helps!
Hi
Surah,
Regarding the issue, "The width of the Excel columns does not match the
Grid width when exporting to Excel," we have already explained the
behavior and solution in a previous conversation. Please refer to the attached
screenshot for details from that discussion.
|
|
Yes,
if you want to export with the same column width you need to define the width
of the GridColumn or use the ExcelExportProperties to customize the column
width in the column's property. Refer to the documentation below for more
information.
https://blazor.syncfusion.com/documentation/datagrid/excel-exporting#customizing-columns
Regards,
Prathap Senthil