I'm trying to use external workbook's data and show it at the chart. I tried like this:
Workbook externalWorkbook = new XSSFWorkbook(@"..\SomeFolder\ExternalWorkbook.xls");
Sheet extSheet = externalWorkbook.GetSheetAt(0);
Chart chart = drawing.CreateChart(anchor);
LineChartData data = chart.getChartDataFactory.CreateLineChartData();
ChartAxis bottomAxis = chart.ChartAxisFactory.CreateCategoryAxis(AxisPosition.Bottom);
ValueAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left);
ChartDataSource<Number> xs = DataSources.FromNumericCellRange(extSheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1));
ChartDataSource<Number> ys1 = DataSources.FromNumericCellRange(extSheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1));
var s1 = data.AddSeries(xs, ys1);
s1.SetTitle(serie1);
chart.Plot(data, bottomAxis, leftAxis);
But it doesn't working properly, so at the end, at Excel file in the chart property I have something like:
Instead of:
And obviously it doesn't working normally.
So how do you think, what I'm doing wrong? Maybe I should use some specific function in such case?
Is it even possible to use data from external workbook at the chart with poi apache?