If you have specific values that you want to return, you can create an object that has properties for each of the values that you want to return like the customer name. Then, you would return the values as that object to Power Automate. The script would look like this:
function main(workbook: ExcelScript.Workbook): SelectedValuesToReturn {
// Get the current worksheet.
let selectedSheet = workbook.getWorksheet("Sheet1");
//values of range
let customerNameValue= selectedSheet.getRange("B3").getValue().toString();
let b4Value = selectedSheet.getRange("B4").getValue().toString();
let b5Value = selectedSheet.getRange("B5").getValue().toString();
let b11Value = selectedSheet.getRange("B11").getValue().toString();
let b12Value = selectedSheet.getRange("B12").getValue().toString();
let b44Value = selectedSheet.getRange("B44").getValue().toString();
return {customerName: customerNameValue, b4: b4Value, b5: b5Value, b11: b11Value, b12: b12Value, b44: b44Value}
}
}
interface SelectedValuesToReturn{
customerName: string,
b4: string,
b5: string,
b11: string,
b12: string,
b44: string
}
If you have an entire table that you want to return, you can follow along this tutorial as well: https://learn.microsoft.com/office/dev/scripts/resources/samples/get-table-data
Oh - and one thing I would change in your current script is that when you are getting a sheet using a script in Power Automate, you should specify the sheet by its name. So, instead of using the line: workbook.getActiveWorksheet()
, you would use workbook.getWorksheet("Sheet Name")
Hope this helps!