Esempio n. 1
0
        public void CreateWorkbook()
        {
            var wb = ExcelExtension.CreateWorkbook();

            Assert.IsType <HSSFWorkbook>(wb);
            wb = ExcelExtension.CreateWorkbook(WorkbookStyle.HSSFWorkbook);
            Assert.IsType <HSSFWorkbook>(wb);
            wb = ExcelExtension.CreateWorkbook(WorkbookStyle.XSSFWorkbook);
            Assert.IsType <XSSFWorkbook>(wb);
        }
Esempio n. 2
0
        public void DefaultTitleStyleTest()
        {
            //默认设置标题列样式
            ExcelExtension.ConfigurationTitleCellStyle((cellStyle) =>
            {
                cellStyle.FillForegroundColor = HSSFColor.Green.Index;
                cellStyle.FillPattern         = FillPattern.SolidForeground;
                cellStyle.Alignment           = HorizontalAlignment.Center;
            });
            var excelTable        = new ExcelTable("TitleOne", "TitleTwo");
            var wb                = ExcelExtension.CreateWorkbook().AddData(excelTable);
            var titleRow          = wb.GetSheetAt(0).GetRow(0);
            var titleOneCellStyle = titleRow.GetCell(0).CellStyle;

            Assert.Equal(HSSFColor.Green.Index, titleOneCellStyle.FillForegroundColor);
            Assert.Equal(FillPattern.SolidForeground, titleOneCellStyle.FillPattern);
            Assert.Equal(HorizontalAlignment.Center, titleOneCellStyle.Alignment);
            var titleTwoCellStyle = titleRow.GetCell(1).CellStyle;

            Assert.Equal(HSSFColor.Green.Index, titleTwoCellStyle.FillForegroundColor);
            Assert.Equal(FillPattern.SolidForeground, titleTwoCellStyle.FillPattern);
            Assert.Equal(HorizontalAlignment.Center, titleTwoCellStyle.Alignment);
        }