Home Forums WinForms controls Xceed Grid for WinForms Export to XML fails to Load into Excel Because of a Style error. Reply To: Export to XML fails to Load into Excel Because of a Style error.

User (Old forums)
Member
Post count: 23064

I ran into this recently too; I don’t know if you ever resolved it, but in my case, the issue turned out to be with using System Colors to format the grid.  These would translate into Named system colors in the XML, i.e. “ControlLight” which apparently aren’t supported by the Excel Schema.

 

The fix was to translate any colors into their ARGB values so they exported that way to Excel.

 

Here’s an example (in C#) that would generate the error loading the XML file:

      private void button1_Click(object sender, EventArgs e)
      {
         string exportFilename = System.IO.Path.Combine(
            Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
            "XceedExport.xml");
 
         // This will cause the error when launching the exported Excel XML file.
         gridControl1.CurrentRow.BackColor = SystemColors.ControlLight;
 
         Xceed.Grid.Exporting.ExcelExporter exporter = new Xceed.Grid.Exporting.ExcelExporter();
 
         exporter.CellDataFormat = Xceed.Grid.Exporting.CellDataFormat.Value;
         exporter.DetailGridsMode = Xceed.Grid.Exporting.DetailGridsMode.Independent;
         exporter.IncludeColumnHeaders = true;
         exporter.IncludeDetailGrids = true;
 
         exporter.Export(gridControl1, exportFilename); 

      } 

 

– Aaron. 

Imported from legacy forums. Posted by AaronY (had 418 views)