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
925
Exporting to Excel - Column Width
posted

I am exporting a grid to Excel but the columns width make it unreadable.  Any way to autosize the column width withthe export?

Thanks

Scott

Parents
No Data
Reply
  • 20872
    Suggested Answer
    Offline posted

    Hello Scott,

    I am not sure but I think that there is not way to set the AutoFit style on the columns in the excel file yet. What you could do is the change the Height of the Cells in order to show the all text in the cell. One way to do that is to iterate through the columns of the Worksheet and set the WrapText property to true in the BeginExport event of the UltraGridExcelExporter like :

     private void ultraGridExcelExporter1_BeginExport(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.BeginExportEventArgs e)
            {
              for (int i = 0; i < ultraGrid1.DisplayLayout.Bands[0].Columns.Count ; i++)
                {
                     e.CurrentWorksheet.Columns[i].CellFormat.WrapText = Infragistics.Excel.ExcelDefaultableBoolean.True;
                }
            }

    Please let me know if you have any other questions on this matter.

     

Children
No Data