Hello
I am struggling to get my column headers to repeat in the excel export, following updating from one version to another.
Previous version: Infragistics2.Win.UltraWinGrid.v8.2 (8.2.20082.2022)
Now using version: Infragistics2.Win.UltraWinGrid.v12.1 (12.1.20121.1001)
With the previous version, when exporting to excel with 1 or more grouped columns, the headers would appear at the top of each set of grouped data, rather than just once, at the top of the sheet. After upgrading to the version I'm on now, this functionality has disappeared, and I now only see the column headers once at the top of the sheet. This is without me changing anything.
I have made sure that the ViewStyle of the export is set to MultiBand, and that ViewStyleBand property is set to OutlookGroupBy. Also, the HeaderPlacement property of the export object is set to RepeatOnBreak. Although, changing this to any of the other options makes no difference.
To clarify where I am doing this, I am handling the ExportStarted event of the Export object and using:
e.Layout.ViewStyle = ViewStyle.MultiBand e.Layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy e.Layout.Override.HeaderPlacement = HeaderPlacement.RepeatOnBreak
Maybe I am missing something obvious, or if not, let me know if you need me to send further details.
Thanks in advance.
Hi,
I'm just checking on the status of this issue. Have you had the chance to run my sample and see if you get the sample results?
Hi Mike
Thank you for your assistance.
With my scenario, I need the grid to show the column headers just once, at the top, as it does now. However, it is only the export to excel where I need the headers to be grouped. This is really what has confused me when comparing the previous version to my current version. With my code as it was before updating, the export was grouping the headers as I required, despite the source grid showing the headers just once at the top. After updating the controls, both are now showing headers once at the top.
I think I will check that I have the very latest version as you suggested, but if no luck, perhaps I could try changing the grid, rather than trying to intercept the export and changing the properties of that. Maybe if I change the state of the grid just before the export, and then revert it once the export has finished, this may give me what I need.
Thanks
Andrew
Hi Mike,
Well... if you are not using GroupBy, then the child bands export the headers under each parent by default. You don't even HAVE to set HeaderPlacement.
I tried this out just to make sure and it's working fine for me without setting HeaderPlacement at all.
I'm attaching my sample here so you can take a look.
Hey Mike,
What I meant was, I cannot get the headers to repeat regardless of the HeaderPlacement settings in my application. It did work correctly in your sample. I just realized now however that I didn't look closely enough at your sample code -- I didn't notice you were using GroupBy.
The difference in my application is that I am trying to export a multi-banded grid, where the first band has parent data and second band has child data. In the grid, I have a row for each parent, and can expand each parent row to view its corresponding child row(s), and the child band's column headings in the grid are repeated for each parent row. But when I export, the child band's header columns are only visible under the first row of parent data. Would I need to use some different settings for the layout in this case, or is what I am looking to do not supported?
If my description is unclear I can provide a sample application. Thanks for your help.
I'm a little confused. In your latest reply you are saying that you cannot get the headers to repeat regardless of the headerPlacement settings, but you said my sample worked when you tried it on your machine. So my sample works but it just doesn't work in your application?
Is there anything obviously different about my sample and your application? My sample is using GroupBy to group the rows, so the headers will repeat for each group. If you are not grouping, then of course the headers will not repeat for every row in the grid.
If you are using OutlookGroupBy to group the rows and setting HeaderPlacement to RepeatOnBreak, then it should work, and there's no other setting I can think of that could possibly affect it.
If you can you reproduce the problem in a small sample project and post it here, I would be happy to check it out and see what's wrong.
I am running the exporter against different grids with various settings, but so far haven't been able to get any of my multi-banded grids to repeat headers in the spreadsheet.
I've tried using the following code:
Private Sub excelExportStarted(ByVal sender As Object, ByVal e As ExcelExport.ExportStartedEventArgs) Handles UltraGridExcelExporter1.ExportStarted
e.Layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy
e.Layout.Override.HeaderPlacement = HeaderPlacement.RepeatOnBreak
End Sub
I put a breakpoint on the HeaderPlacement line. In most cases, the placement comes in as "default". I've tried changing it to each of the various settings (RepeatOnBreak, OncePerRowIsland, etc.). The behavior I see in Excel is that the headers for the second band appear above the first row only, regardless of the HeaderPlacement I choose (unless I use FixedOnTop -- in which case I do see them as FixedOnTop).
My understanding is that the export should use whatever I set in the cloned layout property in the ExportStarted event, but it just doesn't seem to be working, which is why I was thinking there must be some other property being set elsewhere in my code that's interfering.
I can't think of any other properties that would effect this.
In theory, you could write a ton of code in the events of the UltraGridExcelExporter to control exactly where the headers are exported, but it would be a tremendously complex undertaking and you would surely be aware of it if you were doing that.
Are you certain that your HeaderPlacement setting isn't be overriden or overwritten somewhere else in your code? Are you loading a layout into your grid that might be blowing away the setting you applied in code? Try checking the HeaderPlacement property at run-time to make sure it's still set to what you think it is.