like this.
Hello!
Refer to this:
Hope It Helps
Regards,
To create your pivot table use:
Try
workbook = CType(GetObject(strWorkbookPath,),Microsoft.Office.Interop.Excel.Workbook)
pivotTable = workbook.PivotCaches.Create(Microsoft.Office.Interop.Excel.XlPivotTableSourceType.xlDatabase, SourceData:= strNameSheetOrigin & β!β & strRangeRCOrigin , Version:=6).CreatePivotTable(TableDestination:= strNameSheetDestiny & β!β & strRangeRCDestiny, TableName:= strPivotName , DefaultVersion:=6)
Catch ex As Exception
End Try
To add a pivot field filter use:
Try
workbook = CType(GetObject(strWorkbookPath,),Microsoft.Office.Interop.Excel.Workbook)
worksheet = CType(workbook.Sheets(strSheetName),Microsoft.Office.Interop.Excel.Worksheet)
pivotTable = CType(worksheet.PivotTables(strPivotName),Microsoft.Office.Interop.Excel.PivotTable)
pivotTable.AddFields(,strPivotFieldName,True)
Catch ex As Exception
End Try
To add a pivot field filter use:
Try
workbook = CType(GetObject(strWorkbookPath,),Microsoft.Office.Interop.Excel.Workbook)
worksheet = CType(workbook.Sheets(strSheetName),Microsoft.Office.Interop.Excel.Worksheet)
pivotTable = CType(worksheet.PivotTables(strPivotName),Microsoft.Office.Interop.Excel.PivotTable)
pivotTable.AddFields(,strPivotFieldName,True)
Catch ex As Exception
End Try
To add a pivot field Rows use:
Try
workbook = CType(GetObject(strWorkbookPath,),Microsoft.Office.Interop.Excel.Workbook)
worksheet = CType(workbook.Sheets(strSheetName),Microsoft.Office.Interop.Excel.Worksheet)
pivotTable = CType(worksheet.PivotTables(strPivotName),Microsoft.Office.Interop.Excel.PivotTable)
pivotTable.AddFields(strPivotFieldName,True)
Catch ex As Exception
End Try
To add a pivot field Column use:
Try
workbook = CType(GetObject(strWorkbookPath,),Microsoft.Office.Interop.Excel.Workbook)
worksheet = CType(workbook.Sheets(strSheetName),Microsoft.Office.Interop.Excel.Worksheet)
pivotTable = CType(worksheet.PivotTables(strPivotName),Microsoft.Office.Interop.Excel.PivotTable)
pivotTable.AddFields(,strPivotFieldName,True)
Catch ex As Exception
End Try
To add a calculated field in your pivot table use:
Try
workbook = CType(GetObject(strWorkbookPath,),Microsoft.Office.Interop.Excel.Workbook)
worksheet = CType(workbook.Sheets(strSheetName),Microsoft.Office.Interop.Excel.Worksheet)
pivotTable = CType(worksheet.PivotTables(strPivotName),Microsoft.Office.Interop.Excel.PivotTable)
pivotField = pivotTable.CalculatedFields.Add(strFieldName,strFormula,True)
pivotField.Orientation = Microsoft.Office.Interop.Excel.XlPivotFieldOrientation.xlDataField
Catch ex As Exception
End Try
variable/type
workbook/ Microsoft.Office.Interop.Excel.Workbook
worksheet/ Microsoft.Office.Interop.Excel.Worksheet
pivotTable/ Microsoft.Office.Interop.Excel.PivotTable
pivotField/ Microsoft.Office.Interop.Excel.PivotField
Regards
@ChimeraPlayerN1N30N3, Do you have a sample work flow for this? It would be really helpful if you can post that,
Thank you
Priyanka
- Select any cell inside your source data.
- On the Insert tab of the Ribbon select Pivot Table
- Excel will automatically detect the range of cells and put it in your Table/Range field .
- Ok, now youβre ready to build your choose the fields.
- Ok, so far so good.
Hope this information will help you. If you want to enhance your skills then you can also do advance excel course
Do you have a sample work flow for this? It would be really helpful if you can post that,
Do you have sample flow for this? Please share if possible ?it will be really helpful