Lines 390-396
Link Here
|
390 |
} |
390 |
} |
391 |
|
391 |
|
392 |
public void testShiftRows() { |
392 |
public void testShiftRows() { |
393 |
|
|
|
394 |
Workbook wb = _testDataProvider.createWorkbook(); |
393 |
Workbook wb = _testDataProvider.createWorkbook(); |
395 |
Sheet sheet = wb.createSheet(); |
394 |
Sheet sheet = wb.createSheet(); |
396 |
|
395 |
|
Lines 403-432
Link Here
|
403 |
|
402 |
|
404 |
PatternFormatting patternFmt = rule1.createPatternFormatting(); |
403 |
PatternFormatting patternFmt = rule1.createPatternFormatting(); |
405 |
patternFmt.setFillBackgroundColor(IndexedColors.YELLOW.index); |
404 |
patternFmt.setFillBackgroundColor(IndexedColors.YELLOW.index); |
406 |
ConditionalFormattingRule [] cfRules = { rule1, }; |
|
|
407 |
|
405 |
|
|
|
406 |
ConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule( |
407 |
ComparisonOperator.BETWEEN, "SUM(A10:A15)", "1+SUM(B16:B30)"); |
408 |
BorderFormatting borderFmt = rule2.createBorderFormatting(); |
409 |
borderFmt.setBorderDiagonal((short) 2); |
410 |
|
408 |
CellRangeAddress [] regions = { |
411 |
CellRangeAddress [] regions = { |
409 |
new CellRangeAddress(2, 4, 0, 0), // A3:A5 |
412 |
new CellRangeAddress(2, 4, 0, 0), // A3:A5 |
410 |
}; |
413 |
}; |
411 |
sheetCF.addConditionalFormatting(regions, cfRules); |
414 |
sheetCF.addConditionalFormatting(regions, rule1); |
|
|
415 |
sheetCF.addConditionalFormatting(regions, rule2); |
412 |
|
416 |
|
413 |
// This row-shift should destroy the CF region |
417 |
// This row-shift should destroy the CF region |
414 |
sheet.shiftRows(10, 20, -9); |
418 |
sheet.shiftRows(10, 20, -9); |
415 |
assertEquals(0, sheetCF.getNumConditionalFormattings()); |
419 |
assertEquals(0, sheetCF.getNumConditionalFormattings()); |
416 |
|
420 |
|
417 |
// re-add the CF |
421 |
// re-add the CF |
418 |
sheetCF.addConditionalFormatting(regions, cfRules); |
422 |
sheetCF.addConditionalFormatting(regions, rule1); |
|
|
423 |
sheetCF.addConditionalFormatting(regions, rule2); |
419 |
|
424 |
|
420 |
// This row shift should only affect the formulas |
425 |
// This row shift should only affect the formulas |
421 |
sheet.shiftRows(14, 17, 8); |
426 |
sheet.shiftRows(14, 17, 8); |
422 |
ConditionalFormatting cf = sheetCF.getConditionalFormattingAt(0); |
427 |
ConditionalFormatting cf1 = sheetCF.getConditionalFormattingAt(0); |
423 |
assertEquals("SUM(A10:A23)", cf.getRule(0).getFormula1()); |
428 |
assertEquals("SUM(A10:A23)", cf1.getRule(0).getFormula1()); |
424 |
assertEquals("1+SUM(B24:B30)", cf.getRule(0).getFormula2()); |
429 |
assertEquals("1+SUM(B24:B30)", cf1.getRule(0).getFormula2()); |
|
|
430 |
ConditionalFormatting cf2 = sheetCF.getConditionalFormattingAt(1); |
431 |
assertEquals("SUM(A10:A23)", cf2.getRule(0).getFormula1()); |
432 |
assertEquals("1+SUM(B24:B30)", cf2.getRule(0).getFormula2()); |
425 |
|
433 |
|
426 |
sheet.shiftRows(0, 8, 21); |
434 |
sheet.shiftRows(0, 8, 21); |
427 |
cf = sheetCF.getConditionalFormattingAt(0); |
435 |
cf1 = sheetCF.getConditionalFormattingAt(0); |
428 |
assertEquals("SUM(A10:A21)", cf.getRule(0).getFormula1()); |
436 |
assertEquals("SUM(A10:A21)", cf1.getRule(0).getFormula1()); |
429 |
assertEquals("1+SUM(#REF!)", cf.getRule(0).getFormula2()); |
437 |
assertEquals("1+SUM(#REF!)", cf1.getRule(0).getFormula2()); |
|
|
438 |
cf2 = sheetCF.getConditionalFormattingAt(1); |
439 |
assertEquals("SUM(A10:A21)", cf2.getRule(0).getFormula1()); |
440 |
assertEquals("1+SUM(#REF!)", cf2.getRule(0).getFormula2()); |
430 |
} |
441 |
} |
431 |
|
442 |
|
432 |
protected void testRead(String filename){ |
443 |
protected void testRead(String filename){ |