Hi ,
i want export more XamDataGrid in different sheets of Excel but i don't know how to do it ,do you have any idea how work out this step?
And another question ,when i export from XamDatagrid to Excel i need to create in the Excel new Rows how show the picture below :
you can see i should create 3 new rows inserting the label name and after in the fourth row i export the data from XamDataGrid to excel (this last step is done already) so i ask you any help to advice me how i can create those row from the code behind .
Thanks so much for your attention.
If you need more details let me know i will reply faster.
Have a good day.
Cheers
What specific issue are you having? You can create worksheets and then use the Export overloads to export to specific worksheets. e.g.
var exporter = new DataPresenterExcelExporter(); var workbook = new Workbook(WorkbookFormat.Excel2007); var exportOptions = new ExportOptions(); var ws1 = workbook.Worksheets.Add("One"); exporter.Export(this.grid1, ws1, exportOptions); var ws2 = workbook.Worksheets.Add("Two"); exporter.Export(this.grid2, ws2, exportOptions); var ws3 = workbook.Worksheets.Add("Three"); exporter.Export(this.grid3, ws3, exportOptions); const string path = "c:\\temp.xlsx"; workbook.Save(path); Process.Start(path);
var ws1 = workbook.Worksheets.Add("One"); exporter.Export(this.grid1, ws1, exportOptions);
var ws2 = workbook.Worksheets.Add("Two"); exporter.Export(this.grid2, ws2, exportOptions);
var ws3 = workbook.Worksheets.Add("Three"); exporter.Export(this.grid3, ws3, exportOptions);
const string path = "c:\\temp.xlsx"; workbook.Save(path); Process.Start(path);
Hi Andrew,
thanks so much for your reply , i read about Excel Assembly and i can do many things but i got stuck when i create more Worksheet , i show better what i wish to do ;
i have 3 xamdataGrid ( xamDataGrid1, xamDataGrid2 and xamDatagrid3 ) a and i create 3 worksheets( "HTL","FLG" , "TSF") so i wish set up my excel in this way :
the worksheet "HTL" should show the xamDataGrid1 ;
the worksheet "FLG" should show the xamDataGrid2 ;
the worksheet "TSF" should show the xamDataGrid3 ;
so do you have any idea or already a sample code where i can understand how to perform that?
Thanks so much for your attention,
Have a nice time,
gerryjj said: i want export more XamDataGrid in different sheets of Excel but i don't know how to do it ,do you have any idea how work out this step?
There are lots of overloads of the Export method on the DataPresenterExcelExporter. If you want to export multiple grids to the same workbook then you would create a workbook in code, create a worksheet and then use the overloads that take a worksheet. Since you want to insert add information before the export you might use the Export overload that takes a worksheet and starting row/column.
gerryjj said:you can see i should create 3 new rows inserting the label name and after in the fourth row i export the data from XamDataGrid to excel (this last step is done already) so i ask you any help to advice me how i can create those row from the code behind
The Excel assembly help topics discuss the excel api itself. Once you set the values that you want you can use the Export overloads that take the starting row/column as mentioned above. If you instead want to insert content in the middle of the export then you might handle some of the DataPresenterExportEvents. They have properties that allow you to change the CurrentRowIndex, CurrentColumnIndex, etc. For example one might handle the HeaderAreaExported event if one wanted to put something after each of the header records.
Hi,
there are not suggestion about my question? also some link where i can understand how to write down my code . :)
Thanks so much for your attention .
Have a good day,