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

Set Column Width and Row Height with ExcelML format

Columns Width

You can set the columns with by using the ExcelTableCreated event. This event allows you to access the the column attributes and set the columns width.

private void Exporter_ExcelTableCreated(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelTableCreatedEventArgs e)
{
    foreach (ColumnElement item in e.ExcelTableElement.Columns)
    {
        item.Attributes["ss:Width"] = "300";
    }
}

Private Sub Exporter_ExcelTableCreated1(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.Export.ExcelML.ExcelTableCreatedEventArgs)
    For Each item As ColumnElement In e.ExcelTableElement.Columns
        item.Attributes("ss:Width") = "300"
    Next item
End Sub

Rows Height

You can set the rows height by using the ExcelRowFormating event. This event allows you to access the the row attributes and set the height.

private void Exporter_ExcelRowFormatting(object sender, ExcelRowFormattingEventArgs e)
{
    if (e.ExcelRowElement.Attributes.Contains("ss:Height"))
    {
        var att = e.ExcelRowElement.Attributes["ss:Height"];
        if (Convert.ToInt32(att) > 400)
        {
            e.ExcelRowElement.Attributes["ss:Height"] = "400";
        }
    }
}

Private Sub Exporter_ExcelRowFormatting(ByVal sender As Object, ByVal e As ExcelRowFormattingEventArgs)
    If e.ExcelRowElement.Attributes.Contains("ss:Height") Then
        Dim att = e.ExcelRowElement.Attributes("ss:Height")
        If Convert.ToInt32(att) > 400 Then
            e.ExcelRowElement.Attributes("ss:Height") = "400"
        End If
    End If
End Sub

In this article