public static void Print(this RadGridView grid, PrintSettings settings) { spreadsheet.Workbook = CreateWorkbook(grid, settings); PrintWhatSettings printWhatSettings = new PrintWhatSettings(ExportWhat.ActiveSheet, false); spreadsheet.Print(printWhatSettings); }
public static void PrintPreview(this RadGridView grid, PrintSettings settings) { spreadsheet.Workbook = CreateWorkbook(grid, settings); var printPreviewControl = CreatePrintPreviewControl(spreadsheet); var window = CreatePreviewWindow(printPreviewControl); window.ShowDialog(); }
private static Workbook CreateWorkbook(RadGridView grid, PrintSettings settings) { EventHandler <GridViewElementExportingToDocumentEventArgs> elementExporting = (s, e) => { var documentVisualExportParameters = e.VisualParameters as GridViewDocumentVisualExportParameters; if (documentVisualExportParameters != null) { if (e.Element == ExportElement.HeaderRow) { if (settings.HeaderBackground != null) { documentVisualExportParameters.Style = new CellSelectionStyle() { Fill = new PatternFill(PatternType.Solid, settings.HeaderBackground, settings.HeaderBackground) }; } } else if (e.Element == ExportElement.GroupHeaderRow) { if (settings.GroupHeaderBackground != null) { documentVisualExportParameters.Style = new CellSelectionStyle() { Fill = new PatternFill(PatternType.Solid, settings.GroupHeaderBackground, settings.GroupHeaderBackground) }; } } else if (e.Element == ExportElement.Row) { if (settings.RowBackground != null) { documentVisualExportParameters.Style = new CellSelectionStyle() { Fill = new PatternFill(PatternType.Solid, settings.RowBackground, settings.RowBackground) }; } } } }; grid.ElementExportingToDocument += elementExporting; Workbook currentWorkbook = grid.ExportToWorkbook(); return(currentWorkbook); }
private static Workbook CreateWorkbook(RadGridView grid, PrintSettings settings) { EventHandler<GridViewElementExportingToDocumentEventArgs> elementExporting = (s, e) => { var documentVisualExportParameters = e.VisualParameters as GridViewDocumentVisualExportParameters; if (documentVisualExportParameters != null) { if (e.Element == ExportElement.HeaderRow) { if (settings.HeaderBackground != null) { documentVisualExportParameters.Style = new CellSelectionStyle() { Fill = new PatternFill(PatternType.Solid, settings.HeaderBackground, settings.HeaderBackground) }; } } else if (e.Element == ExportElement.GroupHeaderRow) { if (settings.GroupHeaderBackground != null) { documentVisualExportParameters.Style = new CellSelectionStyle() { Fill = new PatternFill(PatternType.Solid, settings.GroupHeaderBackground, settings.GroupHeaderBackground) }; } } else if (e.Element == ExportElement.Row) { if (settings.RowBackground != null) { documentVisualExportParameters.Style = new CellSelectionStyle() { Fill = new PatternFill(PatternType.Solid, settings.RowBackground, settings.RowBackground) }; } } } }; grid.ElementExportingToDocument += elementExporting; Workbook currentWorkbook = grid.ExportToWorkbook(); return currentWorkbook; }