SOLVED

Problem ExcelScript in excel files with compatibility mode 97-2003

Copper Contributor

I don't really know if this is the problem, but after many times of trying to run the most simple lines of code in Excel Typescript, 

 

function main(workbook: ExcelScript.Workbook) {
  const sheet = workbook.getActiveWorksheet();
  let range = sheet.getUsedRange();
   const table = sheet.addTable(range, true);
}
 
it would always show "Error - Worksheet getUsedRange: There was an internal error while processing the request". 
 
But when I copy paste the entire sheet (ctrl + A) into a new excel workbook (excel latest version), the code obviously is coerced. The only conclusion I arrived to is that excel ExcelScript wont run on files labeled as "compatibility mode Microsoft excel 97-2003"
 
Can someone please confirm/challenge this assumption? 
 
Thanks beforehand!
6 Replies
best response confirmed by LearnExcelScript (Copper Contributor)
Solution

@LearnExcelScript I hoped to find an answer here:

https://learn.microsoft.com/en-us/office/dev/scripts/testing/platform-limits

but it does not mention the Excel file type.

Hi @LearnExcelScript, thanks for your question! Office Scripts should be supported in .xls files as long as you open them in a recent Excel client. It's possible there are other issues with your workbook that prevent the script from working properly. Could you share a session id and/or a sample workbook (sensitive data removed as needed)?

@MichelleRanMSFT 

I was able to reproduce it (client is current Beta)

image.png

Above file is attached.

Ah, I see - there does indeed appear to be a bug with the getUsedRange API when run on workbooks in compatibility mode. We've logged a bug with the relevant team, although we don't have a timeline to share at the moment. Thanks for reporting this!

@MichelleRanMSFT Hope you fix it sooner or later, thanks.

1 best response

Accepted Solutions
best response confirmed by LearnExcelScript (Copper Contributor)