-
New Feature
-
Resolution: Done
-
Normal
-
None
-
None
-
None
-
None
Use Case
When populating data into cells, app developers usually need to set multiple cells with a java bean. The current usage:
Ranges.range(sheet, START_ROW + index, 2).setCellValue(s.getId()); Ranges.range(sheet, START_ROW + index, 3).setCellValue(s.getFormName()); Ranges.range(sheet, START_ROW + index, 4).setCellValue(s.getOwner()); Ranges.range(sheet, START_ROW + index, 5).setCellValue(s.getState().toString()); Ranges.range(sheet, START_ROW + index, 6).setCellValue(s.getLastUpdate());
problems
Duplicate code to create many Range objects
Proposed Solution
A helper method can set multiple cells at once can save a developer's effort.
/** fill specified multiple values cell by cell in one row starting from the left-top corner cell of this Range, then fill the next cell on the right, e.g. A1, B1, C1... */ public void setCellValuesInRow(Object... values){ } /** fill multiple values cell by cell in one column starting from the left-top corner cell of this Range, then fill the next cell on the right, e.g. A1, A2, A3... */ public void setCellValuesInColumn(Object... values){ }
- It should treat a merged cell as one cell. For example, setting 3 values (v1, v2, v3) into 3 cells in a row: A1, B1:C1, D1. The method should know B1:C1 is a merged cell and set v3 into D1 instead of C1.
usages
range.setCellValuesInRow(s.getId(), s.getFormName(), s.getOwner()); String [] values; // fill values range.setCellValuesInColumn(values);