I am using RadGridView's ExportToXlsx. I have been able to provide some styling (background colors and cell borders) in the ElementExportingToDocument event. But I don't see a way to increase the row height and column width. Is there a way to do this?
Dilyan Traykov
Telerik team
commented on 09 May 2022, 08:11 AM
Hello Carol,
To be able to control the row height and column width, you need to use the ExportToWorkbook method instead of the ExportToXlsx one and then modify the exported workbook. Here's an example of how to set a different default height/width:
Workbook workbook = this.clubsGrid.ExportToWorkbook(
new GridViewDocumentExportOptions()
{
ShowColumnFooters = true,
ShowColumnHeaders = true,
ShowGroupFooters = true
});
(workbook.ActiveSheet as Worksheet).DefaultRowHeight = new RowHeight(40, true);
(workbook.ActiveSheet as Worksheet).DefaultColumnWidth = new ColumnWidth(100, true);
Alternatively, you can iterate over the rows/columns and set a custom size for each one.
Hello Carol,
To be able to control the row height and column width, you need to use the ExportToWorkbook method instead of the ExportToXlsx one and then modify the exported workbook. Here's an example of how to set a different default height/width:
Workbook workbook = this.clubsGrid.ExportToWorkbook( new GridViewDocumentExportOptions() { ShowColumnFooters = true, ShowColumnHeaders = true, ShowGroupFooters = true }); (workbook.ActiveSheet as Worksheet).DefaultRowHeight = new RowHeight(40, true); (workbook.ActiveSheet as Worksheet).DefaultColumnWidth = new ColumnWidth(100, true);
Alternatively, you can iterate over the rows/columns and set a custom size for each one.