View | Details | Raw Unified | Return to bug 59355
Collapse All | Expand All

(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java (-1 / +2 lines)
Lines 355-361 Link Here
355
        }
355
        }
356
        CTDataField dataField = dataFields.addNewDataField();
356
        CTDataField dataField = dataFields.addNewDataField();
357
        dataField.setSubtotal(STDataConsolidateFunction.Enum.forInt(function.getValue()));
357
        dataField.setSubtotal(STDataConsolidateFunction.Enum.forInt(function.getValue()));
358
        Cell cell = getDataSheet().getRow(pivotArea.getFirstCell().getRow()).getCell(columnIndex);
358
        Cell cell = getDataSheet().getRow(pivotArea.getFirstCell().getRow())
359
                .getCell(pivotArea.getFirstCell().getCol() + columnIndex);
359
        cell.setCellType(Cell.CELL_TYPE_STRING);
360
        cell.setCellType(Cell.CELL_TYPE_STRING);
360
        dataField.setName(valueFieldName);
361
        dataField.setName(valueFieldName);
361
        dataField.setFld(columnIndex);
362
        dataField.setFld(columnIndex);
(-)src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java (+57 lines)
Lines 32-37 Link Here
32
32
33
public class TestXSSFPivotTable extends TestCase {
33
public class TestXSSFPivotTable extends TestCase {
34
    private XSSFPivotTable pivotTable;
34
    private XSSFPivotTable pivotTable;
35
    private XSSFPivotTable offsetPivotTable;
36
    private Cell offsetOuterCell;
35
    
37
    
36
    @Override
38
    @Override
37
    public void setUp(){
39
    public void setUp(){
Lines 71-76 Link Here
71
73
72
        AreaReference source = new AreaReference("A1:C2");
74
        AreaReference source = new AreaReference("A1:C2");
73
        pivotTable = sheet.createPivotTable(source, new CellReference("H5"));
75
        pivotTable = sheet.createPivotTable(source, new CellReference("H5"));
76
        
77
        XSSFSheet offsetSheet = (XSSFSheet) wb.createSheet();
78
        
79
        Row tableRow_1 = offsetSheet.createRow(1);
80
        offsetOuterCell = tableRow_1.createCell(1);
81
        offsetOuterCell.setCellValue(-1);
82
        Cell tableCell_1_1 = tableRow_1.createCell(2);
83
        tableCell_1_1.setCellValue("Row #");
84
        Cell tableCell_1_2 = tableRow_1.createCell(3);
85
        tableCell_1_2.setCellValue("Exponent");
86
        Cell tableCell_1_3 = tableRow_1.createCell(4);
87
        tableCell_1_3.setCellValue("10^Exponent");
88
        
89
        Row tableRow_2 = offsetSheet.createRow(2);
90
        Cell tableCell_2_1 = tableRow_2.createCell(2);
91
        tableCell_2_1.setCellValue(0);
92
        Cell tableCell_2_2 = tableRow_2.createCell(3);
93
        tableCell_2_2.setCellValue(0);
94
        Cell tableCell_2_3 = tableRow_2.createCell(4);
95
        tableCell_2_3.setCellValue(1);
96
        
97
        Row tableRow_3= offsetSheet.createRow(3);
98
        Cell tableCell_3_1 = tableRow_3.createCell(2);
99
        tableCell_3_1.setCellValue(1);
100
        Cell tableCell_3_2 = tableRow_3.createCell(3);
101
        tableCell_3_2.setCellValue(1);
102
        Cell tableCell_3_3 = tableRow_3.createCell(4);
103
        tableCell_3_3.setCellValue(10);
104
        
105
        Row tableRow_4 = offsetSheet.createRow(4);
106
        Cell tableCell_4_1 = tableRow_4.createCell(2);
107
        tableCell_4_1.setCellValue(2);
108
        Cell tableCell_4_2 = tableRow_4.createCell(3);
109
        tableCell_4_2.setCellValue(2);
110
        Cell tableCell_4_3 = tableRow_4.createCell(4);
111
        tableCell_4_3.setCellValue(100);
112
        
113
        AreaReference offsetSource = new AreaReference(new CellReference("C2"), new CellReference("E4"));
114
        offsetPivotTable = offsetSheet.createPivotTable(offsetSource, new CellReference("C6"));
74
    }
115
    }
75
116
76
    /**
117
    /**
Lines 268-271 Link Here
268
        }
309
        }
269
        fail();
310
        fail();
270
    }
311
    }
312
    
313
    /**
314
     * Verify that the Pivot Table operates only within the referenced area, even when the
315
     * first column of the referenced area is not index 0.
316
     */
317
    public void testAddDataColumnWithOffsetData() {
318
        offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1);
319
        assertEquals(Cell.CELL_TYPE_NUMERIC, offsetOuterCell.getCellType());
320
        
321
        try {
322
            offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 0);
323
        } catch(NullPointerException e) {
324
            fail();
325
        }
326
        return;
327
    }
271
}
328
}

Return to bug 59355