title: Not getting all values of a single column in a line or scatter chart diagram using Apache poi
body: <p>In a excel file named "chart.xlsx" i have these data as follows-</p>
  
  <p>name  age  bloodgrp</p>
  
  <p>ad  14  a+</p>
  
  <p>as  42  o+</p>
  
  <p>sd  21  o-</p>
  
  <p>df  55  ab-</p>
  
  <p>fg  44  a-</p>
  
  <p>gh  87  b-</p>
  
  <p>hj  26  b+</p>
  
  <p>jk  24  ab+</p>
  
  <p>kl  28  b-</p>
  
  <p>i read these data using apache poi and i want to plot a line chart/ scatter chart in a excel file .</p>
  
  <pre><code>package tkl;
  import java.io.*;
  import java.util.*;
  import org.apache.poi.ss.usermodel.*;
  import org.apache.poi.ss.usermodel.charts.*;
  import org.apache.poi.ss.util.CellRangeAddress;
  import org.apache.poi.xssf.usermodel.*;
  
  
  public class DemoTrendTest {
  
  
  public static void main(String[] args) {
      // TODO Auto-generated method stub
      try{
      FileInputStream fis= new FileInputStream(new File("D:\\Chart.xlsx"));
      XSSFWorkbook wb= new XSSFWorkbook(fis);
  
      XSSFSheet s= wb.getSheet("a");
      Iterator &lt;Row&gt; rowIterator = s.iterator();
      while (rowIterator.hasNext())
      {
          Row row = rowIterator.next();
          //For each row, iterate through all the columns
          Iterator&lt;Cell&gt; cellIterator = row.cellIterator();
  
          while (cellIterator.hasNext())
          {
              Cell cell = cellIterator.next();
              if(cell.getCellType()== Cell.CELL_TYPE_NUMERIC)
              {
                  System.out.print(cell.getNumericCellValue() + "\t");
              }
  
          }
  
      }
  
      Drawing drawing = s.createDrawingPatriarch();
      ClientAnchor anchor= drawing.createAnchor(0, 0, 0, 0, 5, 4, 14, 20);
      Chart chart = drawing.createChart(anchor);
      ChartLegend legend = chart.getOrCreateLegend();
      legend.setPosition(LegendPosition.BOTTOM);
      ScatterChartData data = chart.getChartDataFactory().createScatterChartData();
      ValueAxis bottomAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM);
      ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
      leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
      ChartDataSource&lt;Number&gt; xs = DataSources.fromNumericCellRange(s, new CellRangeAddress(0, 0, 0, 2));
      ChartDataSource&lt;Number&gt; ys2 = DataSources.fromNumericCellRange(s, new CellRangeAddress(1, 10, 1,1));
  
  //actually should get =SERIES(a!$B$1,,a!$B$2:$B$10,1) but getting =SERIES(,a!$A$1:$J$1,a!$B$2:$B$11,1)
  
      data.addSerie(xs, ys2);
      chart.plot(data, bottomAxis, leftAxis);
      FileOutputStream fileOut = new FileOutputStream("D://1chart.xlsx");
      wb.write(fileOut);
      fileOut.close();
  
      }
      catch(Exception e)
      {
          e.printStackTrace();
      }
  }
  
  }
  </code></pre>
  
  <p>i want to plot 14,42,21, 55,44,87,26,24,28 data in the chart. the problem i'm facing that only first  3 values are taking in the chart. i'm getting =SERIES(,a!$A$1:$J$1,a!$B$2:$B$11,1) but i want =SERIES(a!$B$1,,a!$B$2:$B$10,1). How can i get all the values in the chart? Can anyone help me out. </p>