admin管理员组

文章数量:1181894

Can you help me, how can i return a function in office script that returns an array with: a mail, and 2 array of row ranges:

the return i need is (if possible )

[["[email protected]"],["Estac","22Jan","23Jan","24Jan","25Jan"],["448 - RRHH","","R","R",""]]

Can you help me, how can i return a function in office script that returns an array with: a mail, and 2 array of row ranges:

the return i need is (if possible )

[["[email protected]"],["Estac","22Jan","23Jan","24Jan","25Jan"],["448 - RRHH","","R","R",""]]
Share Improve this question asked yesterday David Ricardo Menacho VadilloDavid Ricardo Menacho Vadillo 1157 bronze badges 2
  • Are you creating an Office add-in or Office Script? – Rick Kirkham Commented yesterday
  • an office script macro that i can use in a power automate flow – David Ricardo Menacho Vadillo Commented 22 hours ago
Add a comment  | 

1 Answer 1

Reset to default 0

Assuming this is Office Scripts and not an Office Add-in, you can return a 2D array from the script by adding the appropriate type to the signature. This script returns the data in the used range of Sheet1:

function main(workbook: ExcelScript.Workbook): (string | number | boolean)[][] {
    let selectedSheet = workbook.getWorksheet("Sheet1");
    let range = selectedSheet.getUsedRange();
    let rangeData = range.getValues();
    return rangeData;
}

You could also wrap the array in an object to make dealing with it in Power Automate easier. This sample shows how to merge worksheets and returns 2D arrays as part of that: https://learn.microsoft.com/office/dev/scripts/resources/samples/combine-worksheets-into-single-workbook

本文标签: Office Script return multidimensional arrayStack Overflow