-1

i have created the Excel table called 'subjectHubTable', where the data came ti this EXCEL context through a API endpoint.

    const addSubjectIntoSheet = async () => {
    const allSubjects = await hubReportService.getAllSubjects();
    const formatedSubjects = formatSubjectForExcel(allSubjects);
    //const formatedSubjects = allSubjects.map(({...rest}) => Object.values(rest));
    console.log("Formated");
    console.log(formatedSubjects);

    await Excel.run(async (context) => {

        const studentColumn = ["id", "Name", "Code", "academic_year", "department_code"];

        const currentWorksheet = context.workbook.worksheets.getActiveWorksheet();
        const subjectHubTable = currentWorksheet.tables.add('A1:E1', true);
        subjectHubTable.name = "subjectHubTable";

        subjectHubTable.getHeaderRowRange().values = [studentColumn];


        subjectHubTable.rows.add(null /*add at the end*/, formatedSubjects);
        
        //studentTable.columns.getItemAt(3).getRange().numberFormat = [["\u20AC#,##0.00"]];
        subjectHubTable.getRange().format.autofitColumns();
        subjectHubTable.getRange().format.autofitRows();

        await context.sync();
    });
};

Is there any founctionality to get the latest data to Excel Sheet from my custom API end points. like Refresh All in 'Data->Referesh / All' in the Excel Menu. or any possible way to achive this async data push into sheet

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Arun N
  • 1
  • 1

1 Answers1

0

I think the feature you want may not be supported now. And there doesn't seem to be any other way to achieve this except 'Data->Referesh / All'. Maybe you can add your request here: Microsoft 365 Developer Platform Ideas Forum.

SiruiMSFT
  • 46
  • 1