Пример #1
0
        public void TestGetCharts()
        {
            XSSFWorkbook wb = XSSFTestDataSamples.OpenSampleWorkbook("chart_sheet.xlsx");

            XSSFSheet      ns = (XSSFSheet)wb.GetSheetAt(0);
            XSSFChartSheet cs = (XSSFChartSheet)wb.GetSheetAt(2);

            Assert.AreEqual(0, (ns.CreateDrawingPatriarch() as XSSFDrawing).GetCharts().Count);
            Assert.AreEqual(1, (cs.CreateDrawingPatriarch() as XSSFDrawing).GetCharts().Count);

            XSSFChart chart = (cs.CreateDrawingPatriarch() as XSSFDrawing).GetCharts()[0];

            Assert.AreEqual(null, chart.GetTitle());
        }
Пример #2
0
        public void TestGetCharts()
        {
            XSSFWorkbook wb = XSSFTestDataSamples.OpenSampleWorkbook("WithThreeCharts.xlsx");

            XSSFSheet s1 = (XSSFSheet)wb.GetSheetAt(0);
            XSSFSheet s2 = (XSSFSheet)wb.GetSheetAt(1);
            XSSFSheet s3 = (XSSFSheet)wb.GetSheetAt(2);

            Assert.AreEqual(0, (s1.CreateDrawingPatriarch() as XSSFDrawing).GetCharts().Count);
            Assert.AreEqual(2, (s2.CreateDrawingPatriarch() as XSSFDrawing).GetCharts().Count);
            Assert.AreEqual(1, (s3.CreateDrawingPatriarch() as XSSFDrawing).GetCharts().Count);

            // Check the titles
            XSSFChart chart = (s2.CreateDrawingPatriarch() as XSSFDrawing).GetCharts()[(0)];

            Assert.AreEqual(null, chart.GetTitle());

            chart = (s2.CreateDrawingPatriarch() as XSSFDrawing).GetCharts()[(1)];
            Assert.AreEqual("Pie Chart Title Thingy", chart.GetTitle().String);

            chart = (s3.CreateDrawingPatriarch() as XSSFDrawing).GetCharts()[(0)];
            Assert.AreEqual("Sheet 3 Chart with Title", chart.GetTitle().String);
        }