The method works as you do in the PivotTable and PivotChart Wizard in Ms Excel.
In the step 1, you select "Mulitple consolidation ranges" as the data that you want to analyze.
In the step 2, if you select "Create a single page field for me", you should set the param isAutoPage is true.We will auto create a page field and the page pageFields will be ignored.
If you select another option, you should set the param isAutoPage is false and init the param pageFields.
The class PageFields works as the step3 , you will be asked to add the page fields and choose the item of the page field to identify the data rage. So you should call pageFields.addPageField(String[]) to add the page field. Then you should call addIdentify() method to add relation with the item in the page field and the data range.
I have quite a huge amount of records which could reach to 100,000 and I am splitting these records to multiple sheets having each sheet to contains 10,000 records. May I know how can I read the records in these sheets to create a single pivot tables in C#?
Well, although you may try to use the code, e.g int index = pivotTables.Add(new string[] {"=Sheet1!A1:C10000", “=Sheet2!A1:C10000…”}, true, null, “A3”, “PivotTable1”); But this will not suit your requirements. I think MS Excel 2003 cannot support your need if your data source exceeds 65536 rows/records. Moreover, if you use consolidation ranges option, the pivot fields would only be with Page 1, Pag2… and with Row,Column,Data fields or other attributes and we think it will not be the way you want to create your desired pivot table report.
So, we suggest you to use and create xlsx file format (MS Excel 2007) that does not have 65536 rows/records restriction. You should export/fill all records (e.g 100,000 records) in a single worksheet and create the pivot table based on the single range.
Thanks. We have manage to stream down the number of records.
But I have another issue, that is the data column suppose to show a character but instead it is showing number. May I know how can I make it to show character?
// Pivot table i add these value in column 13 as Data int dataFieldIndex = pivotTable.AddFieldToArea(PivotFieldType.Data, 13); PivotField df = pivotTable.DataFields[dataFieldIndex]; df.Number = 49;
Your understanding is right. Number and NumberFormat properties are used to format the date and numbers and are not applied to the strings. If you still face any problem, please manually create an excel file showing your requirement and post it here. We will check it soon.
Attached is a sample excel. Refering to the Data worksheet column 13, highlighted in yellow, you can see it is appearing as "1" in the PivotTable worksheet (portion highlighted in yellow).
If you use cell.PutValue(“1”), we will set a string value to the cell, so you will see a triangle in the left corner of the cell in MS Excel. If you want to set a numeric value to the cell, please simply use Cell.PutValue(1).
Also, please create your mentioned pivot table in MS Excel and post the template file here. We will check it soon.
BTW, we tried the following codes and it works fine.