public void SetToStyle(XSSFCellStyle style) { style.SetFillForegroundColor(BackgroundColor); style.FillPattern = FillPattern.SolidForeground; style.BorderTop = BorderTop; style.SetTopBorderColor(BorderTopColor); style.BorderRight = BorderRight; style.SetRightBorderColor(BorderRightColor); style.BorderBottom = BorderBottom; style.SetBottomBorderColor(BorderBottomColor); style.BorderLeft = BorderLeft; style.SetLeftBorderColor(BorderLeftColor); style.VerticalAlignment = VerticalAlignment; style.Alignment = HorizontalAlignment; switch (_writingMode) { case WritingModeEnum.lr_tb: style.Rotation = 0; break; case WritingModeEnum.tb_rl: style.Rotation = -90; break; case WritingModeEnum.tb_lr: style.Rotation = 90; break; default: throw new ArgumentOutOfRangeException($"Writing mode {_writingMode} is not supported"); } }
public void TestGetSetBottomBorderColor() { //defaults Assert.AreEqual(IndexedColors.Black.Index, cellStyle.BottomBorderColor); Assert.IsNull(cellStyle.BottomBorderXSSFColor); int num = stylesTable.GetBorders().Count; XSSFColor clr; //setting indexed color cellStyle.BottomBorderColor = (IndexedColors.BlueGrey.Index); Assert.AreEqual(IndexedColors.BlueGrey.Index, cellStyle.BottomBorderColor); clr = cellStyle.BottomBorderXSSFColor; Assert.IsTrue(clr.GetCTColor().IsSetIndexed()); Assert.AreEqual(IndexedColors.BlueGrey.Index, clr.Indexed); //a new border was Added to the styles table Assert.AreEqual(num + 1, stylesTable.GetBorders().Count); //id of the Created border uint borderId = cellStyle.GetCoreXf().borderId; Assert.IsTrue(borderId > 0); //check Changes in the underlying xml bean CT_Border ctBorder = stylesTable.GetBorderAt((int)borderId).GetCTBorder(); Assert.AreEqual((uint)IndexedColors.BlueGrey.Index, ctBorder.bottom.color.indexed); //setting XSSFColor num = stylesTable.GetBorders().Count; clr = new XSSFColor(Color.Cyan); cellStyle.SetBottomBorderColor(clr); Assert.AreEqual(clr.GetCTColor().ToString(), cellStyle.BottomBorderXSSFColor.GetCTColor().ToString()); byte[] rgb = cellStyle.BottomBorderXSSFColor.RGB; Assert.AreEqual(Color.Cyan, Color.FromRgb((byte)(rgb[0] & 0xFF), (byte)(rgb[1] & 0xFF), (byte)(rgb[2] & 0xFF))); //another border was Added to the styles table Assert.AreEqual(num + 1, stylesTable.GetBorders().Count); //passing null unsets the color cellStyle.SetBottomBorderColor(null); Assert.IsNull(cellStyle.BottomBorderXSSFColor); }
private static void CopyBordersStyle(XSSFCell oldCell, XSSFCellStyle newCellStyle) { byte[] rgb = new byte[3] { 0, 0, 0 }; newCellStyle.BorderBottom = oldCell.CellStyle.BorderBottom; newCellStyle.SetBottomBorderColor(new XSSFColor(rgb)); newCellStyle.BorderLeft = oldCell.CellStyle.BorderLeft; newCellStyle.SetLeftBorderColor(new XSSFColor(rgb)); newCellStyle.BorderTop = oldCell.CellStyle.BorderTop; newCellStyle.SetTopBorderColor(new XSSFColor(rgb)); newCellStyle.BorderRight = oldCell.CellStyle.BorderRight; newCellStyle.SetRightBorderColor(new XSSFColor(rgb)); }
private void ApplyBorderStyleBottom(ICellStyle cellStyle, DocumentModel.BorderStyle borderStyleBottom) { if (borderStyleBottom == null) { return; } cellStyle.BorderBottom = this.GetBorderStyle(borderStyleBottom.Type); if (borderStyleBottom.Color.HasValue) { XSSFCellStyle style = cellStyle as XSSFCellStyle; var color = borderStyleBottom.Color.Value; style.SetBottomBorderColor(new XSSFColor(new[] { color.Red, color.Green, color.Blue })); } }
public void SetToStyle(XSSFCellStyle style) { style.SetFillForegroundColor(BackgroundColor); style.FillPattern = FillPattern.SolidForeground; style.BorderTop = BorderTop; style.SetTopBorderColor(BorderTopColor); style.BorderRight = BorderRight; style.SetRightBorderColor(BorderRightColor); style.BorderBottom = BorderBottom; style.SetBottomBorderColor(BorderBottomColor); style.BorderLeft = BorderLeft; style.SetLeftBorderColor(BorderLeftColor); style.VerticalAlignment = VerticalAlignment; style.Alignment = HorizontalAlignment; }
public void Bug58996_UsedToWorkIn3_11_ButNotIn3_13() { XSSFWorkbook workbook = new XSSFWorkbook(); XSSFCellStyle cellStyle = workbook.CreateCellStyle() as XSSFCellStyle; cellStyle.FillForegroundColorColor = (null); Assert.IsNull(cellStyle.FillForegroundColorColor); cellStyle.FillBackgroundColorColor = (null); Assert.IsNull(cellStyle.FillBackgroundColorColor); cellStyle.FillPattern = FillPattern.NoFill;; Assert.AreEqual(FillPattern.NoFill, cellStyle.FillPattern); cellStyle.SetBottomBorderColor(null); Assert.IsNull(cellStyle.BottomBorderXSSFColor); cellStyle.SetTopBorderColor(null); Assert.IsNull(cellStyle.TopBorderXSSFColor); cellStyle.SetLeftBorderColor(null); Assert.IsNull(cellStyle.LeftBorderXSSFColor); cellStyle.SetRightBorderColor(null); Assert.IsNull(cellStyle.RightBorderXSSFColor); }
private XSSFCellStyle GetCellCommonStyle(IFont font, XSSFColor color, XSSFColor foregroundColor, BorderStyle borderRight) { XSSFCellStyle style = _wb.CreateCellStyle() as XSSFCellStyle; style.SetFillForegroundColor(foregroundColor); style.FillPattern = FillPattern.SolidForeground; style.Alignment = HorizontalAlignment.Center; style.VerticalAlignment = VerticalAlignment.Center; style.SetRightBorderColor(color); style.BorderRight = borderRight; style.SetLeftBorderColor(color); style.BorderLeft = BorderStyle.Thin; style.SetBottomBorderColor(color); style.BorderBottom = BorderStyle.Thin; style.SetTopBorderColor(color); style.BorderTop = BorderStyle.Thin; style.SetFont(font); return(style); }