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
150
Wrapping in Column Headers on exported grid
posted

Hello,

I am having some problems getting the column headers on an exported UltraWebGrid to be multiple lines high and wrap as needed.

Here is what I am doing:

I have multiple data tables of data to be exported onto one worksheet. To accomplish hits, I first create a new Workbook and Worksheet object. Then, for each data table, I am binding the data table to an UltraWebGrid that is on the form and is set to auto generate columns. I then call the Export method of an UltraWebGridExcelExporter specifying a row for it to export to as well as the grid to export and the sheet that I created earlier. I then repeat this process using the same grid for each data table.  Once all of the data tables have been exported, I stream the Excel workbook out to the browser using the Save method of the Workbook, passing it the Page’s OutputStream. Other than the header heights, this is working beautifully.

A few other things that I am doing, in case it matters, are:

  • I am setting the column width of each Column in the Worksheet to a defined width. This is done after all of the data tables have been exported to keep the auto-sizing routines with the exporter or grid from overriding my defined widths.
  • I am using the DataBound event of the grid to set the colors of specific cells based on their column and value.

Things I have tried:

  • setting the header size in the grid tag on the .ascx page using 
    <HeaderStyleDefault  Height="64" Wrap="true" Font-Bold="true">
  • using the HeaderRowExporting event of the grid and setting
    e.Band.HeaderStyle.Wrap = true and e.Band.HeaderStyle.Height = 64
  • Setting the style of the header from the Grids DataBound event via the col.Header.Style.Height and col.Header.Style.Wrap properties of each column in the grid.

How can I get the header cells in the exported file to be taller and to word wrap?

Thanks
Glenn

Parents
No Data
Reply
  • 150
    Verified Answer
    posted

    Ok, I did finally get this to work, just not as "cleanly" as I had hoped. After I call the Export command of the UltraWebGridExcelExporter, I run the following lines:

    sheet.Rows[currentRow].Height = 602;
    sheet.Rows[currentRow].CellFormat.WrapText = ExcelDefaultableBoolean.True;

    This sets the height and wrapping of the curent row, which is where I exported to, so it is the "header" row. Remember that Excel sets the height in Twips, so that is 602 twips, or about a value of 30 as seen in Excel.

    Hope this helps someone...

    Glenn

Children