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)
I was not able to reproduce this crash. Can you provide a sample with the XamGrid, you are trying to export, so that I can try and isolate the problem?
Thanks,
Stefana
Hello,
i am facing the same issue on a view ....
The grid has one ImageColumn and the rest are TextColumns, some of them have conditional format collection defined with StyleToApply a resource from app.xaml...
Please check if this is the issue....
Michael
I followed the steps you suggested and was unable to reproduce the behavior you're describing. I created a grid with an in image column and text columns and included conditional formatting. I was able to export the grid to excel as expected.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using version 11.2.20112.1010 in NetAdvantage for Silverlight LOB 2011 Volume 2.
If the project does show the product feature working correctly, this indicates a possible problem in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if I can provide any further assistance.
Sincerely,
Valerie
Developer Support Engineer
Infragistics
www.infragistics.com/support
Were you able to test the sample I provided?
Sincerely,ValerieDeveloper Support Engineer Infragisticswww.infragistics.com/support
sorry for not replying, i was too busy...
I have tested the sample, and indeed it works. It seems that is something else that produces the problem we mention...
I will try to create a sample that reproduces the problem and i will post it here or create a support case that will reference this post....
Thank you,
This issue was resolved in the service release for 11.2 and 12.1.
Please let me know if you are still having issues after upgrading to the latest service release.
Developer Support Supervisor - XAML
what this ever resolved?
i have the same issue with a grid that is tied to a domaindatasource. it used to work but just stopped
I have logged this as development issue 97611.
unfortunately i will not close this thread yet.
I modified the sample, and moved the style resources under the xamgridex resources.(it is the same for xamGrid also)
Now when i try to export, i get the following error "System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type System.Windows.Style was not expected. Use the XmlInclude attribute to specify types that are not known statically.", as you can see in the attached sample.
Also, when we call the Export method to the XamGridExcelExporter, we pass as parameter the grid on which we will perform the export. Why don't you use reflection to create an instance of the requested grid, if the event is not handled by the developer? I tried it on the attached sample and it seems to work....
Regards,
I spoke with development on this and in order to resolve this you need to indicate the type to the persistence framework in order to rehydrate the inherited grid. This can be accomplished by handling the XamGridRequested event on the XamGridExcelExporter and passing in a new instance of the grid being exported:
XamGridExcelExporter excelExporter = new XamGridExcelExporter(); excelExporter.XamGridRequested += new EventHandler<XamGridExcelExporterRequestedEventArgs>(excelExporter_XamGridRequested); ….
void excelExporter_XamGridRequested(object sender, XamGridExcelExporterRequestedEventArgs e){ e.XamGrid = new XamGridEx();}
Please note there are known issues and limitations using the XamGridExporter, including conditional formatting, which can be found at:
http://help.infragistics.com/NetAdvantage/Silverlight/2011.2/CLR4.0/?page=xamGrid_Known_Issues_Limitations_ExcelExporter.html
Please let me know if you have any questions.