I can do it and this is my Code
- Code: Select all
Spire.Xls.Workbook workbook = new Spire.Xls.Workbook();
Spire.Xls.Worksheet sheet = workbook.Worksheets[0];
sheet.InsertDataTable(dtFinal, true, 1, 1);
Spire.Xls.Worksheet sheet2 = workbook.CreateEmptySheet();
sheet2.Name = "Pivot Table";
Spire.Xls.CellRange dataRange = sheet.Range["A1:J9205"];
Spire.Xls.PivotCache cache = workbook.PivotCaches.Add(dataRange);
Spire.Xls.PivotTable pt = sheet2.PivotTables.Add("Pivot Table", sheet.Range["A1"], cache);
pt.ShowRowGrand = false;
pt.ShowColumnGrand = false;
var r0 = pt.PivotFields["ptime"];
r0.Axis = Spire.Xls.AxisTypes.Row;
pt.Options.RowHeaderCaption = "ptime";
var r1 = pt.PivotFields["RankingSub"];
r1.Axis = Spire.Xls.AxisTypes.Column;
pt.Options.ColumnHeaderCaption = "RankingSub";
r1.Subtotals = 0;
var r2 = pt.PivotFields["Substation"];
r2.Axis = Spire.Xls.AxisTypes.Column;
pt.Options.ColumnHeaderCaption = "Substation";
r2.Subtotals = 0;
var r3 = pt.PivotFields["RankingTit"];
r3.Axis = Spire.Xls.AxisTypes.Column;
pt.Options.ColumnHeaderCaption = "RankingTit";
r3.Subtotals = 0;
var r4 = pt.PivotFields["ColumnTitle"];
r4.Axis = Spire.Xls.AxisTypes.Column;
pt.Options.ColumnHeaderCaption = "ColumnTitle";
r4.Subtotals = 0;
var r7 = pt.PivotFields["RankingS6"];
r7.Axis = Spire.Xls.AxisTypes.Column;
pt.Options.ColumnHeaderCaption = "RankingS6";
r7.Subtotals = 0;
var r8 = pt.PivotFields["S6_NAME"];
r8.Axis = Spire.Xls.AxisTypes.Column;
pt.Options.ColumnHeaderCaption = "S6_NAME";
r8.Subtotals = 0;
pt.DataFields.Add(pt.PivotFields["ValueAmount"], "ValueAmount", Spire.Xls.SubtotalTypes.None);
pt.AllSubTotalTop = false;
sheet2.Range["A34:LR34"].Style.Font.Color = Color.Blue;
string filename = @"D:\Temp\XML\PivotTable.xlsx";
workbook.SaveToFile(filename, Spire.Xls.ExcelVersion.Version2010);
My First Question is:
When I want to change th font color of a rows the code doesn't effect. is there something I am mising
- Code: Select all
sheet2.Range["A34:LR34"].Style.Font.Color = Color.Blue;
Thank s