https://bz.apache.org/bugzilla/show_bug.cgi?id=59705

--- Comment #1 from Chenna Kesavarao <chenna...@intellicus.com> ---
i have updated code accordingly to fix this issue.

i have created a new method XSSFPivotTable.addColumnLabel(int columnIndex) and
changed the names of existing XSSFPivotTable.addColumnLabel() methods to
XSSFPivotTable.addValueLabel()

--------------------------------------------
New method, which i have added
---------------------------------------
  /**
     * Add a column label using data from the given column.
     * @param columnIndex the index of the column to be used as column label.
     */
    @Beta
    public void addColumnLabel(int columnIndex) {
        AreaReference pivotArea = getPivotArea();
        int lastRowIndex = pivotArea.getLastCell().getRow() -
pivotArea.getFirstCell().getRow();
        int lastColIndex = pivotArea.getLastCell().getCol() -
pivotArea.getFirstCell().getCol();

        if(columnIndex > lastColIndex) {
            throw new IndexOutOfBoundsException();
        }
        CTPivotFields pivotFields = pivotTableDefinition.getPivotFields();

        CTPivotField pivotField = CTPivotField.Factory.newInstance();
        CTItems items = pivotField.addNewItems();

        pivotField.setAxis(STAxis.AXIS_COL);
        pivotField.setShowAll(false);
        for(int i = 0; i <= lastRowIndex; i++) {
            items.addNewItem().setT(STItemType.DEFAULT);
        }
        items.setCount(items.sizeOfItemArray());
        pivotFields.setPivotFieldArray(columnIndex, pivotField);

        CTColFields colFields;
        if(pivotTableDefinition.getColFields() != null) {
            colFields = pivotTableDefinition.getColFields();
        } else {
            colFields = pivotTableDefinition.addNewColFields();
        }

        colFields.addNewField().setX(columnIndex);
        colFields.setCount(colFields.sizeOfFieldArray());
    }



--------------------------------------------------
Change of previous existing XSSFPivotTable.addColumnLabel methods to
XSSFPivotTable.addValueLabel
-----------------------------------------------------

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to