private void SetNumCell(double value, LayoutStyle style, bool zeroEmpty) { if (zeroEmpty && Math.Abs(value) < 0.000001) { FetchCurCell(CellType.String, style)?.SetCellValue(string.Empty); } else { FetchCurCell(CellType.Numeric, style)?.SetCellValue(value); } }
public BaseCell(string value, int columnWidth = 0, LayoutStyle style = null) { Value = value; LayoutStyle = style; if (columnWidth > 0) { LayoutSet = new LayoutSet { ColumnWidth = columnWidth } } ; }
private ICell FetchCurCell(CellType type, LayoutStyle style) { if (CurRow == null) { return(null); } var cell = CurRow.GetCell(CurColumnIndex) ?? CurRow.CreateCell(CurColumnIndex, type); CurColumnIndex++; //移到下一格 if (style != null) { cell.CellStyle = Sheet.Workbook.GetCellStyleAt(style.StoreIndex); } return(cell); }
public LayoutStyle CreateStyle(AlignmentMode alignment, AlignmentMode verticalAlignment = AlignmentMode.Center, bool applyToColumn = false, bool fontBold = false, short fontPoints = 0, string backColor = null) { var style = new LayoutStyle { Alignment = alignment, VerticalAlignment = verticalAlignment, FontBold = fontBold, FontPoints = fontPoints, ApplyToColumn = applyToColumn, BackgroundColor = backColor, //HasBorder = true }; SheetStyles.Add(style); return(style); }
public BaseCell(string value, LayoutSet layoutSet = null, LayoutStyle style = null) { Value = value; LayoutStyle = style; LayoutSet = layoutSet; }
public void WriteCell(decimal value, LayoutStyle style = null, bool zeroEmpty = false) { SetNumCell((double)value, style, zeroEmpty); }
public void WriteCell(int value, LayoutStyle style = null, bool zeroEmpty = false) { SetNumCell(value, style, zeroEmpty); }
public void WriteCell(string value, LayoutStyle style = null) { FetchCurCell(CellType.String, style)?.SetCellValue(value); }