public override void Execute(object parameter) { SpreadsheetCellRangeBorders borders = this.Adapter.SheetCellRangeBorders; var borderColor = this.Adapter.BorderColor; CellBorderLineStyle style = this.Adapter.CellBorderLineStyle; ExcelBorders borderCommnd = this.Adapter.LastAppliedBorderSettings; if (parameter != null) { borderCommnd = (ExcelBorders)Enum.Parse(typeof(ExcelBorders), parameter.ToString()); } this.Adapter.LastAppliedBorderSettings = borderCommnd; switch (borderCommnd) { case ExcelBorders.BottomBorder: style = CellBorderLineStyle.Thin; borders = SpreadsheetCellRangeBorders.BottomBorder; break; case ExcelBorders.TopBorder: style = CellBorderLineStyle.Thin; borders = SpreadsheetCellRangeBorders.TopBorder; break; case ExcelBorders.LeftBorder: style = CellBorderLineStyle.Thin; borders = SpreadsheetCellRangeBorders.LeftBorder; break; case ExcelBorders.RightBorder: style = CellBorderLineStyle.Thin; borders = SpreadsheetCellRangeBorders.RightBorder; break; case ExcelBorders.NoBorder: borders = SpreadsheetCellRangeBorders.AllBorder; style = CellBorderLineStyle.None; break; case ExcelBorders.AllBorders: style = CellBorderLineStyle.Thin; borders = SpreadsheetCellRangeBorders.AllBorder; break; case ExcelBorders.OutsideBorder: style = CellBorderLineStyle.Thin; borders = SpreadsheetCellRangeBorders.OutsideBorder; break; case ExcelBorders.ThickBoxBorder: style = CellBorderLineStyle.Thick; borders = SpreadsheetCellRangeBorders.OutsideBorder; break; case ExcelBorders.BottomDoubleBorder: style = CellBorderLineStyle.Double; borders = SpreadsheetCellRangeBorders.BottomBorder; break; case ExcelBorders.ThickBottomBorder: style = CellBorderLineStyle.Thick; borders = SpreadsheetCellRangeBorders.BottomBorder; break; case ExcelBorders.TopAndBottomBorder: style = CellBorderLineStyle.Thin; borders = SpreadsheetCellRangeBorders.TopBorder | SpreadsheetCellRangeBorders.BottomBorder; break; case ExcelBorders.TopAndThickBottomBorder: style = CellBorderLineStyle.Thin; borders = SpreadsheetCellRangeBorders.TopBorder; this.Adapter.SpreadSheet.ActiveSelectionCellRangeFormat.SetBorders(borders, borderColor, style); style = CellBorderLineStyle.Thick; borders = SpreadsheetCellRangeBorders.BottomBorder; break; case ExcelBorders.TopAndDoubleBottomBorder: style = CellBorderLineStyle.Thin; borders = SpreadsheetCellRangeBorders.TopBorder; this.Adapter.SpreadSheet.ActiveSelectionCellRangeFormat.SetBorders(borders, borderColor, style); style = CellBorderLineStyle.Double; borders = SpreadsheetCellRangeBorders.BottomBorder; break; default: break; } this.Adapter.SheetCellRangeBorders = borders; this.Adapter.BorderColor = borderColor; this.Adapter.CellBorderLineStyle = style; this.Adapter.SpreadSheet.ActiveSelectionCellRangeFormat.SetBorders(borders, borderColor, style); }
public StyleBorder Add(CellBorderPosition Position, CellBorderLineStyle LineStyle, Color Color, double Weight) { StyleBorder border = new StyleBorder(); border.Color = Color; border.LineStyle = LineStyle; border.Position = Position; border.Weight = Weight; _Borders.Add(border); return border; }
/// <summary> /// Converts a Web BorderStyle into an Excel BorderStyle. /// /// </summary> private CellBorderLineStyle ConvertWebToExcelBorderStyle(CellBorderLineStyle currentStyle, Infragistics.Documents.Reports.BorderStyle webBorderStyle, Unit width) { if (currentStyle != CellBorderLineStyle.Default) return currentStyle; double num = width.Value; if (num == 0.0) return CellBorderLineStyle.Default; CellBorderLineStyle cellBorderLineStyle; switch (webBorderStyle) { case Infragistics.Documents.Reports.BorderStyle.Double: case Infragistics.Documents.Reports.BorderStyle.Groove: cellBorderLineStyle = CellBorderLineStyle.Double; break; case Infragistics.Documents.Reports.BorderStyle.Inset: cellBorderLineStyle = CellBorderLineStyle.Hair; break; case Infragistics.Documents.Reports.BorderStyle.None: cellBorderLineStyle = CellBorderLineStyle.Default; break; case Infragistics.Documents.Reports.BorderStyle.Outset: case Infragistics.Documents.Reports.BorderStyle.Ridge: case Infragistics.Documents.Reports.BorderStyle.Solid: cellBorderLineStyle = num < 2.0 ? CellBorderLineStyle.Thin : (num < 5.0 ? CellBorderLineStyle.Medium : CellBorderLineStyle.Thick); break; case Infragistics.Documents.Reports.BorderStyle.Dotted: cellBorderLineStyle = CellBorderLineStyle.Dotted; break; case Infragistics.Documents.Reports.BorderStyle.Dashed: cellBorderLineStyle = num < 3.0 ? CellBorderLineStyle.Dashed : CellBorderLineStyle.MediumDashed; break; default: cellBorderLineStyle = CellBorderLineStyle.Thin; break; } return cellBorderLineStyle; }