Example #1
0
        public void TestCTTableStyleInfo()
        {
            XSSFWorkbook outputWorkbook = new XSSFWorkbook();
            XSSFSheet    sheet          = outputWorkbook.CreateSheet() as XSSFSheet;

            //Create
            XSSFTable outputTable = sheet.CreateTable();

            outputTable.DisplayName = ("Test");
            CT_Table outputCTTable = outputTable.GetCTTable();

            //Style configurations
            CT_TableStyleInfo outputStyleInfo = outputCTTable.AddNewTableStyleInfo();

            outputStyleInfo.name = ("TableStyleLight1");
            outputStyleInfo.showColumnStripes = (false);
            outputStyleInfo.showRowStripes    = (true);

            XSSFWorkbook     inputWorkbook = XSSFTestDataSamples.WriteOutAndReadBack(outputWorkbook) as XSSFWorkbook;
            List <XSSFTable> tables        = (inputWorkbook.GetSheetAt(0) as XSSFSheet).GetTables();

            Assert.AreEqual(1, tables.Count, "Tables number");

            XSSFTable inputTable = tables[0];

            Assert.AreEqual(outputTable.DisplayName, inputTable.DisplayName, "Table display name");

            CT_TableStyleInfo inputStyleInfo = inputTable.GetCTTable().tableStyleInfo;

            Assert.AreEqual(outputStyleInfo.name, inputStyleInfo.name, "Style name");
            Assert.AreEqual(outputStyleInfo.showColumnStripes, inputStyleInfo.showColumnStripes, "Show column stripes");
            Assert.AreEqual(outputStyleInfo.showRowStripes, inputStyleInfo.showRowStripes, "Show row stripes");
        }
Example #2
0
        static void Main(string[] args)
        {
            XSSFWorkbook workbook = new XSSFWorkbook();
            XSSFSheet    sheet1   = (XSSFSheet)workbook.CreateSheet("Sheet1");

            sheet1.CreateRow(0).CreateCell(0).SetCellValue("This is a Sample");
            int x = 1;

            for (int i = 1; i <= 15; i++)
            {
                IRow row = sheet1.CreateRow(i);
                for (int j = 0; j < 15; j++)
                {
                    row.CreateCell(j).SetCellValue(x++);
                }
            }
            XSSFTable table = sheet1.CreateTable();

            table.Name        = "Tabella1";
            table.DisplayName = "Tabella1";

            FileStream sw = File.Create("test.xlsx");

            workbook.Write(sw);
            sw.Close();
        }
Example #3
0
        public void GetRowCount()
        {
            XSSFWorkbook wb      = new XSSFWorkbook();
            XSSFSheet    sh      = wb.CreateSheet() as XSSFSheet;
            XSSFTable    table   = sh.CreateTable() as XSSFTable;
            CT_Table     ctTable = table.GetCTTable();

            Assert.AreEqual(0, table.RowCount);
            ctTable.@ref = "B2:B2";
            // update cell references to clear the cache
            table.UpdateReferences();
            Assert.AreEqual(1, table.RowCount);
            ctTable.@ref = "B2:B12";
            // update cell references to clear the cache
            table.UpdateReferences();
            Assert.AreEqual(11, table.RowCount);
        }
Example #4
0
        public void GetCellReferences()
        {
            // make sure that cached start and end cell references
            // can be synchronized with the underlying CTTable
            XSSFWorkbook wb      = new XSSFWorkbook();
            XSSFSheet    sh      = wb.CreateSheet() as XSSFSheet;
            XSSFTable    table   = sh.CreateTable() as XSSFTable;
            CT_Table     ctTable = table.GetCTTable();

            ctTable.@ref = "B2:E8";
            Assert.AreEqual(new CellReference("B2"), table.StartCellReference);
            Assert.AreEqual(new CellReference("E8"), table.EndCellReference);
            // At this point start and end cell reference are cached
            // and may not follow changes to the underlying CTTable
            ctTable.@ref = "C1:M3";
            Assert.AreEqual(new CellReference("B2"), table.StartCellReference);
            Assert.AreEqual(new CellReference("E8"), table.EndCellReference);
            // Force a synchronization between CTTable and XSSFTable
            // start and end cell references
            table.UpdateReferences();
            Assert.AreEqual(new CellReference("C1"), table.StartCellReference);
            Assert.AreEqual(new CellReference("M3"), table.EndCellReference);
        }