Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public void TestApplyFontWithStyles()
        {
            XSSFRichTextString rt = new XSSFRichTextString("Apache POI");

            StylesTable tbl = new StylesTable();
            rt.SetStylesTableReference(tbl);

            try
            {
                rt.ApplyFont(0, 10, (short)1);
                Assert.Fail("Fails without styles in the table");
            }
            catch (ArgumentOutOfRangeException e)
            {
                // expected
            }

            tbl.PutFont(new XSSFFont());
            rt.ApplyFont(0, 10, (short)1);
            rt.ApplyFont((short)1);
        }
Ejemplo n.º 3
0
 ///**
 // * Perform a registration of ourselves 
 // *  to the style table
 // */
 public long RegisterTo(StylesTable styles)
 {
     this._themes = styles.GetTheme();
     short idx = (short)styles.PutFont(this, true);
     this._index = idx;
     return idx;
 }