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
40
Crash when using the new XamGridExcelExporter
posted

Hi,

I upgraded my project to v11.2 and I'm trying to export the content of my xamGrid with the new xamGridExcelExporter.

Here is my code:

        private void bt_excel_Click(object sender, RoutedEventArgs e)
        {
            Workbook dataWorkbook = new Workbook();
            Worksheet sheetOne = dataWorkbook.Worksheets.Add("Data Sheet");

            dataWorkbook.SetCurrentFormat(WorkbookFormat.Excel2007);

            excelExporter.Export(this.datagrid, dataWorkbook);
           
            SaveExport(dataWorkbook);
        }

        private void SaveExport(Workbook dataWorkbook)
        {
            SaveFileDialog dialog;

            dialog = new SaveFileDialog { Filter = "Excel files|*.xlsx", DefaultExt = "xlsx" };


            bool? showDialog = dialog.ShowDialog();
            if (showDialog == true)
            {
                using (Stream exportStream = dialog.OpenFile())
                {
                    dataWorkbook.Save(exportStream);
                    exportStream.Close();
                }

            }
        }

 

 

Here is the error detail:

PersistenceGroup elements don't match elements in stream.

   at Infragistics.Persistence.PersistenceManager.LoadGroup(PersistenceGroup group, Stream stream, PersistenceSettings settings)
   at Infragistics.Persistence.PersistenceManager.Load(DependencyObject obj, Stream stream, PersistenceSettings settings)
   at Infragistics.Persistence.PersistenceManager.Load(DependencyObject obj, Stream stream)
   at Infragistics.Controls.Grids.XamGridExcelExporter.CopySourceGridToExporterGrid()
   at Infragistics.Controls.Grids.XamGridExcelExporter.ExportInternal()
   at Infragistics.Controls.Grids.XamGridExcelExporter.Export(XamGrid grid, Workbook workBook, Worksheet workSheet, PackageFactory pf, Boolean useAsync)
   at Infragistics.Controls.Grids.XamGridExcelExporter.Export(XamGrid grid, Workbook workBook)
   at GEC.GecExtendedDataGrid.bt_excel_Click(Object sender, RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)