示例#1
0
        public void TestPopulateNew()
        {
            XSSFWorkbook wb = new XSSFWorkbook();
            StylesTable  st = wb.GetStylesSource();

            Assert.IsNotNull(st.GetCTStylesheet());
            Assert.AreEqual(1, st.GetXfsSize());
            Assert.AreEqual(1, st.GetStyleXfsSize());
            Assert.AreEqual(0, st.GetNumberFormatSize());

            int nf1 = st.PutNumberFormat("yyyy-mm-dd");
            int nf2 = st.PutNumberFormat("yyyy-mm-DD");

            Assert.AreEqual(nf1, st.PutNumberFormat("yyyy-mm-dd"));

            st.PutStyle(new XSSFCellStyle(st));

            // Save and re-load
            st = ((XSSFWorkbook)XSSFTestDataSamples.WriteOutAndReadBack(wb)).GetStylesSource();

            Assert.IsNotNull(st.GetCTStylesheet());
            Assert.AreEqual(2, st.GetXfsSize());
            Assert.AreEqual(1, st.GetStyleXfsSize());
            Assert.AreEqual(2, st.GetNumberFormatSize());

            Assert.AreEqual("yyyy-mm-dd", st.GetNumberFormatAt(nf1));
            Assert.AreEqual(nf1, st.PutNumberFormat("yyyy-mm-dd"));
            Assert.AreEqual(nf2, st.PutNumberFormat("yyyy-mm-DD"));
        }
示例#2
0
        public void doTestExisting(StylesTable st)
        {
            // Check contents
            Assert.IsNotNull(st.GetCTStylesheet());
            Assert.AreEqual(11, st.GetXfsSize());
            Assert.AreEqual(1, st.GetStyleXfsSize());
            Assert.AreEqual(8, st.GetNumberFormatSize());

            Assert.AreEqual(2, st.GetFonts().Count);
            Assert.AreEqual(2, st.GetFills().Count);
            Assert.AreEqual(1, st.GetBorders().Count);

            Assert.AreEqual("yyyy/mm/dd", st.GetNumberFormatAt(165));
            Assert.AreEqual("yy/mm/dd", st.GetNumberFormatAt(167));

            Assert.IsNotNull(st.GetStyleAt(0));
            Assert.IsNotNull(st.GetStyleAt(1));
            Assert.IsNotNull(st.GetStyleAt(2));

            Assert.AreEqual(0, st.GetStyleAt(0).DataFormat);
            Assert.AreEqual(14, st.GetStyleAt(1).DataFormat);
            Assert.AreEqual(0, st.GetStyleAt(2).DataFormat);
            Assert.AreEqual(165, st.GetStyleAt(3).DataFormat);

            Assert.AreEqual("yyyy/mm/dd", st.GetStyleAt(3).GetDataFormatString());
        }
示例#3
0
        public void doTestExisting(StylesTable st)
        {
            // Check contents
            Assert.IsNotNull(st.GetCTStylesheet());
            Assert.AreEqual(11, st._GetXfsSize());
            Assert.AreEqual(1, st._GetStyleXfsSize());
            Assert.AreEqual(8, st._GetNumberFormatSize());

            Assert.AreEqual(2, st.GetFonts().Count);
            Assert.AreEqual(2, st.GetFills().Count);
            Assert.AreEqual(1, st.GetBorders().Count);

            Assert.AreEqual("yyyy/mm/dd", st.GetNumberFormatAt(165));
            Assert.AreEqual("yy/mm/dd", st.GetNumberFormatAt(167));

            Assert.IsNotNull(st.GetStyleAt(0));
            Assert.IsNotNull(st.GetStyleAt(1));
            Assert.IsNotNull(st.GetStyleAt(2));

            Assert.AreEqual(0, st.GetStyleAt(0).DataFormat);
            Assert.AreEqual(14, st.GetStyleAt(1).DataFormat);
            Assert.AreEqual(0, st.GetStyleAt(2).DataFormat);
            Assert.AreEqual(165, st.GetStyleAt(3).DataFormat);

            Assert.AreEqual("yyyy/mm/dd", st.GetStyleAt(3).GetDataFormatString());
        }
示例#4
0
        public void TestCreateSaveLoad()
        {
            XSSFWorkbook wb = new XSSFWorkbook();
            StylesTable  st = wb.GetStylesSource();

            Assert.IsNotNull(st.GetCTStylesheet());
            Assert.AreEqual(1, st.GetXfsSize());
            Assert.AreEqual(1, st.GetStyleXfsSize());
            Assert.AreEqual(0, st.GetNumberFormatSize());

            st = ((XSSFWorkbook)XSSFTestDataSamples.WriteOutAndReadBack(wb)).GetStylesSource();

            Assert.IsNotNull(st.GetCTStylesheet());
            Assert.AreEqual(1, st.GetXfsSize());
            Assert.AreEqual(1, st.GetStyleXfsSize());
            Assert.AreEqual(0, st.GetNumberFormatSize());
        }
示例#5
0
        public void TestCreateNew()
        {
            StylesTable st = new StylesTable();

            // Check defaults
            Assert.IsNotNull(st.GetCTStylesheet());
            Assert.AreEqual(1, st.GetXfsSize());
            Assert.AreEqual(1, st.GetStyleXfsSize());
            Assert.AreEqual(0, st.GetNumberFormatSize());
        }
示例#6
0
        public void TestCreateNew()
        {
            StylesTable st = new StylesTable();

            // Check defaults
            Assert.IsNotNull(st.GetCTStylesheet());
            Assert.AreEqual(1, st._GetXfsSize());
            Assert.AreEqual(1, st._GetStyleXfsSize());
            Assert.AreEqual(0, st._GetNumberFormatSize());
        }
示例#7
0
        public void SetUp()
        {
            stylesTable = new StylesTable();

            ctStylesheet = stylesTable.GetCTStylesheet();

            ctBorderA = new CT_Border();
            XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA);
            long borderId = stylesTable.PutBorder(borderA);
            Assert.AreEqual(1, borderId);

            XSSFCellBorder borderB = new XSSFCellBorder();
            Assert.AreEqual(1, stylesTable.PutBorder(borderB));

            ctFill = new CT_Fill();
            XSSFCellFill fill = new XSSFCellFill(ctFill);
            long fillId = stylesTable.PutFill(fill);
            Assert.AreEqual(2, fillId);

            ctFont = new CT_Font();
            XSSFFont font = new XSSFFont(ctFont);
            long fontId = stylesTable.PutFont(font);
            Assert.AreEqual(1, fontId);

            cellStyleXf = ctStylesheet.AddNewCellStyleXfs().AddNewXf();
            cellStyleXf.borderId = 1;
            cellStyleXf.fillId = 1;
            cellStyleXf.fontId = 1;

            cellXfs = ctStylesheet.AddNewCellXfs();
            cellXf = cellXfs.AddNewXf();
            cellXf.xfId = (1);
            cellXf.borderId = (1);
            cellXf.fillId = (1);
            cellXf.fontId = (1);
            stylesTable.PutCellStyleXf(cellStyleXf);
            stylesTable.PutCellXf(cellXf);
            cellStyle = new XSSFCellStyle(1, 1, stylesTable, null);

            Assert.IsNotNull(stylesTable.GetFillAt(1).GetCTFill().patternFill);
            Assert.AreEqual(ST_PatternType.darkGray, stylesTable.GetFillAt(1).GetCTFill().patternFill.patternType);
        }