Try the below example, and you will get the following error
Error:
Removed Feature: PivotTable report from / xl / PivotTables / pivotTable.xml part ( PivotTable view)
Records removed : book Properties / xl / workbook.xml part ( Book)
Example:
public class TEA
{
public DateTime TimeEntryDate { get; set; }
public String EmployeeName { get; set; }
public String ProjectName { get; set; }
public String DepartmentName { get; set; }
public String TimeEntryPeriodName { get; set; }
public decimal BillableHours { get; set; }
public decimal BilledPrice { get; set; }
}
...
var items = new List<TEA>
{
// Uncomment this line and comment the next one to make it working!
//new TEA() {TimeEntryDate=new DateTime(2013,10,7), BillableHours = 3, BilledPrice = 0, EmployeeName = "Minnie", DepartmentName = "Dep1", ProjectName = "FORMAZIONE", TimeEntryPeriodName = "Ottobre 2013" },
new TEA() {TimeEntryDate=new DateTime(2013,10,7), BillableHours = 3, BilledPrice = 0, EmployeeName = "Minnie", DepartmentName = "Dep1", ProjectName = "Formazione", TimeEntryPeriodName = "Ottobre 2013" },
new TEA() {TimeEntryDate=new DateTime(2013,10,8), BillableHours = 8, BilledPrice = 0, EmployeeName = "Bugs Bunny", DepartmentName = "Dep2", ProjectName = "FORMAZIONE", TimeEntryPeriodName = "Ottobre 2013" },
new TEA() {TimeEntryDate=new DateTime(2013,10,10), BillableHours = 8, BilledPrice = 0, EmployeeName = "Mickey Nouse", DepartmentName = "Dep2", ProjectName = "FORMAZIONE", TimeEntryPeriodName = "Ottobre 2013" },
};
var workbook = new XLWorkbook();
var sheet = workbook.Worksheets.Add("PastrySalesData");
// Insert our list of pastry data into the "PastrySalesData" sheet at cell 1,1
var source = sheet.Cell(1, 1).InsertTable(items, "PastrySalesData", true);
// Create a range that includes our table, including the header row
var range = source.DataRange;
var header = sheet.Range(1, 1, 1, 7);
var dataRange = sheet.Range(header.FirstCell(), range.LastCell());
// Add a new sheet for our pivot table
var ptSheet = workbook.Worksheets.Add("PivotTable");
// Create the pivot table, using the data from the "PastrySalesData" table
var pt = ptSheet.PivotTables.AddNew("PivotTable", ptSheet.Cell(1, 1), dataRange);
// The rows in our pivot table will be the names of the pastries
pt.RowLabels.Add("DepartmentName");
// The columns will be the months
pt.ColumnLabels.Add("TimeEntryPeriodName");
// The values in our table will come from the "NumberOfOrders" field
// The default calculation setting is a total of each row/column
pt.Values.Add("BillableHours");
...
However if you replace the ProjectName = "Formazione" with upper case everythings works like a charm.
I hope this is helpful for understanding the reason causing the error.
Error:
Removed Feature: PivotTable report from / xl / PivotTables / pivotTable.xml part ( PivotTable view)
Records removed : book Properties / xl / workbook.xml part ( Book)
Example:
public class TEA
{
public DateTime TimeEntryDate { get; set; }
public String EmployeeName { get; set; }
public String ProjectName { get; set; }
public String DepartmentName { get; set; }
public String TimeEntryPeriodName { get; set; }
public decimal BillableHours { get; set; }
public decimal BilledPrice { get; set; }
}
...
var items = new List<TEA>
{
// Uncomment this line and comment the next one to make it working!
//new TEA() {TimeEntryDate=new DateTime(2013,10,7), BillableHours = 3, BilledPrice = 0, EmployeeName = "Minnie", DepartmentName = "Dep1", ProjectName = "FORMAZIONE", TimeEntryPeriodName = "Ottobre 2013" },
new TEA() {TimeEntryDate=new DateTime(2013,10,7), BillableHours = 3, BilledPrice = 0, EmployeeName = "Minnie", DepartmentName = "Dep1", ProjectName = "Formazione", TimeEntryPeriodName = "Ottobre 2013" },
new TEA() {TimeEntryDate=new DateTime(2013,10,8), BillableHours = 8, BilledPrice = 0, EmployeeName = "Bugs Bunny", DepartmentName = "Dep2", ProjectName = "FORMAZIONE", TimeEntryPeriodName = "Ottobre 2013" },
new TEA() {TimeEntryDate=new DateTime(2013,10,10), BillableHours = 8, BilledPrice = 0, EmployeeName = "Mickey Nouse", DepartmentName = "Dep2", ProjectName = "FORMAZIONE", TimeEntryPeriodName = "Ottobre 2013" },
};
var workbook = new XLWorkbook();
var sheet = workbook.Worksheets.Add("PastrySalesData");
// Insert our list of pastry data into the "PastrySalesData" sheet at cell 1,1
var source = sheet.Cell(1, 1).InsertTable(items, "PastrySalesData", true);
// Create a range that includes our table, including the header row
var range = source.DataRange;
var header = sheet.Range(1, 1, 1, 7);
var dataRange = sheet.Range(header.FirstCell(), range.LastCell());
// Add a new sheet for our pivot table
var ptSheet = workbook.Worksheets.Add("PivotTable");
// Create the pivot table, using the data from the "PastrySalesData" table
var pt = ptSheet.PivotTables.AddNew("PivotTable", ptSheet.Cell(1, 1), dataRange);
// The rows in our pivot table will be the names of the pastries
pt.RowLabels.Add("DepartmentName");
// The columns will be the months
pt.ColumnLabels.Add("TimeEntryPeriodName");
// The values in our table will come from the "NumberOfOrders" field
// The default calculation setting is a total of each row/column
pt.Values.Add("BillableHours");
...
However if you replace the ProjectName = "Formazione" with upper case everythings works like a charm.
I hope this is helpful for understanding the reason causing the error.