DataSet { String getCellRanges(String tablecellrange, boolean bFirstRowAsLabel, boolean bFirstColumnAsLabel, boolean rowAsDataSeries, Vector<String> seriesCellRange, Vector<String> legendCellAddr) { String labelCellRange = null; if (seriesCellRange == null) seriesCellRange = new Vector<String>(); else seriesCellRange.removeAllElements(); if (legendCellAddr == null) legendCellAddr = new Vector<String>(); else legendCellAddr.removeAllElements(); StringTokenizer st = new StringTokenizer(tablecellrange, ".:$ "); if (st.countTokens() < 3) return null; String sheettable = st.nextToken(); String begincell = st.nextToken(); String endcell = st.nextToken(); if (st.hasMoreTokens()) endcell = st.nextToken(); char beginColumn = begincell.charAt(0); char endColumn = endcell.charAt(0); int beginRow = Integer.parseInt(begincell.substring(1)); int endRow = Integer.parseInt(endcell.substring(1)); if (rowAsDataSeries) { int starti = beginRow + 1; if (!bFirstRowAsLabel) { labelCellRange = null; starti = beginRow; } else if (bFirstColumnAsLabel) labelCellRange = createCellRange(sheettable, beginRow, (char) (beginColumn + 1), beginRow, endColumn); else labelCellRange = createCellRange(sheettable, beginRow, beginColumn, beginRow, endColumn); for (int i = starti; i < endRow + 1; i++) { if (bFirstColumnAsLabel) seriesCellRange.add(createCellRange(sheettable, i, (char) (beginColumn + 1), i, endColumn)); else seriesCellRange.add(createCellRange(sheettable, i, beginColumn, i, endColumn)); if (bFirstColumnAsLabel) legendCellAddr.add(sheettable + "." + beginColumn + i); else legendCellAddr.add(null); } } else { char startch = (char) (beginColumn + 1); if (!bFirstColumnAsLabel) { labelCellRange = null; startch = beginColumn; } else if (bFirstRowAsLabel) labelCellRange = createCellRange(sheettable, beginRow + 1, beginColumn, endRow, beginColumn); else labelCellRange = createCellRange(sheettable, beginRow, beginColumn, endRow, beginColumn); for (char ch = startch; ch <= endColumn; ch++) { if (bFirstRowAsLabel) seriesCellRange.add(createCellRange(sheettable, beginRow + 1, ch, endRow, ch)); else seriesCellRange.add(createCellRange(sheettable, beginRow, ch, endRow, ch)); if (bFirstRowAsLabel) legendCellAddr.add(sheettable + "." + ch + beginRow); else legendCellAddr.add(null); } } return labelCellRange; } DataSet();  DataSet(String[] labels, String[] legends, double[][] data);  DataSet(CellRangeAddressList cellRangeAddress, SpreadsheetDocument spreadsheet, boolean bFirstRowAsLabel,
			boolean bFirstColumnAsLabel, boolean rowAsDataSeries); String getLocalTableCellRanges(int seriesCount, int labelLength, Vector<String> seriesCellRange,
			Vector<String> legendCellAddr); CellRangeAddressList getCellRangeAddress(); void appendDataSeries(String legend, double[] values); void insertDataSeries(int index, String legend, double[] values); void updateDataSeries(int index, double[] values); void updateDataSeries(String legend, int beginindex, double[] values); void removeDataSeries(int index); void removeDataSeries(String legend, int beginindex); int getIndexOfDataSeries(String legend, int beginindex); String getLegendByIndex(int index); void setLegendByIndex(int index, String legend); String getLabelByIndex(int index); void setLabelByIndex(int index, String label); String[] getLabels(); String[] getLegends(); boolean isFirstRowAsLabel(); boolean isFirstColumnAsLabel(); boolean isRowAsDataSeries(); boolean isLocalTable(); void setLocalTable(boolean isLocalTable); double[] getDataSeriesByIndex(int index); double[] getDataSeriesByLegend(String legend, int beginindex); Double[][] getLocalTableData(); String[] getLocalTableFirstRow(); String[] getLocalTableFirstColumn(); int getLengthOfDataSeries(int index); int getLengthOfDataSeries(String legend, int beginindex); int getMaxLengthOfDataSeries(); int getDataSeriesCount(); void setValues(String[] labels, String[] legends, double[][] data); void setValues(CellRangeAddressList cellRangeAddress, SpreadsheetDocument spreadsheet,
			boolean bFirstRowAsLabel, boolean bFirstColumnAsLabel, boolean rowAsDataSeries);  }
@Test public void testGetCellRanges() { Vector<String> seriesCellRange = new Vector<String>(); Vector<String> legendCellAddr = new Vector<String>(); DataSet ds = new DataSet(); String labelCellRange = ds.getCellRanges("A.A2:A.E21", false, true, false, seriesCellRange, legendCellAddr); Assert.assertEquals("A.A2:A.A21", labelCellRange); Assert.assertEquals(4, seriesCellRange.size()); Assert.assertEquals("A.B2:A.B21", seriesCellRange.firstElement()); Assert.assertEquals("A.E2:A.E21", seriesCellRange.lastElement()); Assert.assertEquals(4, legendCellAddr.size()); Assert.assertNull(legendCellAddr.firstElement()); Assert.assertNull(legendCellAddr.lastElement()); labelCellRange = ds.getCellRanges("A.A1:A.E21", true, true, true, seriesCellRange, legendCellAddr); Assert.assertEquals("A.B1:A.E1", labelCellRange); Assert.assertEquals(20, seriesCellRange.size()); Assert.assertEquals("A.B2:A.E2", seriesCellRange.firstElement()); Assert.assertEquals("A.B21:A.E21", seriesCellRange.lastElement()); Assert.assertEquals(20, legendCellAddr.size()); Assert.assertEquals("A.A2", legendCellAddr.firstElement()); Assert.assertEquals("A.A21", legendCellAddr.lastElement()); labelCellRange = ds.getCellRanges("A.B1:A.E21", true, false, false, seriesCellRange, legendCellAddr); Assert.assertNull(labelCellRange); Assert.assertEquals(4, seriesCellRange.size()); Assert.assertEquals("A.B2:A.B21", seriesCellRange.firstElement()); Assert.assertEquals("A.E2:A.E21", seriesCellRange.lastElement()); Assert.assertEquals(4, legendCellAddr.size()); Assert.assertEquals("A.B1", legendCellAddr.firstElement()); Assert.assertEquals("A.E1", legendCellAddr.lastElement()); labelCellRange = ds.getLocalTableCellRanges(4, 20, seriesCellRange, legendCellAddr); Assert.assertEquals("local-table.A2:local-table.A21", labelCellRange); Assert.assertEquals(4, seriesCellRange.size()); Assert.assertEquals("local-table.B2:local-table.B21", seriesCellRange.firstElement()); Assert.assertEquals("local-table.E2:local-table.E21", seriesCellRange.lastElement()); Assert.assertEquals(4, legendCellAddr.size()); Assert.assertEquals("local-table.B1", legendCellAddr.firstElement()); Assert.assertEquals("local-table.E1", legendCellAddr.lastElement()); }