Hi,
Could you Please help me in Solving the Below Problem. It’s very urgent. I am Facing the Problem like
Header is Showing in Black Color for Pivot excel outputs and But My requirement is like Display Header fields should based on applied pivot style. I have tried with different options like REPORT_1,NONE,TABLE_1 styles etc.… But its not working for me. I have commented those styles and i have applied Style sheet to the pivot Excel. after commenting below piece of code. I am facing Format issue.
pivotTable.setAutoFormatType(PivotTableAutoFormatType.REPORT_1)
Format Issue.PNG : After commenting the above code
Pivot Excel.PNG : Before Commenting the above code
I am attaching CSV file with values
Below is the code i am using for it.
import com.aspose.cells.*;
import java.util.*;
public class createpivot
{
public createpivot()
{
}
public static void main(String[] args)
{
try{
LoadOptions loadOptions = new LoadOptions(FileFormatType.CSV);
Workbook workbook = new Workbook("D:\\Aspose Files\\1008253_693_1.csv",loadOptions);
createpivot p=new createpivot();
p.CreateStaticReport(workbook);
workbook.save("D:\\Aspose Files\\693.xls",FileFormatType.EXCEL_97_TO_2003);
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void CreateStaticReport(Workbook workbook)
{
try{
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet worksheet = worksheets.add("Pivot sheet");
PivotTableCollection pivotTables = worksheet.getPivotTables();
//Adding a PivotTable to the worksheet
int index = pivotTables.add("=sheet1!$A$1:w$18924","A1","PivotTable1");
//Accessing the instance of the newly added PivotTable
PivotTable pivotTable = (PivotTable)pivotTables.get(index);
//Draging the first field to the row area.
pivotTable.setShowPivotStyleColumnStripes(true);
pivotTable.setShowPivotStyleRowStripes(true);
//Draging the third field to the data area.
pivotTable.addFieldToArea(PivotFieldType.DATA,"Released Date");
pivotTable.addFieldToArea(PivotFieldType.DATA,"Applied Date");
pivotTable.addFieldToArea(PivotFieldType.DATA,"Directory");
pivotTable.addFieldToArea(PivotFieldType.DATA,"File Name");
pivotTable.addFieldToArea(PivotFieldType.DATA,"Vss Version Number");
pivotTable.addFieldToArea(PivotFieldType.DATA,"Parent Patch Numbere");
pivotTable.addFieldToArea(PivotFieldType.DATA,"Patch Number");
pivotTable.addFieldToArea(PivotFieldType.DATA,"Product Code");
pivotTable.addFieldToArea(PivotFieldType.DATA,"Product Name");
pivotTable.addFieldToArea(PivotFieldType.DATA,"Patch Description");
pivotTable.addFieldToArea(PivotFieldType.DATA,"Build Number");
pivotTable.addFieldToArea(PivotFieldType.DATA,"Patch Id");
// pivotTable.setAutoFormatType(PivotTableAutoFormatType.REPORT_1);
PivotTable pt = (PivotTable)worksheet.getPivotTables().get(0);
Style dxfStyle = workbook.createStyle();
Font font = dxfStyle.getFont();
font.setSize(8);
pt.formatAll(dxfStyle);
pivotTable.setPageFieldOrder(PrintOrderType.DOWN_THEN_OVER);
pivotTable.setPivotTableStyleName("PivotStyleMedium17");
}
catch(Exception e){e.printStackTrace();}
}
}