We are using office.js and the Excel.run functionality. The objective is to click on a single cell in a sheet and capture all data in that sheet. This was successfully tested in Visual Studio 2015 running Excel 2016 and Excel API v1.3.
However, when running the same on Excel Online, an exception is created at the line return ctx.sync().then(function () {
.
Exception:
GeneralException: An internal error has occurred.
Debug info: {"code":"GeneralException","message":"An internal error has occurred."}
This issue happens in all browsers. Currently using Chrome version 63.0.3239.18 (Official Build) beta (64-bit).
We are trying to understand why it only fails in Excel Online and not Excel 2016 for Windows.
Here's the code without the Office 2013 paradigm. Unfortunately, it causes the same error. I noticed that the stack trace mentions 'Promise rejected (async)'.
Note: the code is not optimized. Just trimmed to show data access.
// read data from the sheet
function readDataExportConfirm() {
Excel.run(function (ctx) {
// Create a proxy object for the active worksheet
var sheet = ctx.workbook.worksheets.getActiveWorksheet();
// auto select entire sheet
var range = sheet.getUsedRange();
// fill proxy objects
range.load('values');
console.log("fill proxy objects");
// sync on the request context synchronizes the state between
// proxy objects and objects in Excel doc
return ctx.sync().then(function () {
var selectedData = range.values;
console.log('data length: ' + selectedData.length + ' rows');
console.log('for row ' + 0 + ', got: ' + selectedData[0].length + ' columns');
// get rows
var rows = selectedData.length;
for (var row = 0; row < rows; row++) {
var cols = selectedData[row].length;
for (var col = 0; col < cols; col++) {
console.log(' for row ' + row + ', col ' + col
+ ' = ' +selectedData[row][col].toString());
}
}
});
})
.catch(function (error) {
// Always be sure to catch any accumulated errors that bubble up from the Excel.run execution
console.error("Error: " + error);
console.error("Error stack: " + error.stack);
if (error instanceof OfficeExtension.Error) {
console.error("Debug info: " + JSON.stringify(error.debugInfo));
}
});
}
Then used code from the page 'Work with Ranges using the Excel JavaScript API' at https://dev.office.com/docs/add-ins/excel/excel-add-ins-ranges in section "Get entire range" and get the same error with 'Promise rejected (async)' in the stack trace. Runs fine in Visual Studio 2015/Excel 2016.
Your help in resolving this is much appreciated.
Home.js:113 Error: GeneralException: An internal error has occurred. (anonymous) @ Home.js:113 Promise rejected (async)
Line 113 in Home.js is the console.error catch. Unfortunately, these do not tell me what is actually causing the issue. Contents are (tab delimited, fictional data):Name Street City, State ZIP Code Mr. & Mrs. Barry Hernandez 1919 Empire Ave. Anaheim, CA 92806 Billy Dane & Tony Harris 400 Carol Stream Portland, OR 97211 Dr. Deborah Spencer-Clark 567 Moulton Ave. Atlanta, GA 30318
– RickInLosAngeles