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
138
UltreGrid Excel Exporter (WinForms): Add many blank columns
posted

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

Parents
No Data
Reply
  • 34850
    Verified Answer
    Offline posted

    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

Children