How to export the multiple UWP SfDataGrid's to single excel sheet ?
In SfDataGrid control, you can export data to Excel by using the ExportToExcel method. If you want export multiple SfDataGrid’s to single excel sheet , you need to merge the one SfDataGrid WorkSheet into another SfDataGrid WorkSheet using Worksheet.UsedRange.CopyTo method like the below code example.
C#
using Syncfusion.UI.Xaml.Grid.Converter; using Syncfusion.XlsIO;try { var options = new ExcelExportingOptions(); options.ExcelVersion = ExcelVersion.Excel2010; var excelEngine = dataGrid1.ExportToExcel(dataGrid1.View, options); var workBook1 = excelEngine.Excel.Workbooks[0]; var worksheet1 = workBook1.Worksheets[0]; excelEngine = dataGrid2.ExportToExcel(dataGrid2.View, options); var workBook2 = excelEngine.Excel.Workbooks[0]; var worksheet2 = workBook2.Worksheets[0]; var columnCount = dataGrid1.Columns.Count; //Merge the One SfDataGrid WorkSheet into the other SfDataGrid WorkSheet worksheet2.UsedRange.CopyTo(worksheet1[1, columnCount + 1]); workBook1.SaveAs("sample.xlsx"); } catch (Exception) { }
Samples:
I hope you enjoyed learning about how to export the multiple UWP SfDataGrid's to single excel sheet.
You can refer to our UWP SfSpreadsheet.feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!