Hi.. i am using xamdatagrid and i am exporting excel.I want to change the format of the excel so that i am sending the format of the excel so that i want same as it is and sum of the group is not coming in excel only Grand sum is coming.i am sending my application so that u can verify and solve my problem.l
Thanks for sending code.... Its working sir.... Thanks a lot....
Here is how I formatted the Excel file:
private void Button_Click(object sender, System.Windows.RoutedEventArgs e){ var exporter = new DataPresenterExcelExporter(); string file = currentReport + " " + DateTime.Now.ToString("ddMMyy hhmmss") + ".xls"; exporter.HeaderLabelExporting += exporter_HeaderLabelExporting; exporter.RecordExported += exporter_RecordExported; Workbook workbook = new Workbook(WorkbookFormat.Excel97To2003, WorkbookPaletteMode.CustomPalette); exporter.Export(Project, workbook); workbook.Save(file); // SaveExport(workbook);} void exporter_RecordExported(object sender, RecordExportedEventArgs e){ if (e.Record is Infragistics.Windows.DataPresenter.GroupByRecord) { WorksheetMergedCellsRegionCollection mergedRegions = e.CurrentWorksheet.MergedCellsRegions; if (mergedRegions.Count != 0) { WorksheetMergedCellsRegion lastMergedRegion = mergedRegions[mergedRegions.Count - 1]; lastMergedRegion.CellFormat.Alignment = HorizontalCellAlignment.Center; lastMergedRegion.CellFormat.Font.Bold = ExcelDefaultableBoolean.True; lastMergedRegion.CellFormat.FillPatternForegroundColor = System.Drawing.Color.FromArgb(196, 189, 151); } }} private void exporter_HeaderLabelExporting(object sender, HeaderLabelExportingEventArgs e){ e.FormatSettings.FillPatternForegroundColor = System.Windows.Media.Color.FromArgb(255, 221, 217, 196);}
private void Button_Click(object sender, System.Windows.RoutedEventArgs e){ var exporter = new DataPresenterExcelExporter(); string file = currentReport + " " + DateTime.Now.ToString("ddMMyy hhmmss") + ".xls"; exporter.HeaderLabelExporting += exporter_HeaderLabelExporting; exporter.RecordExported += exporter_RecordExported;
Workbook workbook = new Workbook(WorkbookFormat.Excel97To2003, WorkbookPaletteMode.CustomPalette); exporter.Export(Project, workbook); workbook.Save(file);
// SaveExport(workbook);}
void exporter_RecordExported(object sender, RecordExportedEventArgs e){ if (e.Record is Infragistics.Windows.DataPresenter.GroupByRecord) { WorksheetMergedCellsRegionCollection mergedRegions = e.CurrentWorksheet.MergedCellsRegions; if (mergedRegions.Count != 0) { WorksheetMergedCellsRegion lastMergedRegion = mergedRegions[mergedRegions.Count - 1]; lastMergedRegion.CellFormat.Alignment = HorizontalCellAlignment.Center; lastMergedRegion.CellFormat.Font.Bold = ExcelDefaultableBoolean.True; lastMergedRegion.CellFormat.FillPatternForegroundColor = System.Drawing.Color.FromArgb(196, 189, 151); } }}
private void exporter_HeaderLabelExporting(object sender, HeaderLabelExportingEventArgs e){ e.FormatSettings.FillPatternForegroundColor = System.Windows.Media.Color.FromArgb(255, 221, 217, 196);}
Hi... i am sending the format of my excel which it should be.i am generating excel from xamdatagrid which i have send sample application.In that i am exporting to excel and format of that excel should be like this wat i am sending now.....
I'm sorry, I don't understand the question. Are you looking to change the format of the cells in the exported file? You can do that by handling the DataPresenterExcelExporter.HeaderLabelExporting, CellExporting, and SummaryCellExporting events and changing the e.FormatSettings.