/// <summary> /// to do /// </summary> /// <param name="row">to do 2</param> /// <param name="column">to do 3</param> /// <param name="text">to do 4</param> /// <param name="options">to do 5</param> public void WriteOnCell(int row, int column, string text, CellOptions options) { this.WriteOnCell(row, column, text); if (this.sheetToWrite != null) { var cell = this.sheetToWrite.Cells[row, column]; this.AttributeOptions(options, cell); } }
/// <summary> /// to do /// </summary> /// <param name="row">to do 2</param> /// <param name="startColumn">to do 3</param> /// <param name="texts">to do 4</param> /// <param name="options">to do 5</param> public void WriteHorizontalHeaders(int row, int startColumn, string[] texts, CellOptions options) { int numCol = startColumn; for (int i = 0; i < texts.Length; i++) { this.WriteOnCell(row, numCol, texts[i], options); numCol++; } }
/// <summary> /// to do /// </summary> /// <param name="options">to do 2</param> /// <param name="cell">to do 3</param> private static void AttributeOptions(CellOptions options, dynamic cell) { if (options.Bold) { cell.Font.Bold = options.Bold; } if (options.Italic) { cell.Font.Italic = options.Italic; } if (options.Underline) { cell.Font.Underline = options.Underline; } if (options.FontName != null) { cell.Font.Name = options.FontName; } if (options.FontSize > 0) { cell.Font.Size = options.FontSize; } if (options.FontColor != null) { cell.Font.Color = options.FontColor; } if (options.CellColor != Color.Empty) { cell.Interior.Color = options.CellColor; } if (options.TextHorizontalAlignment != HorizontalAlignment.None) { cell.HorizontalAlignment = (Excel.XlHAlign)options.TextHorizontalAlignment; } if (options.TextVerticalAlignment != VerticalAlignment.None) { cell.VerticalAlignment = (Excel.XlVAlign)options.TextVerticalAlignment; } if (options.Borders.Count > 0) { var borders = cell.Borders; foreach (var border in options.Borders) { if (border.Style != BorderStyle.None) { var index = (Excel.XlBordersIndex)border.Position; borders[index].LineStyle = (Excel.XlLineStyle)border.Style; if (border.Thickness > 0) { var thickness = (border.Thickness > 4) ? 4 : border.Thickness; borders[index].Weight = thickness; } if (border.Color != null) { borders[index].Color = border.Color; } } } } }
/// <summary> /// to do /// </summary> /// <param name="startRow">to do2</param> /// <param name="startColumn">to do 3</param> /// <param name="endRow">to do 4</param> /// <param name="endColumn">to do 5</param> /// <param name="options">to do 6</param> public void FormatRangeOptions(int startRow, int startColumn, int endRow, int endColumn, CellOptions options) { Excel.Range range = this.FindRange(startRow, startColumn, endRow, endColumn); AttributeOptions(options, range); }