Example #1
0
 /// <summary>
 /// Exports a grid field caption (header or footer) to the specified worksheet cell.
 /// 
 /// </summary>
 protected virtual void ExportGridFieldCaption(WebDataGrid grid, GridFieldCaption caption, WorksheetRow wsRow, WorksheetCell wsCell, int rowIndex, int columnIndex, string gridCssClass, string captionRowCssClass, bool isHeader, int rowSpan, int colSpan, int colOffset)
 {
     WorksheetMergedCellsRegion mergedCellsRegion = rowSpan > 1 || colSpan > 1 ? wsRow.Worksheet.MergedCellsRegions.Add(rowIndex, columnIndex + colOffset, rowIndex + rowSpan - 1, columnIndex + colOffset + colSpan - 1) : (WorksheetMergedCellsRegion)null;
     ExcelCellExportingEventArgs e1 = new ExcelCellExportingEventArgs(wsRow.Worksheet, wsCell, rowIndex, columnIndex, wsRow.OutlineLevel, isHeader, !isHeader, false);
     this.OnCellExporting(e1);
     if (e1.Cancel)
         return;
     GridFieldCaptionExportingEventArgs e2 = new GridFieldCaptionExportingEventArgs(caption, wsRow.Worksheet, wsCell, rowIndex, columnIndex, wsRow.OutlineLevel, isHeader, !isHeader, false);
     this.OnGridFieldCaptionExporting(e2);
     if (e2.Cancel)
         return;
     if (mergedCellsRegion != null)
         mergedCellsRegion.Value = (object)caption.Text;
     else
         wsCell.Value = (object)caption.Text;
     if (this.EnableStylesExport)
     {
         string styleClassString = grid.RunBot.StyleBot.GetStyleClassString((int)caption.Role, caption.CssClassResolved);
         if (caption.OwnerField is GroupField && caption.Role == WebDataGridRoles.HeaderCaption)
             styleClassString = grid.RunBot.StyleBot.GetStyleClassString(10, styleClassString);
         CssSelector selector1 = new CssSelector();
         selector1.AddClasses(string.Format("{0} {1} {2}", (object)gridCssClass, (object)captionRowCssClass, (object)styleClassString));
         CssStyle styleObject1 = this._currentStyleSheet.GetStyleObject(selector1);
         this.ApplyCellFormatFromStyle(wsCell.Worksheet.Workbook, wsCell.CellFormat, styleObject1, grid);
         if (mergedCellsRegion != null)
             this.ApplyCellFormatFromStyle(mergedCellsRegion.Worksheet.Workbook, mergedCellsRegion.CellFormat, styleObject1, grid);
         CssSelector selector2 = new CssSelector();
         selector2.AddClasses(styleClassString);
         CssStyle styleObject2 = this._currentStyleSheet.GetStyleObject(selector2);
         this.ApplyCellBorderFromStyle(wsCell.CellFormat, styleObject2);
         if (mergedCellsRegion != null)
             this.ApplyCellBorderFromStyle(mergedCellsRegion.CellFormat, styleObject2);
     }
     if (wsCell.Value != null)
     {
         this.SetColumnWidth(wsCell.Worksheet.Columns[wsCell.ColumnIndex], wsCell);
         if (wsCell.Value.ToString().Contains(Environment.NewLine))
             wsCell.CellFormat.WrapText = ExcelDefaultableBoolean.True;
     }
     if (mergedCellsRegion != null && mergedCellsRegion.Value != null && mergedCellsRegion.Value.ToString().Contains(Environment.NewLine))
         mergedCellsRegion.CellFormat.WrapText = ExcelDefaultableBoolean.True;
     this.OnGridFieldCaptionExported(new GridFieldCaptionExportedEventArgs(caption, wsRow.Worksheet, wsCell, rowIndex, columnIndex, wsRow.OutlineLevel, isHeader, !isHeader, false));
     this.OnCellExported(new ExcelCellExportedEventArgs(wsRow.Worksheet, wsCell, rowIndex, columnIndex, wsRow.OutlineLevel, isHeader, !isHeader, false));
 }
Example #2
0
 /// <summary>
 /// Raises the GridFieldCaptionExporting Event.
 /// 
 /// </summary>
 protected virtual void OnGridFieldCaptionExporting(GridFieldCaptionExportingEventArgs e)
 {
     GridFieldCaptionExportingEventHandler exportingEventHandler = this.Events[WebExcelExporter.EventGridFieldCaptionExporting] as GridFieldCaptionExportingEventHandler;
     if (exportingEventHandler == null)
         return;
     exportingEventHandler((object)this, e);
 }