Downloading a file or creating a workbook with new data using Excel api

Mike Young 0 Reputation points
2023-10-24T18:45:46.96+00:00

We have created a plugin for Excel that uses the Javascript Api (in typescript). We would like to allow the user to download a file that has some report data. The following code works in our plug in when we run excel in chrome, but not in the excel app on the mac.

    const file = new File(["foo"], "new-note.txt", {
      type: "text/plain",
    });
    const link = document.createElement("a");
    const url = URL.createObjectURL(file);

    link.href = url;
    link.download = file.name;
    document.body.appendChild(link);
    link.click();

    document.body.removeChild(link);
    window.URL.revokeObjectURL(url);

I know this is due to an issue with downloading a file in safari. Is there a way to do this using the Excel api?

Alternatively, we could create a new workbook with that data. But the examples for Excel.createWorkbook all involve using data from an existing workbook. Is there a way to use Excel.createWorkbook to create a workbook populated with new data, or to set values in the newly created workbook? Thanks!

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
1,620 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
914 questions
0 comments No comments
{count} votes