Hi
I am using Infragistics4.Documents.Excel.v19.1
I have a table with two bands.
I want to insert some blank columns in the child band in order to better align child information.
Child band real column list is:
C1 (hidden), C2 (hidden), C3, C4, C5, C6, C7
What I want to achieve (into the Excel file) is:
Blank, Blank, Blank, Blank, Blank, Blank, C3, Blank, Blank, Blank, C4, C5, C6, C7
I handled the ExportStarted event and added the needed empty columns but the results are not as expected.
I used e.Layout.Bands[1].Columns.Insert(3, "EmptyX") to insert 3 empty columns between C3 and C4 and then e.Layout.Bands[1].Columns.Insert(2, "EmptyX") to insert 6 columns before C3: e.Layout.Bands[1].Columns.Insert(3, "Empty7"); e.Layout.Bands[1].Columns.Insert(3, "Empty8"); e.Layout.Bands[1].Columns.Insert(3, "Empty9"); e.Layout.Bands[1].Columns.Insert(2, "Empty1"); e.Layout.Bands[1].Columns.Insert(2, "Empty2"); e.Layout.Bands[1].Columns.Insert(2, "Empty3"); e.Layout.Bands[1].Columns.Insert(2, "Empty4"); e.Layout.Bands[1].Columns.Insert(2, "Empty5"); e.Layout.Bands[1].Columns.Insert(2, "Empty6");
The result is
Blank (indentation), Empty6, C3, Empty5, C4, Empty4, C5, Empty3, C6, Empty2, C7, Empty1, Empty9, Empty8, Empty7
I used e.Layout.Bands[1].Columns.Insert(0, "EmptyX") to insert 9 empty columns before the original ones: e.Layout.Bands[1].Columns.Insert(0, "Empty1"); e.Layout.Bands[1].Columns.Insert(0, "Empty2"); e.Layout.Bands[1].Columns.Insert(0, "Empty3"); e.Layout.Bands[1].Columns.Insert(0, "Empty4"); e.Layout.Bands[1].Columns.Insert(0, "Empty5"); e.Layout.Bands[1].Columns.Insert(0, "Empty6"); e.Layout.Bands[1].Columns.Insert(0, "Empty7"); e.Layout.Bands[1].Columns.Insert(0, "Empty8"); e.Layout.Bands[1].Columns.Insert(0, "Empty9");
The result is:
Blank (indentation), Empty9, Empty8, Empty7, C3, Empty6, C4, Empty5, C5, Empty4, C6, Empty3, C7, Empty2, Empty1
I also tried using e.Layout.Bands[1].Columns.Indentation = 6 to achieve at least the first part of my goal but it doesn't work as expected
I also tried to use e.Layout.Bands[1].Columns[x].ColSpan but it gets ignored
Additionally, I handled BeginExport event (which gets handled after ExportStarted) in order to change column visibility. At the end of this event handler I checked the childband's column list and it seems as expected (6 blanks, 2 hiddens, C3, 3 blanks, C4, C5, C6, C7).
Could someone please help me?
Thanks
Hello Minerva,
I have been investigating into the behavior you are looking to achieve, and I have reproduced the behavior you are seeing where the columns do not appear to be getting added in the correct order prior to the export. I will be asking our development teams to examine this behavior further, as this appears to be a bug in the exporter.
With the above said, I have found a better way than adding extra columns to the grid to be exported. I would recommend that you handle the RowExporting and HeaderExporting events of the UltraGridExcelExporter. In this event, you can check the grid row’s Band property for your child band and set the event arguments’ CurrentColumnIndex property to the index that you would like that row to start exporting at.
I am attaching a sample project to demonstrate the above.
Please let me know if you have any other questions or concerns on this matter.
UltraGridExportIndentationCase.zip
Thank You for the quick replyI solved the first half of my issue using the proposed workaround e.CurrentColumnIndex = 9;: I am now able to set the starting column for child data obtaining
Blank, Blank, Blank, Blank, Blank, Blank, Blank, Blank, Blank, C3, C4, C5, C6, C7
And using e.CurrentColumnIndex = 6;:I obtain
Blank, Blank, Blank, Blank, Blank, Blank, C3, C4, C5, C6, C7
Now I just need to figure out how to insert 3 blank columns between C3 and the others
In order to place empty columns between column C3 and the others in your example, I would recommend utilizing the CellExporting and HeaderCellExporting events in tandem with the RowExporting and HeaderRowExporting events mentioned above.
The RowExporting and HeaderRowExporting events will fire first, and will transfer their CurrentColumnIndex to the CellExporting and HeaderCellExporting events. You can set this individually for each cell through the event arguments of the latter two events as well, and I am attaching an updated version of the sample project I originally sent to demonstrate how this can be done.
1031.UltraGridExportIndentationCase.zip
Hi AndrewI fear that applying the displacement cell-by-cell will hinder performances when the number of rows becomes relevant.I had the customer accept the temporary version vith columns C3~C7 close to each other so the issue became low priority.Let me know if the Developer team comes up with an HotFix for the expected behaviour describid in the original question.Thank You for your assistance, I will mark your first reply as answer.
I have created you a private support case that I will be linking to the internal development issue that I have logged for the “added columns” issue. The development issue has an ID of 273794 and the support case has an ID of C-00222161. You can access the support case after signing into your account here: https://account.infragistics.com/support-cases.
The next step is for a developer to review the findings in this forum thread and the sample project that reproduces the issue you are seeing and offer a fix or other resolution. You can continue to send updates to this forum thread or the private support case at any time.
I have received an update from our development teams on this matter. This issue is not a bug, as it appears that this behavior has nothing to do with exporting, specifically. The same behavior exists if you add the columns to the grid that is in your view.
What is happening is that the initial set of columns are being shown and having their VisiblePosition being generated and cached. Inserting a column into the Columns collection does not currently affect the cached visible position of other columns. When the VisiblePosition property of the new columns is retrieved, it resolves it based on the index in the collection and leads to multiple columns having potentially duplicate values.
The workaround to this behavior is you are looking to insert columns is to specific the column.Header.VisiblePosition for each of the columns after doing your insert.