Is there a way to control row height and column width using ExportToXlsx on RadGridView?

0 Answers 105 Views
GridView
Carol
Top achievements
Rank 1
Carol asked on 04 May 2022, 10:18 PM
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.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Carol
Top achievements
Rank 1
Share this question
or