New to Telerik UI for WinForms? Download free 30-day trial

SpreadExportRenderer

The SpreadExportRenderer class gives you access to the exported document and provides you with the ability to change it before it is saved.

The SpreadExportRenderer API gives you the ability to manipulate the document. The most important part is the WorkbookCreated event. This event is triggered on the SpreadExportRenderer object when the workbook is ready to be exported. Allows to introduce final customizations (for example you can add header and footer). More information on how to work with Workbook is available here: Working with Workbooks.

The following example shows how you can subscribe to the event and use it to best fit the columns in the file:


SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
exportRenderer.WorkbookCreated += exportRenderer_WorkbookCreated;

Dim exportRenderer As New SpreadExportRenderer()
AddHandler exportRenderer.WorkbookCreated, AddressOf exportRenderer_WorkbookCreated

void exportRenderer_WorkbookCreated(object sender, WorkbookCreatedEventArgs e)
{
    Worksheet worksheet = (Worksheet)e.Workbook.Sheets[0];
    worksheet.Columns[worksheet.UsedCellRange].AutoFitWidth();
}

Private Sub exportRenderer_WorkbookCreated(ByVal sender As Object, ByVal e As WorkbookCreatedEventArgs)
    Dim worksheet As Worksheet = CType(e.Workbook.Sheets(0), Worksheet)
    worksheet.Columns(worksheet.UsedCellRange).AutoFitWidth()
End Sub

tpf-export-data-support-spread-export-renderer 001

See Also

In this article