Ejemplo n.º 1
0
        public void TestFormulaCache()
        {
            IWorkbook     wb      = new XSSFWorkbook();
            ISheet        sheet   = new SheetBuilder(wb, plotData).Build();
            IDrawing      Drawing = sheet.CreateDrawingPatriarch();
            IClientAnchor anchor  = Drawing.CreateAnchor(0, 0, 0, 0, 1, 1, 10, 30);
            IChart        chart   = Drawing.CreateChart(anchor);

            IChartAxis bottomAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Bottom);
            IChartAxis leftAxis   = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left);

            IScatterChartData scatterChartData =
                chart.ChartDataFactory.CreateScatterChartData();

            DataMarker         xMarker = new DataMarker(sheet, CellRangeAddress.ValueOf("A1:E1"));
            DataMarker         yMarker = new DataMarker(sheet, CellRangeAddress.ValueOf("A2:E2"));
            IScatterChartSerie serie   = scatterChartData.AddSerie(xMarker, yMarker);

            chart.Plot(scatterChartData, bottomAxis, leftAxis);

            XSSFScatterChartData.Serie xssfScatterSerie =
                (XSSFScatterChartData.Serie)serie;
            XSSFNumberCache yCache = xssfScatterSerie.LastCalculatedYCache;

            Assert.AreEqual(5, yCache.PointCount);
            Assert.AreEqual(4.0, yCache.GetValueAt(3), 0.00001);
            Assert.AreEqual(16.0, yCache.GetValueAt(5), 0.00001);
        }
Ejemplo n.º 2
0
        /**
         * Builds new numeric cache Container.
         * @param marker data marker to use for cache Evaluation
         * @param ctNumRef parent number reference
         * @return numeric cache instance
         */
        internal static XSSFNumberCache BuildCache(DataMarker marker, CT_NumRef ctNumRef)
        {
            CellRangeAddress range = marker.Range;
            int numOfPoints = range.NumberOfCells;

            if (numOfPoints == 0)
            {
                // Nothing to do.
                return null;
            }

            XSSFNumberCache cache = new XSSFNumberCache(ctNumRef.AddNewNumCache());
            cache.SetPointCount(numOfPoints);

            IWorkbook wb = marker.Sheet.Workbook;
            IFormulaEvaluator Evaluator = wb.GetCreationHelper().CreateFormulaEvaluator();

            CellWalk cellWalk = new CellWalk(marker);
            NumCacheCellHandler numCacheHandler = new NumCacheCellHandler(Evaluator, cache.ctNumData);
            cellWalk.Traverse(numCacheHandler);
            return cache;
        }
Ejemplo n.º 3
0
        /**
         * Builds new numeric cache Container.
         * @param marker data marker to use for cache Evaluation
         * @param ctNumRef parent number reference
         * @return numeric cache instance
         */
        internal static XSSFNumberCache BuildCache(DataMarker marker, CT_NumRef ctNumRef)
        {
            CellRangeAddress range = marker.Range;
            int numOfPoints        = range.NumberOfCells;

            if (numOfPoints == 0)
            {
                // Nothing to do.
                return(null);
            }

            XSSFNumberCache cache = new XSSFNumberCache(ctNumRef.AddNewNumCache());

            cache.SetPointCount(numOfPoints);

            IWorkbook         wb        = marker.Sheet.Workbook;
            IFormulaEvaluator Evaluator = wb.GetCreationHelper().CreateFormulaEvaluator();

            CellWalk            cellWalk        = new CellWalk(marker);
            NumCacheCellHandler numCacheHandler = new NumCacheCellHandler(Evaluator, cache.ctNumData);

            cellWalk.Traverse(numCacheHandler);
            return(cache);
        }