Hi folks,
my first question would be the following. I am trying to Export a Webgrid which is design with multi column headers. Each time the export works fine except the mutli cloumn header wich i added in the webgrid's UWG_InitializeLayout Method the following way.
In the Browser it works fine. But after Export it is invisible.
Dim ch As New Infragistics.WebUI.UltraWebGrid.ColumnHeader(True) ch.Caption = "Employee's Name" ' set the origin to be on the top most level of the header ch.RowLayoutColumnInfo.OriginY = 0 ' extend the newly added header over 3 columns ch.RowLayoutColumnInfo.SpanX = 20 ' add the header into the header layout e.Layout.Bands(0).HeaderLayout.Add(ch)
The current version of the Excel Exporter doesn't support exporting multi-row headers. Unfortunate, I know. But you can manually add the headers to the Excel sheet during the export by using the e.CurrentWorksheet.MergedCellsRegions.Add method in the BeginExport event.
That also means you'll need to come up with some way of saving the info in the multi-row headers. Once you add a header row by using the code you posted, you won't be able to look up that same information during the BeginExport event. You'll have to save that header info in a custom object or some other store and move it to the export event yourself.
Hope that helps,
Mike
But how do you *add* a new header row during the export?
Hello Just wanted to check if any body got a solution to this.
hi,
We also need a similar solution...to export multi column headers in Excel and PDF? Any answer you found?
Appreciate it!
Thx!
Sure, I got it work by doing following Steps:
1) Add the Column as a new Grid Row in begin Export method.
2) In HeaderCellExporting event, you will get the Sub Column, Change the export to write our main Column headers.
3) In RowExporting event, merge the Header Columns to have Sub-Columns.
What I did is I added all the events to the excel Exporter to track the Export progess.
excelExporter1.RowExporting +=
In begin Export:
{
newRow.Cells.Add(
}
e.CurrentWorksheet.PrintOptions.Header =
e.CurrentWorksheet.PrintOptions.PaperSize =
//Header Export
e.HeaderText
//Merge the Header Cells
Infragistics.Excel.
childCell = cells.Where(i => i.Value.ToString() == cells[cnt].Value.ToString()).LastOrDefault();
e.CurrentWorksheet.MergedCellsRegions.Add(0, cnt, 0, childCell.ColumnIndex);
cnt = childCell.ColumnIndex;
e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex].ClearComment();
Let me know if you need any further help.
Excellent stuff manish. Thanks a lot for ur code.
Has this been fixed in any of the recent versions? I'm using V12.2 SR2075. I would rather not add all that extra code if this has been fixed.
Thanks.