Esempio n. 1
0
        private NPOI.SS.UserModel.Cell CreateCell(Cell cell, Row currentRow, int columnOrdinal)
        {
            var nCell = currentRow.CreateCell(columnOrdinal, CellType.STRING);
            nCell.CellStyle = GetCellStyle(cell);

            return nCell;
        }
        public void RichTextCell_should_have_default_value()
        {
            Cell target = new Cell();

            Assert.IsFalse(target.IsBold);
            Assert.AreEqual(Color.Empty, target.BackgroundColor);
            Assert.IsNotNull(target.Borders);
        }
Esempio n. 3
0
        private CellStyle GetCellStyle(Cell cell)
        {
            CellStyle style = _sheet.Workbook.CreateCellStyle();

            SetBold(cell, style);

            SetColor(cell, style);

            SetBorder(cell, style);

            return style;
        }
Esempio n. 4
0
 private void SetColor(Cell cell, CellStyle style)
 {
     if (cell.BackgroundColor != Color.Empty && cell.BackgroundColor != Color.White)
     {
         style.FillForegroundColor = cell.BackgroundColor.ToNPOIColor();
         style.FillPattern = FillPatternType.SOLID_FOREGROUND;
     }
 }
Esempio n. 5
0
        private void SetBorder(Cell cell, CellStyle style)
        {
            foreach (var border in cell.Borders)
            {
                if (border.Location != BorderLocation.None)
                {
                    switch (border.Location)
                    {
                        case BorderLocation.Top:
                            style.BorderTop = border.Style.NPOIBorderType();
                            style.TopBorderColor = border.Color.ToNPOIColor();
                            break;

                        case BorderLocation.Bottom:
                            style.BorderBottom = border.Style.NPOIBorderType();
                            style.BottomBorderColor = border.Color.ToNPOIColor();
                            break;

                        case BorderLocation.Left:
                            style.BorderLeft = border.Style.NPOIBorderType();
                            style.LeftBorderColor = border.Color.ToNPOIColor();
                            break;

                        case BorderLocation.Right:
                            style.BorderRight = border.Style.NPOIBorderType();
                            style.RightBorderColor = border.Color.ToNPOIColor();
                            break;

                        default:
                            throw new InvalidOperationException("Trying to set border for non-existent side");

                    }
                }
            }
        }
Esempio n. 6
0
 private void SetBold(Cell cell, CellStyle style)
 {
     if (cell.IsBold)
     {
         Font font = _sheet.Workbook.CreateFont();
         font.Boldweight = (short)FontBoldWeight.BOLD;
         style.SetFont(font);
     }
 }
 public void Cell_should_have_default_values()
 {
     Cell target = new Cell();
     Assert.AreEqual(1, target.ColumnSpan);
 }