Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
545
WebExcelExporter: set column width
posted

Hallo,

i'm setting column width of my grid during export:

Private Sub m_exporter_GridFieldCaptionExporting(sender As Object, e As Infragistics.Web.UI.GridControls.GridFieldCaptionExportingEventArgs) Handles m_exporter.GridFieldCaptionExporting
If (e.GridCell.OwnerField.GetType() Is GetType(TemplateDataField)) Then
Dim col As Infragistics.Documents.Excel.WorksheetColumn

col = e.Worksheet.Columns(e.WorksheetCell.ColumnIndex)
col.SetWidth(50, Infragistics.Documents.Excel.WorksheetColumnWidthUnit.Pixel)
End If
End Sub 

but it doesn'work. Why?

I'm using version 2011.1 (last release).

Thanks

  • 325
    posted

    Got this to work in version 2012.1...

    Width is defined as

    Public Property Width() As Integer
    Member of Infragistics.Documents.Excel.WorksheetColumn
    Summary:
    Gets or sets the column width including padding, in 256ths of the '0' digit character width in the workbook's default font.

     

    Protected Sub weeExportGrid_Exported(ByVal sender As Object, ByVal e As Infragistics.Web.UI.GridControls.ExcelExportedEventArgs) Handles weeExportGrid.Exported

    e.Worksheet.Columns.Item(0).Width = 256 * 7
    e.Worksheet.Columns.Item(1).Width = 256 * 11

    e.Worksheet.Rows(0).Height = 1075

    End Sub

    A width of 256 * 7 will be approximately 6.29 pixels

  • 8736
    Verified Answer
    posted

    Hello,

    I was able to set the exported TemplateDataField width based on the code you have provided. I have attached a sample for you to review.

    Run the sample and test. The sample is created as a website. Use version utility if you are using other version of NetAdvantage product.  If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. I have tested this sample using NetAdvantage 11.1.20111.2238, IE 9, and Visual Studio 2010.

    If this sample does not demonstrates the functionality you described, feel free to modify it and send it back that demonstrates the behavior you mentioned with relevant dependencies.

    I hope this helps.

    WebDataGrid_Export.zip