An Office service that supports add-ins to interact with objects in Office client applications.
How do I make a streaming Excel Custom Function which returns FormattedNumberCellValue or EntityCellValue?
I have a streaming API. I was able to successfully wire it up as CustomFunctions.StreamingInvocation<string>.
But I would like to return as a Excel.EntityPropertyType so I can use numberFormat with Excel.CellValueType.formattedNumber. This is primarily so I can format it by default for consumers but also because I didn't seem to able to have Excel use "Format Cells" or decimal precision control on the string return type.
When I first use the formula, the cell renders fine. But it breaks upon update. It displays #VALUE! with error A value used in the formula is of the wrong data type.
I tried modifying my functions.json with allowCustomDataForDataTypeAny but that didn't make a difference.
What I'd really like to do is have a streaming Excel.EntityCellValue so I could have multiple data properties like bid/mid/offer. I did try that first and it went the same way... looked great upon first render and then broke on updates; so I'd be happy enough if I could do one customfunction per property.
Here is a simplified version of the code:
/**
* @customfunction
*/
export function test(invocation: CustomFunctions.StreamingInvocation<any>): void {
let dollars = 100;
const timer = setInterval(() => {
invocation.setResult({
basicValue: dollars++,
numberFormat: "$0.000",
type: Excel.CellValueType.formattedNumber,
});
}, 3000);
invocation.onCanceled = () => {
clearInterval(timer);
};
}
Microsoft 365 and Office | Development | Office JavaScript API
Microsoft 365 and Office | Development | Other
Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
Microsoft 365 and Office | Excel | For business | Windows
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data