Example #1
0
  /** Writes a XLS (Excel workbook) representation of the given Grid to the given OutputStream. */
  public static void toXls(Grid grid, OutputStream out) throws Exception {
    WritableWorkbook workbook = ExcelUtils.openWorkbook(out);

    String sheetName =
        CodecUtils.filenameEncode(
            StringUtils.defaultIfEmpty(grid.getTitle(), XLS_SHEET_PREFIX + 1));

    toXlsInternal(grid, workbook, sheetName, 0);

    workbook.write();
    workbook.close();
  }
Example #2
0
  /**
   * Writes a XLS (Excel workbook) representation of the given list of Grids to the given
   * OutputStream.
   */
  public static void toXls(List<Grid> grids, OutputStream out) throws Exception {
    WritableWorkbook workbook = ExcelUtils.openWorkbook(out);

    for (int i = 0; i < grids.size(); i++) {
      Grid grid = grids.get(i);

      String sheetName =
          CodecUtils.filenameEncode(
              StringUtils.defaultIfEmpty(grid.getTitle(), XLS_SHEET_PREFIX + (i + 1)));

      toXlsInternal(grid, workbook, sheetName, i);
    }

    workbook.write();
    workbook.close();
  }