Skip to content

Latest commit

 

History

History
99 lines (71 loc) · 5.77 KB

excel-add-ins-troubleshooting.md

File metadata and controls

99 lines (71 loc) · 5.77 KB
titledescriptionms.datems.topicms.localizationpriority
Troubleshooting Excel add-ins
Learn how to troubleshoot development errors in Excel add-ins.
02/17/2022
troubleshooting-error-codes
medium

Troubleshooting Excel add-ins

This article discusses troubleshooting issues that are unique to Excel. Please use the feedback tool at the bottom of the page to suggest other issues that can be added to the article.

API limitations when the active workbook switches

Add-ins for Excel are intended to operate on a single workbook at a time. Errors can arise when a workbook that is separate from the one running the add-in gains focus. This only happens when particular methods are in the process of being called when the focus changes.

The following APIs are affected by this workbook switch.

Excel JavaScript APIError thrown
Chart.activateGeneralException
Range.selectGeneralException
Table.clearFiltersGeneralException
Workbook.getActiveCellInvalidSelection
Workbook.getSelectedRangeInvalidSelection
Workbook.getSelectedRangesInvalidSelection
Worksheet.activateGeneralException
Worksheet.deleteInvalidSelection
Worksheet.gridlinesGeneralException
Worksheet.showHeadingsGeneralException
WorksheetCollection.addGeneralException
WorksheetFreezePanes.freezeAtGeneralException
WorksheetFreezePanes.freezeColumnsGeneralException
WorksheetFreezePanes.freezeRowsGeneralException
WorksheetFreezePanes.getLocationOrNullObjectGeneralException
WorksheetFreezePanes.unfreezeGeneralException

Note

This only applies to multiple Excel workbooks open on Windows or Mac.

Coauthoring

See Coauthoring in Excel add-ins for patterns to use with events in a coauthoring environment. The article also discusses potential merge conflicts when using certain APIs, such as TableRowCollection.add.

Known Issues

Binding events return temporary Binding objects

Both BindingDataChangedEventArgs.binding and BindingSelectionChangedEventArgs.binding return a temporary Binding object that contains the ID of the Binding object that raised the event. Use this ID with BindingCollection.getItem(id) to retrieve the Binding object that raised the event.

The following code sample shows how to use this temporary binding ID to retrieve the related Binding object. In the sample, an event listener is assigned to a binding. The listener calls the getBindingId method when the onDataChanged event is triggered. The getBindingId method uses the ID of the temporary Binding object to retrieve the Binding object that raised the event.

asyncfunctionrun(){awaitExcel.run(async(context)=>{// Retrieve your binding.letbinding=context.workbook.bindings.getItemAt(0);awaitcontext.sync();// Register an event listener to detect changes to your binding// and then trigger the `getBindingId` method when the data changes. binding.onDataChanged.add(getBindingId);awaitcontext.sync();});}asyncfunctiongetBindingId(eventArgs){awaitExcel.run(async(context)=>{// Get the temporary binding object and load its ID. lettempBindingObject=eventArgs.binding;tempBindingObject.load("id");// Use the temporary binding object's ID to retrieve the original binding object. letoriginalBindingObject=context.workbook.bindings.getItem(tempBindingObject.id);// You now have the binding object that raised the event: `originalBindingObject`. });}

Cell format useStandardHeight and useStandardWidth issues

The useStandardHeight property of CellPropertiesFormat doesn't work properly in Excel on the web. Due to an issue in the Excel on the web UI, setting the useStandardHeight property to true calculates height imprecisely on this platform. For example, a standard height of 14 is modified to 14.25 in Excel on the web.

On all platforms, the useStandardHeight and useStandardWidth properties of CellPropertiesFormat are only intended to be set to true. Setting these properties to false has no effect.

Range getImage method unsupported on Excel for Mac

The Range getImage method isn't currently supported in Excel for Mac. See OfficeDev/office-js Issue #235 for the current status.

Range return character limit

The Worksheet.getRange(address) and Worksheet.getRanges(address) methods have an address string limit of 8192 characters. When this limit is exceeded, the address string is truncated to 8192 characters.

See also

close