Beispiel #1
0
 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);
     }
 }
Beispiel #2
0
 public BaseCell(string value, int columnWidth = 0, LayoutStyle style = null)
 {
     Value       = value;
     LayoutStyle = style;
     if (columnWidth > 0)
     {
         LayoutSet = new LayoutSet {
             ColumnWidth = columnWidth
         }
     }
     ;
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public BaseCell(string value, LayoutSet layoutSet = null, LayoutStyle style = null)
 {
     Value       = value;
     LayoutStyle = style;
     LayoutSet   = layoutSet;
 }
Beispiel #6
0
 public void WriteCell(decimal value, LayoutStyle style = null, bool zeroEmpty = false)
 {
     SetNumCell((double)value, style, zeroEmpty);
 }
Beispiel #7
0
 public void WriteCell(int value, LayoutStyle style = null, bool zeroEmpty = false)
 {
     SetNumCell(value, style, zeroEmpty);
 }
Beispiel #8
0
 public void WriteCell(string value, LayoutStyle style = null)
 {
     FetchCurCell(CellType.String, style)?.SetCellValue(value);
 }