From 27ccce7b0823a071da5e0f69ebf5882af08f10d2 Mon Sep 17 00:00:00 2001 From: VinothSF5015 Date: Wed, 3 Jun 2026 16:24:05 +0530 Subject: [PATCH 1/2] Content Added --- ...eate-a-pivot-cache-from-worksheet-table.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/how-to-create-a-pivot-cache-from-worksheet-table.md diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-create-a-pivot-cache-from-worksheet-table.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-create-a-pivot-cache-from-worksheet-table.md new file mode 100644 index 0000000000..e9d1513adb --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-create-a-pivot-cache-from-worksheet-table.md @@ -0,0 +1,93 @@ +--- +title: How to create a Pivot Cache when the worksheet data is stored as a table? | Syncfusion +description: This page explains how to create a Pivot Cache when the worksheet data is stored as a table using Syncfusion XlsIO. +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to create a Pivot Cache when the worksheet data is stored as a table? + +You can create a Pivot Cache from a worksheet's ListObject (table) by accessing the table's location and passing it to the PivotCaches.Add method. The following code illustrates this. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + // Instantiate the Excel application object + IApplication application = excelEngine.Excel; + + // Assign default application version + application.DefaultVersion = ExcelVersion.Xlsx; + + // Open a new workbook contains table + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data\InputTemplate.xlsx")); + + // Access first worksheet from the workbook + IWorksheet worksheet = workbook.Worksheets[0]; + + IWorksheet pivotSheet = workbook.Worksheets[1]; + + // Create pivot cache from the table location + IPivotCache cache = workbook.PivotCaches.Add(worksheet.ListObjects[0].Location); + + IPivotTable pivotTable = pivotSheet.PivotTables.Add("PivotTable1", pivotSheet["A1"], cache); + + // Save the workbook to disk in XLSX format + workbook.SaveAs(Path.GetFullPath(@"Output\Output.xlsx")); +} +{% endhighlight %} +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + // Instantiate the Excel application object + IApplication application = excelEngine.Excel; + + // Assign default application version + application.DefaultVersion = ExcelVersion.Xlsx; + + // Open a new workbook contains table + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); + + // Access first worksheet from the workbook + IWorksheet worksheet = workbook.Worksheets[0]; + + IWorksheet pivotSheet = workbook.Worksheets[1]; + + // Create pivot cache from the table location + IPivotCache cache = workbook.PivotCaches.Add(worksheet.ListObjects[0].Location); + + IPivotTable pivotTable = pivotSheet.PivotTables.Add("PivotTable1", pivotSheet["A1"], cache); + + // Save the workbook to disk in XLSX format + workbook.SaveAs("Output.xlsx"); +} +{% endhighlight %} +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As New ExcelEngine() + ' Instantiate the Excel application object + Dim application As IApplication = excelEngine.Excel + + ' Assign default application version + application.DefaultVersion = ExcelVersion.Xlsx + + ' Open a new workbook contains table + Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx") + + ' Access first worksheet from the workbook + Dim worksheet As IWorksheet = workbook.Worksheets(0) + + Dim pivotSheet As IWorksheet = workbook.Worksheets(1) + + ' Create pivot cache from the table location + Dim cache As IPivotCache = workbook.PivotCaches.Add(worksheet.ListObjects(0).Location) + + Dim pivotTable As IPivotTable = pivotSheet.PivotTables.Add("PivotTable1", pivotSheet("A1"), cache) + + ' Save the workbook to disk in XLSX format + workbook.SaveAs("Output.xlsx") +End Using +{% endhighlight %} +{% endtabs %} + +A complete working example in C# is present on this GitHub page. \ No newline at end of file From 27b96121e5019314e0bec1f5439423fb748a2385 Mon Sep 17 00:00:00 2001 From: VinothSF5015 Date: Wed, 3 Jun 2026 16:33:50 +0530 Subject: [PATCH 2/2] Update how-to-create-a-pivot-cache-from-worksheet-table.md --- .../how-to-create-a-pivot-cache-from-worksheet-table.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-create-a-pivot-cache-from-worksheet-table.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-create-a-pivot-cache-from-worksheet-table.md index e9d1513adb..bcfe80cfae 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-create-a-pivot-cache-from-worksheet-table.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-create-a-pivot-cache-from-worksheet-table.md @@ -1,12 +1,12 @@ --- -title: How to create a Pivot Cache when the worksheet data is stored as a table? | Syncfusion +title: Create Pivot Cache from Excel Table Data | Syncfusion description: This page explains how to create a Pivot Cache when the worksheet data is stored as a table using Syncfusion XlsIO. platform: document-processing control: XlsIO documentation: UG --- -# How to create a Pivot Cache when the worksheet data is stored as a table? +# How to Create a Pivot Cache from Excel Table Data? You can create a Pivot Cache from a worksheet's ListObject (table) by accessing the table's location and passing it to the PivotCaches.Add method. The following code illustrates this. @@ -90,4 +90,4 @@ End Using {% endhighlight %} {% endtabs %} -A complete working example in C# is present on this GitHub page. \ No newline at end of file +A complete working example in C# is present on this GitHub page.