Lines 44-49
Link Here
|
44 |
import org.apache.poi.hssf.record.WindowTwoRecord; |
44 |
import org.apache.poi.hssf.record.WindowTwoRecord; |
45 |
import org.apache.poi.hssf.record.aggregates.DataValidityTable; |
45 |
import org.apache.poi.hssf.record.aggregates.DataValidityTable; |
46 |
import org.apache.poi.hssf.record.formula.Ptg; |
46 |
import org.apache.poi.hssf.record.formula.Ptg; |
|
|
47 |
import org.apache.poi.hssf.record.formula.AreaPtg; |
47 |
import org.apache.poi.hssf.record.formula.RefPtg; |
48 |
import org.apache.poi.hssf.record.formula.RefPtg; |
48 |
import org.apache.poi.hssf.util.CellRangeAddress; |
49 |
import org.apache.poi.hssf.util.CellRangeAddress; |
49 |
import org.apache.poi.hssf.util.PaneInformation; |
50 |
import org.apache.poi.hssf.util.PaneInformation; |
Lines 1282-1287
Link Here
|
1282 |
Ptg[] ptgs = FormulaParser.parse(c.getCellFormula(), workbook); |
1283 |
Ptg[] ptgs = FormulaParser.parse(c.getCellFormula(), workbook); |
1283 |
boolean changed = false; |
1284 |
boolean changed = false; |
1284 |
for(int i=0; i<ptgs.length; i++) { |
1285 |
for(int i=0; i<ptgs.length; i++) { |
|
|
1286 |
// single reference, like A1 |
1285 |
if(ptgs[i] instanceof RefPtg) { |
1287 |
if(ptgs[i] instanceof RefPtg) { |
1286 |
RefPtg rptg = (RefPtg)ptgs[i]; |
1288 |
RefPtg rptg = (RefPtg)ptgs[i]; |
1287 |
if(startRow <= rptg.getRowAsInt() && |
1289 |
if(startRow <= rptg.getRowAsInt() && |
Lines 1291-1296
Link Here
|
1291 |
changed = true; |
1293 |
changed = true; |
1292 |
} |
1294 |
} |
1293 |
} |
1295 |
} |
|
|
1296 |
// area refence, like A1:A4 |
1297 |
if(ptgs[i] instanceof AreaPtg) { |
1298 |
AreaPtg aptg = (AreaPtg)ptgs[i]; |
1299 |
if(startRow <= aptg.getFirstRow() && |
1300 |
aptg.getFirstRow() <= endRow) { |
1301 |
// First row of area references a row that moved |
1302 |
aptg.setFirstRow(aptg.getFirstRow() + n); |
1303 |
changed = true; |
1304 |
} |
1305 |
if(startRow <= aptg.getLastRow() && |
1306 |
aptg.getLastRow() <= endRow) { |
1307 |
// Last row of area references a row that moved |
1308 |
aptg.setLastRow(aptg.getLastRow() + n); |
1309 |
changed = true; |
1310 |
} |
1311 |
} |
1312 |
|
1294 |
} |
1313 |
} |
1295 |
// If any references were changed, then |
1314 |
// If any references were changed, then |
1296 |
// re-create the formula string |
1315 |
// re-create the formula string |