Formatting Issue(Very urgent)

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();}

}

}

Hi Chiranjeevi,

Thanks for your posting and using Aspose.Cells for Java.

We were unable to run your sample code successfully. It throws the exception saying The PivotTable field name is invalid.

However, we have tested your issue with the source file attached at this post and applied different pivot table styles and it successfully set the pivot table styles. We have also attached the output file for your reference.

We have tested it with the latest version: Aspose.Cells
for Java v7.5.3.5.


If you still find the issue, then please provide us your source and output file and also expected output files. Also provide the simplified sample runnable code for testing.

Java


String filePath = “F:\Shak-Data-RW\Downloads\Test.xls”;


Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.getWorksheets().get(1);


PivotTable pivotTable = worksheet.getPivotTables().get(0);


pivotTable.setPivotTableStyleName(“PivotStyleMedium9”);


workbook.save(filePath + “.out1.xls”, SaveFormat.EXCEL_97_TO_2003);