I have this function in Excel Script Lab:
Libraries
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
@types/office-js
office-ui-fabric-js@1.4.0/dist/css/fabric.min.css
office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css
core-js@2.4.1/client/core.min.js
@types/core-js
jquery@3.1.1
@types/jquery@3.3.1
Script:
/**
* Create a list.
* @customfunction
* @param name string
* @param args {string[]}
*/
function datatablex(display: string, ...args: string[]): any {
const entity = {
type: "Entity",
text: display,
properties: {
Nombre: {
type: "String",
basicValue: display,
propertyMetadata: {
excludeFrom: {
cardView: true
}
}
}
}
};
for (let i = 0; i < args[0].length; i += 2) {
const name = args[0][i + 0];
const value = args[0][i + 1];
entity.properties[name] = {
type: "String",
basicValue: value
};
}
return entity;
}
This function allows me to create a DataType: Entity with the parameters given in the function as arguments. Currently, this function takes a string which will be the displayed text in the cell, and then any number of arguments. These extra arguments always come in couples. The first is the name of the value and the second is the value itself. This repeats many times if you add many more parameters. Below is an image showing an example:
My problem is that the extra arguments are currently strings and instead I want them to be tables (two dimensions each). I tried making changes in the function:
- Replace the string with string and even string
- Replace the property “String” type to “Array” and basicValue to elements.
- Replace the args[0][i + 0] stuff with more . However, I couldn’t make it work. Sometimes it gives #Value! and others "Calc! depending on what I change. Below is an image explaining the imputs I want:
[Example imputs]
Below is an example of the output I want (I created it manually, not using the function cause obviously it doesn’t work)
[Example output]
Example when clicking one of the tables.