Skip to content
Sheetwrite

@sheetwrite/core/external-links

rewriteExternalSheetsfunction

Report a problem

On this page

Rewrite the names of other workbooks' sheets in a formula. Each such sheet is replaced by replace, which returns the new text before !, or undefined when the formula cannot be written that way. Text in quotes and structured references stay as they are. A folder before [ in a quoted name is left out.

Declaration

function rewriteExternalSheets(
formula: string,
replace: (name: ExternalSheetName) => string | undefined,
): string | undefined

Parameters

formula: stringrequired

Formula text, with or without the leading =.

replace: (name: ExternalSheetName) => string | undefinedrequired

Called for each name of another workbook; returns its new text.

Returns

string | undefined

The new formula, or undefined when replace returned undefined for any name.