Пример #1
0
 public ReportContainer(File summaryCsvFile) {
   super();
   try {
     Table csv = Table.readTable(summaryCsvFile.getAbsolutePath());
     if (csv.numColumns() == 2) {
       initPieChart(csv);
     }
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (UnsupportedEncodingException e) {
     e.printStackTrace();
   }
 }
Пример #2
0
  public WAbstractItemModel readFromCsv(Table csv) {
    WAbstractItemModel model = new WStandardItemModel();
    for (int r = 0; r < csv.numRows(); r++) {
      if (r != 0) model.insertRow(r - 1);

      for (int c = 0; c < csv.numColumns(); c++) {
        String value = csv.valueAt(c, r);
        if (r == 0) {
          model.insertColumn(c);
          model.setHeaderData(c, Orientation.Horizontal, value);
        } else {
          try {
            Double d = Double.valueOf(value);
            model.setData(r - 1, c, d);
          } catch (NumberFormatException e) {
            model.setData(r - 1, c, value);
          }
        }
      }
    }
    return model;
  }