Hi,
I'm making some progress formatting the header row of my Excel export, but I'd really like to have the columns automatically adjust to fit the width of the content.
Here's my OnInfrastructureExporting event handler:
protected void grdControls_InfrastructureExporting(object sender, GridInfrastructureExportingEventArgs e)
{
var colCount = e.ExportStructure.Tables[0].Columns.Count;
// Set the header style for all columns
ExportStyle headerStyle = new ExportStyle();
headerStyle.ForeColor = Color.White;
headerStyle.BackColor = Color.Blue;
headerStyle.Font.Bold = true;
for (var i = 1; i <= colCount; i++)
{
e.ExportStructure.Tables[0].Cells[i, 1].Style = headerStyle;
e.ExportStructure.Tables[0].Columns[i].Width = 200; // Would like auto-width !!
}
}
I've seen similar threads but they are related to export formats other than Xlsx.
Any idea how I can accomplish auto-fit using the above handler? Or do I need to do that elsewhere?
Thanks for any advice.
Jim