我希望这能帮助我,至少,回答了2个问题,我问here,但我期待如何在EPPlus / OpenXML的创建PivotCache并不能找到任何在线/在他们的文件资料,介绍如何做到这一点。
I'm hoping this could help me, at least, answer one of the 2 questions I asked here, but I am looking how to create a PivotCache in EPPlus / OpenXML and can't find anything online / in their documentation that shows how to do it.
所以,suposing我有一个Excel工作表, wksRawData 在EPPlus创造,我想创建第二个表与基于透视表缓存数据透视表
wksRawData.Cells(wksRawData.Dimension.Address)
- 在这种话,我可以删除wksRawData但仍保持数据透视表的希望。我将如何做呢?
So, suposing I have one Excel sheet, wksRawData
created in EPPlus and I want to create a second sheet with a pivot table based upon the pivot cache of wksRawData.Cells(wksRawData.Dimension.Address)
- In the hopes that then I could delete wksRawData but still keep the pivot table. How would I do that?
到目前为止,我的code在我的第二个工作表创建数据透视表是:
So far, my code for creating the pivot table in my second worksheet is:
Dim wksRawData As ExcelWorksheet = wbk.Worksheets("Raw Data")
Dim wksPvtTbl As ExcelWorksheet = wbk.Worksheets("PivotTbl")
' Insert the Pivot Table to the sheet
Dim DataRange As ExcelRange = wksRawData.Cells(wksRawData.Dimension.Address)
Dim pvtTable As OfficeOpenXml.Table.PivotTable.ExcelPivotTable = wksPvtTbl.PivotTables.Add(wksPvtTbl.Cells("B4"), DataRange, "MyPivotTable")
pvtTable.Compact = True
pvtTable.CompactData = True
pvtTable.Outline = True
pvtTable.OutlineData = True
pvtTable.ShowHeaders = True
pvtTable.UseAutoFormatting = True
pvtTable.ApplyWidthHeightFormats = True
pvtTable.ShowDrill = True
pvtTable.RowHeaderCaption = "Caption"
' Set the top field
Dim r1 As OfficeOpenXml.Table.PivotTable.ExcelPivotTableField = pvtTable.Fields("FirstField")
r1.Sort = OfficeOpenXml.Table.PivotTable.eSortType.Ascending
pvtTable.RowFields.Add(r1)
' Set the second field
Dim r2 As OfficeOpenXml.Table.PivotTable.ExcelPivotTableField = pvtTable.Fields("SecondField")
r2.Sort = OfficeOpenXml.Table.PivotTable.eSortType.Ascending
pvtTable.RowFields.Add(r2)
r2.ShowAll = False
' Set the DataField
Dim df1 As OfficeOpenXml.Table.PivotTable.ExcelPivotTableField = pvtTable.Fields("DataField")
df1.SubTotalFunctions = OfficeOpenXml.Table.PivotTable.eSubTotalFunctions.Sum
pvtTable.DataFields.Add(df1)
请,在此任何和所有帮助或其他问题,真的会AP preciated - 无论是在C#或VB,EPPlus或OpenXML的 - 我只需要得到这个工作!
PLEASE, any and all help on this or the other question would REALLY be appreciated - Whether it be in C# or VB, EPPlus or OpenXML - I just need to get this working!!!
谢谢!
推荐答案
我相信你想从另一个工作表添加数据。我在你的其他线程后显示满code EPPlus透视表 - 关闭整场
I belive you want to add data from another sheet. My post in your other thread shows full code EPPlus Pivot Table - Collapse entire field
var pt = wsPivot1.PivotTables.Add(wsPivot1.Cells["A1"], ws.Cells["K1:N11"], "Pivottable1");
调用PivoTables.Add()参见下面的工具提示。
calling "PivoTables.Add()" see tool tip below.
// Summary:
// Create a pivottable on the supplied range
//
// Parameters:
// Range:
// The range address including header and total row
//
// Source:
// The Source data range address
//
// Name:
// The name of the table. Must be unique
//
// Returns:
// The pivottable object
相关推荐
最新文章