MCPcopy Index your code
hub / github.com/simstudioai/sim / resolveSheetAndAddress

Function resolveSheetAndAddress

apps/sim/tools/microsoft_excel/utils.ts:163–185  ·  view source on GitHub ↗
(
  address: string | undefined,
  sheetName?: string
)

Source from the content-addressed store, hash-verified

161 * Throws when a worksheet name cannot be determined or the combined format is invalid.
162 */
163export function resolveSheetAndAddress(
164 address: string | undefined,
165 sheetName?: string
166): { sheetName: string; address: string } {
167 const trimmedAddress = address?.trim()
168 if (!trimmedAddress) {
169 throw new Error('A cell range is required (e.g., "A1:B2" or "Sheet1!A1:B2")')
170 }
171
172 const trimmedSheet = sheetName?.trim()
173 if (trimmedSheet) {
174 return { sheetName: trimmedSheet, address: trimmedAddress }
175 }
176
177 const match = trimmedAddress.match(/^([^!]+)!(.+)$/)
178 if (!match) {
179 throw new Error(
180 `Invalid range format: "${address}". Provide a sheet name, or use the combined format "Sheet1!A1:B2"`
181 )
182 }
183
184 return { sheetName: match[1], address: match[2] }
185}
186
187/**
188 * Builds the Graph API URL for a worksheet range object, resolving the sheet name

Callers 1

buildWorksheetRangeUrlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected