Closed ctphillips closed 2 months ago
Hi @ctphillips,
Thanks for reporting this. I'll double-check, but I don't think there is a way to change PivotTable column headers through the Scripts APIs. Let me tag @michelleranmsft to log this feature request.
Thanks for confirming Alex. I wasn’t sure if I was missing a way to do it or not. In the future, is there a place where I should put feature requests or is the process I used what y’all would want me to do?
On Fri, Jul 12, 2024 at 12:08 Alex Jerabek @.***> wrote:
Hi @ctphillips https://github.com/ctphillips,
Thanks for reporting this. I'll double-check, but I don't think there is a way to change PivotTable column headers through the Scripts APIs. Let me tag @michelleranmsft https://github.com/michelleranmsft to log this feature request.
— Reply to this email directly, view it on GitHub https://github.com/OfficeDev/office-scripts-docs/issues/751#issuecomment-2225986660, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABV6AFMCRHEUMMNT7RSCEE3ZMAESBAVCNFSM6AAAAABKY2BN6KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRVHE4DMNRWGA . You are receiving this because you were mentioned.Message ID: @.***>
Hi @ctphillips,
The best place for Office Scripts feature requests is on the Excel Community page. There is a category for "Macros, Scripts, and Add-ins". Having the request there also helps gauge community interest through the voting mechanism.
Since there's nothing actionable to be done in the documentation, I'm going to close this this. If you have any further questions about Office Scripts, please don't hesitate to ask.
Describe your scenario
After creating a pivot table using office scripts, currently there does not appear to be a way to change the name of the column headers. You can get the pivotTable.getLayout().getColumnLabelRange().getValues() but when you call pivotTable.getLayout().getColumnLabelRange().setValues(someNewValues[][]) you get the error: Range setValues: The operation failed because it conflicts with a pivot table range. So it seems like you cannot use the setValues method on the column header range within a pivot table, but there does not seem to be a method provided to perform this task. I also attempt to record the action of changing the column headers manually, but the recording just states that the action is not recordable (or some similar message in the recorded script output).
Which APIs or Excel features?
The pivot layout interface should provide a method for setting the column labels, or allow the range setValues() method access to write just the header values.