Discussion

1
Replies
68
Views
Close popover
Sulakkya Peiris (Sulakkya)
evonsys
Senior Software Engineer
evonsys
LK
Sulakkya Member since 2015 14 posts
evonsys
Posted: September 11, 2020
Last activity: September 11, 2020

Create a Pivot Table in Excel - via script.

This script will help if you're trying to create a basic pivot table (please refer to the attached .txt file) and if you need something a little advanced, the links below will help you.

Method parameters,

  • path - excel file path
  • workSheet - sheet number
  • dataStart - input data start cell
  • dataEnd - input data end/last cell
  • PivotStart - Pivot table start cell.

public void ExelPivot(string path, int workSheet, string dataStart, string dataEnd, string PivotStart)

* Before this script is invoked, make sure to, save and close your excel.

Invoke script

Note: Add this line before the namespace,  using Excel = Microsoft.Office.Interop.Excel; 

Pivot table methods: https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.excel.pivottables?view=excel-pia

Pivot fields: https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.tools.excel.namedrange.pivotfield?view=vsto-2017

Pivot table settings/options:  https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.excel.pivottable?view=excel-pia

 

***Edited by Moderator: Pallavi to change content type from Idea to Discussion***
Pega Robotic Process Automation 19.1 Robotic Process Automation Robotics System Architect Developer Knowledge Share