public virtual void Export(Worksheet worksheet, params WebDataGridExport[] grids) { //this._currentWorkbookFormat = worksheet.Workbook.CurrentFormat; var e = new ExcelExportingEventArgs(worksheet, grids[0].RowOffset, grids[0].ColumnOffset, 0); this.OnExporting(e); if (e.Cancel) { return; } int currentRowIndex = e.CurrentRowIndex; foreach (var grid in grids) { int rowExportIndex; int rowIndex = rowExportIndex = grid.RowOffset; //this.InitStyleSheet(grid.Grid.RunBot); this.ExportGrid(grid.Grid, worksheet, ref rowIndex, ref rowExportIndex, grid.ColumnOffset, 0); //this._currentStyleSheet = (StyleSheet)null; //currentRowIndex += this._gridsRowSpacing; } //this.OnExported(new ExcelExportedEventArgs(worksheet, currentRowIndex, columnOffset, 0)); this.DownloadWorkbook(worksheet.Workbook); }
private async void WebExcelExporterOnExporting(object sender, ExcelExportingEventArgs e) { string title = string.Empty; switch (calculateRequest.RequestType) { case RequestType.Plz: title = "PLZ: " + calculateRequest.Plz; break; case RequestType.Bundesland: var bl = await bundeslandService.GetById(calculateRequest.Value); title = "Bundesland: " + bl.Name; break; case RequestType.Deutschland: title = "Deutschland"; break; } // Add a title to the report e.Worksheet.Rows[0].Cells[0].Value = title; e.Worksheet.Rows[0].Cells[0].CellFormat.Font.ColorInfo = Color.Black; e.Worksheet.Rows[0].Cells[0].CellFormat.Font.Height = 10 * 20; e.Worksheet.Rows[1].Cells[0].Value = "Stichtag: " + calculateRequest.Stichtag.ToString("MM.yyyy"); e.Worksheet.Rows[1].Cells[0].CellFormat.Font.ColorInfo = Color.Black; e.Worksheet.Rows[1].Cells[0].CellFormat.Font.Height = 10 * 20; }
/// <summary> /// Exports multiple grids on a single worksheet. /// /// </summary> public virtual void Export(Worksheet worksheet, int rowOffset, int columnOffset, params WebControl[] grids) { this._currentWorkbookFormat = worksheet.Workbook.CurrentFormat; ExcelExportingEventArgs e = new ExcelExportingEventArgs(worksheet, rowOffset, columnOffset, 0); this.OnExporting(e); if (e.Cancel) return; int currentRowIndex = e.CurrentRowIndex; foreach (object obj in grids) { if (obj is WebDataGrid) { this.InitStyleSheet(((FlatDataBoundControl)obj).RunBot); this.ExportGrid((WebDataGrid)obj, worksheet, ref currentRowIndex, columnOffset, 0); this._currentStyleSheet = (StyleSheet)null; currentRowIndex += this._gridsRowSpacing; } else if (obj is WebHierarchicalDataGrid) { this.InitStyleSheet(((HierarchicalDataBoundControlMain)obj).RunBot); this.ExportHierarchicalGrid((WebHierarchicalDataGrid)obj, worksheet, ref currentRowIndex, columnOffset); this._currentStyleSheet = (StyleSheet)null; currentRowIndex += this._gridsRowSpacing; } else throw new InvalidOperationException(Infragistics.Web.UI.SR.GetString("EE_CONTROL_NOT_SUPPORTED_EXCEPTION", new object[1] { (object) obj.GetType().Name })); } this.OnExported(new ExcelExportedEventArgs(worksheet, currentRowIndex, columnOffset, 0)); this.DownloadWorkbook(worksheet.Workbook); }
/// <summary> /// Exports a single flat grid to the specified worksheet. /// Exporting starts from the defined row and column offsets. /// /// </summary> public virtual void Export(WebDataGrid grid, Worksheet worksheet, int rowOffset, int columnOffset) { this._currentWorkbookFormat = worksheet.Workbook.CurrentFormat; ExcelExportingEventArgs e = new ExcelExportingEventArgs(worksheet, rowOffset, columnOffset, 0); this.OnExporting(e); if (e.Cancel) return; rowOffset = e.CurrentRowIndex; this.InitStyleSheet(grid.RunBot); this.ExportGrid(grid, worksheet, ref rowOffset, columnOffset, 0); this._currentStyleSheet = (StyleSheet)null; this.OnExported(new ExcelExportedEventArgs(worksheet, rowOffset, columnOffset, 0)); this.DownloadWorkbook(worksheet.Workbook); }
/// <summary> /// Raises the Exporting Event. /// /// </summary> protected virtual void OnExporting(ExcelExportingEventArgs e) { ExcelExportingEventHandler exportingEventHandler = this.Events[WebExcelExporter.EventExporting] as ExcelExportingEventHandler; if (exportingEventHandler == null) return; exportingEventHandler((object)this, e); }