public static void SetFormatCell(IXLWorksheet ws, int firstCellRow, int firstCellColumn, int lastCellRow, int lastCellColumn, bool isFontBold = false, int fontSize = 10, bool isMergeCell = false, bool isSetColorHeader = false, bool isSetBorder = true, XLAlignmentHorizontalValues HorizontalAlgn = XLAlignmentHorizontalValues.Center, XLAlignmentVerticalValues VerticalAlgn = XLAlignmentVerticalValues.Center) { // Defining ranges // From worksheet var rangeTable = ws.Range(firstCellRow, firstCellColumn, lastCellRow, lastCellColumn); rangeTable.Style.Alignment.Horizontal = HorizontalAlgn; rangeTable.Style.Alignment.Vertical = VerticalAlgn; rangeTable.Style.Font.Bold = isFontBold; rangeTable.Style.Font.FontSize = fontSize; if (isSetColorHeader) { rangeTable.Style.Fill.BackgroundColor = XLColor.FromArgb(184, 184, 184); } if (isMergeCell) { // Merge title cells //rngTable.Row(1).Merge(); // We could've also used: rngTable.Range("A1:E1").Merge() rangeTable.Merge(); } if (isSetBorder) { rangeTable.Style.Border.BottomBorder = XLBorderStyleValues.Thin; rangeTable.Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } }
public XLAlignment(IXLStylized container, IXLAlignment d = null) { _container = container; if (d == null) { return; } _horizontal = d.Horizontal; _vertical = d.Vertical; _indent = d.Indent; _justifyLastLine = d.JustifyLastLine; _readingOrder = d.ReadingOrder; _relativeIndent = d.RelativeIndent; _shrinkToFit = d.ShrinkToFit; _textRotation = d.TextRotation; _wrapText = d.WrapText; }
internal async Task <IXLCell> SetStyleToCell(IXLCell cell, int fontSize = 12, string fontName = "Segoe UI", bool isFontBold = false, XLColor backgroundColor = null, XLAlignmentHorizontalValues horizontalAlignment = XLAlignmentHorizontalValues.Center, XLAlignmentVerticalValues verticalAlignment = XLAlignmentVerticalValues.Center, XLColor outsideBorderColor = null, XLBorderStyleValues outsideBorder = XLBorderStyleValues.Dashed) { cell.Style.Font.FontSize = fontSize; cell.Style.Font.FontName = fontName; cell.Style.Font.Bold = isFontBold; cell.Style.Border.OutsideBorder = outsideBorder; cell.Style.Border.OutsideBorderColor = outsideBorderColor ?? XLColor.LightSlateGray; cell.Style.Alignment.SetHorizontal(horizontalAlignment); cell.Style.Alignment.SetVertical(verticalAlignment); cell.Style.Alignment.SetWrapText(); if (backgroundColor != null) { cell.Style.Fill.BackgroundColor = backgroundColor; } return(cell); }
public static IXLCell SetAlignVertical(this IXLCell cell, XLAlignmentVerticalValues align) { cell.AsRange().SetAlignVertical(align); return(cell); }
public IXLStyle SetVertical(XLAlignmentVerticalValues value) { Vertical = value; return(_style); }
public void AddHeaderDataWrapText(string cell, string cellvalue, string font, bool isBold, XLAlignmentHorizontalValues Alignment, double fontsize, XLCellValues DataType, XLAlignmentVerticalValues VerticalAlignment) { ws.Cell(cell).Value = cellvalue; ws.Cell(cell).Style.Font.FontName = font; ws.Cell(cell).Style.Font.Bold = isBold; ws.Cell(cell).Style.Font.FontSize = fontsize; ws.Cell(cell).Style.Alignment.Horizontal = Alignment; ws.Cell(cell).DataType = DataType; ws.Cell(cell).Style.Alignment.Vertical = VerticalAlignment; ws.Cell(cell).Style.Alignment.SetWrapText(); }
public void AddHeaderDataWrapText(string cell, string cellvalue, string font, bool isBold, XLAlignmentHorizontalValues Alignment, double fontsize, string mergeCellReference, XLCellValues DataType, XLColor bgColor, XLAlignmentVerticalValues VerticalAlignment) { ws.Cell(cell).Value = cellvalue; ws.Cell(cell).Style.Font.FontName = font; ws.Cell(cell).Style.Font.Bold = isBold; ws.Cell(cell).Style.Font.FontSize = fontsize; ws.Cell(cell).Style.Alignment.Horizontal = Alignment; ws.Cell(cell).Style.Alignment.Vertical = VerticalAlignment; ws.Range(mergeCellReference).Merge(); ws.Cell(cell).DataType = DataType; ws.Cell(cell).Style.Fill.BackgroundColor = bgColor; ws.Cell(cell).Style.Alignment.SetWrapText(); }
public IXLStyle SetVertical(XLAlignmentVerticalValues value) { Vertical = value; return _container.Style; }
public XLAlignment(IXLStylized container, IXLAlignment d = null) { _container = container; if (d == null) return; _horizontal = d.Horizontal; _vertical = d.Vertical; _indent = d.Indent; _justifyLastLine = d.JustifyLastLine; _readingOrder = d.ReadingOrder; _relativeIndent = d.RelativeIndent; _shrinkToFit = d.ShrinkToFit; _textRotation = d.TextRotation; _wrapText = d.WrapText; }