An Office service that supports add-ins to interact with objects in Office client applications.
Excel Javascript API : Unable to use any workbook and any other sheet while writing data in Excel is process.
Kishan Vaishnani
6
Reputation points
Hello,
I have developed an Excel Javascript plugin using the React framework.
The add-in workflow is simple.
- Request data from Ui using APIs
- Passing entities' column names and authorized API keys
- Start writing data into an active Excel sheet by pulling the button.
During the Excel data writing, the whole Excel workbook freezes, and I'm unable to use any other workbook until the data is written.
The maximum amount of data coming from APIs is 5-8K.
Below is the sample code.
try {
var i = 0;
// these data are coming from APIs
var allCompanies =[12,32,33,43,45,66,12,32,10,12,21,90];
allCompanies.forEach(async _company => {
// calling APIs for each _docs and writing data for that companies
await fetchData(_company).then(async (responseRows) => {
await Excel.run(async (context) => {
let sheet = context.workbook.worksheets.getActiveWorksheet();
sheet.load(["name"]);
await context.sync();
for (let i = 0; i < responseRows.length; i++) {
// data operations into Exel sheet
// creating table, table header, applying Css
// writting value to each cells
}
sheet.getUsedRange().format.autofitColumns();
sheet.getUsedRange().format.autofitRows();
await context.sync();
});
});
});
} catch (error) {
console.log("error on appending data into excel " + error);
}
Any solution will be helpful to me.
Thanks.
Microsoft 365 and Office | Development | Office JavaScript API
Microsoft 365 and Office | Development | Office JavaScript API
Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Development | Other
Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
Microsoft 365 and Office | Excel | For business | Windows
Microsoft 365 and Office | Excel | For business | Windows
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Sign in to answer