public static int nextFreeColNumber(WritableSheet sheet) { if (sheet == null) return 0; int colCount = sheet.getColumns(); Cell[] cells; int i = 0; for (; i < colCount; i++) { cells = sheet.getColumn(i); for (Cell cell : cells) { if (cell.getContents() == null || cell.getContents().isEmpty()) return i; } } return i; }
public static void writeToCell(WritableSheet sheet, String value, int col, int row) { if (sheet == null) return; Label label = new Label(col, row, value); try { sheet.addCell(label); } catch (WriteException e) { e.printStackTrace(); } }