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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #17440 |

    I am having problems opening a XML file that was created by Xceed’s Grid export.  Sometimes I get a error from Excel 2003 when trying to open the XML file.

    Error: “Problems came up in the following areas during Load:  Style”.  It tells me to check a log file for a list of errors but I can not find the log file.

    If I turn off IncludeGridStyles then the problem goes away.  The Grid is a flat grid with no groups or custom editors.  The XML file size is about 4M.

    Any ideas as to what could be causing the error?


    The following code is part of a Wrapper I created for the Grid Control:

    Public Sub ExportGrid(Optional ByVal Filename As String = “”, Optional ByVal vIncludeGridStyles As Boolean = True)

          Dim saveFileDialog As New SaveFileDialog
          saveFileDialog.Filter = “XML Spreadsheet (*.xml)|*.xml”
          saveFileDialog.FileName = Filename

          If saveFileDialog.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then
          End If

          Dim excelExporter As New ExcelExporter

          excelExporter.IncludeColumnHeaders = True
          excelExporter.ColumnHeaderStyle = New ExcelStyle(Color.White, Color.Black, New Font(Me.Font, FontStyle.Bold), ContentAlignment.BottomLeft)
          excelExporter.GridLineColor = Color.DarkGray

          excelExporter.IncludeDetailGrids = True
          excelExporter.IncludeGridStyles = vIncludeGridStyles
          excelExporter.RepeatParentData = True

          excelExporter.CellDataFormat = CellDataFormat.Value
          excelExporter.DetailGridsMode = DetailGridsMode.Independent

          excelExporter.Export(Me, saveFileDialog.FileName)

          If (DialogResult.Yes = (MessageBox.Show(“Export successful.” + System.Environment.NewLine + System.Environment.NewLine + “Do you wish to open the exported spreadsheet into Excel now?”, “Export successful”, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1))) Then
             Catch exception As Exception
                Throw New InvalidOperationException(“An error occured while trying to open ” + saveFileDialog.FileName + “.  Make sure that Microsoft Excel is installed.”, exception)
             End Try
          End If

       End Sub

    Imported from legacy forums. Posted by Morgan (had 3979 views)

    Xceed Support
    Post count: 5658

    Hi Morgan,


    Please can you provide us with an example project that generates the defective XML file using the latest assemblies’ version? Having a reproducing sample will enable us to clearly identify the causes of the issue. Thank you.

    Imported from legacy forums. Posted by Mohamed [Xceed] (had 813 views)

    User (Old forums)
    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(
             // 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)

    User (Old forums)
    Post count: 23064

    Thanks Aaron, I never made the connection as to why sometimes it worked and other times it did not.

    Imported from legacy forums. Posted by Morgan (had 1300 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.