Hello Alan,

The list of things to consider when moving cells is quite extensive.
There is already a bugzilla discussing this for the case of shifting
rows: https://issues.apache.org/bugzilla/show_bug.cgi?id=46742  (Note
- POI has not implemented everything yet, but we should try to have
consistent behaviour when shifting columns).

Some steps have already been taken to generalise treatment of these
issues for shifting rows / columns or any arbitrary region. The class
"FormulaShifter" is an abstraction that deals with all of the formula
related issues.  Any method which currently takes FormulaShifter as a
parameter will be perfectly reusable for column moves as well.
However, we need a new method "FormulaShifter.createForColumnShift(int
externSheetIndex, int firstMovedColIndex, int lastMovedColIndex, int
numberOfColsToMove)"



Take a look at the existing method "HSSFSheet.shiftRows(int startRow,
int endRow, int n)".  You could make a new method
"HSSFSheet.shiftColumns(int startColumn, int endColumn, int n)" using
your code in pastebin.com.  With this new general method, the two use
cases you describe are trivial to implement:
void insertColumn(HSSFSheet s, int columnIndex) {
  s.shiftColumns(columnIndex, 254, 1);
}
void deleteColumn(HSSFSheet s, int columnIndex) {
  s.shiftColumns(columnIndex+1, 255, -1);
}


hope this helps,
-josh

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to