cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bBI
Regular Visitor

Excel script error - getWorksheet() throws string only error when inputting an index

Hello everyone,

 

Trying to create a flow that will rename the first worksheet of any excel file that is dropped into a sharepoint folder.

 

I had Excel Script record my actions which created the following code:

 

function main(workbook: ExcelScript.Workbook) {

let name_of_worksheet = workbook.getWorksheet("name_of_sheet");
// Rename worksheet to "new_name_of_sheet"
name_of_worksheet.setName("new_name_of_sheet");

}

 

I need the code to be dynamic (it will always be the first sheet but not always have the same name (colleagues working with different languages settings will do that))

 

However when I replace "name_of_sheet" by the index (i.e. workbook.getWorksheet(1) I get the following error message:


[2, 36] Argument of type '1' is not assignable to parameter of type 'string'.

 

How can I get around this? How can I set my Excel Script so it will always rename the first worksheet in excel file that are dropped in a sharepoint?

0 REPLIES 0

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (82,111)