Excel Javascript API : The process automaticallyu exists without any error in console

Kishan Vaishnani 6 Reputation points
2023-05-03T06:13:11.18+00:00

Hello,

I have developed an Excel Javascript plugin using the React framework.

The add-in workflow is simple.

  1. Request data from Ui using APIs
  2. Passing entities' column names and authorized API keys
  3. Start writing data into an active Excel sheet by pulling the button.

During the Excel data writing, sometimes the ongoing process stopped without showing any error in the console pane.

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 Other
Microsoft 365 and Office Excel For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Hua-MSFT 27,796 Reputation points
    2023-05-03T07:26:07.65+00:00

    Hi @Kishan Vaishnani

    To help you better, I suggest you post new threads on other forums of following link.

    Excel add-ins developer community

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.