Esempio n. 1
0
        public void TestPopulateExisting()
        {
            XSSFWorkbook workbook = XSSFTestDataSamples.OpenSampleWorkbook(testFile);

            Assert.IsNotNull(workbook.GetStylesSource());

            StylesTable st = workbook.GetStylesSource();

            Assert.AreEqual(11, st._GetXfsSize());
            Assert.AreEqual(1, st._GetStyleXfsSize());
            Assert.AreEqual(8, 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 = ((XSSFWorkbook)XSSFTestDataSamples.WriteOutAndReadBack(workbook)).GetStylesSource();

            Assert.AreEqual(11, st._GetXfsSize());
            Assert.AreEqual(1, st._GetStyleXfsSize());
            Assert.AreEqual(10, 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"));
        }
Esempio n. 2
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"));
        }
Esempio n. 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());
        }
Esempio n. 4
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());
        }
Esempio n. 5
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());
        }
Esempio n. 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());
        }
Esempio n. 7
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());
        }