I'm looking to retrieve and download all xlsx
files from a folder called myFolder
. I have two functions available: getExcelSheets
, which retrieves a list of all excel sheets, and @microsoft.graph.downloadUrl
, accessed by calling the getFileContentById
method. However, I am encountering difficulties in getting and converting the file into an xlsx
format.
import { Client } from "@microsoft/microsoft-graph-client";
import axios from "axios";
import * as MicrosoftGraph from "@microsoft/microsoft-graph-types";
export async function getExcelSheets(
template_name: string,
msgraph_client: Client,
): Promise<MicrosoftGraph.DriveItem[]> {
const result = await msgraph_client
.api(
`drives/{driver_id}/root:/myFolder/${template_name}:/children`
)
.get();
return result.value as MicrosoftGraph.DriveItem[];
}
export async function getFileContentById(download_url: string): Promise<any> {
const response = await axios.get(download_url);
return response;
}
If you have any tips on how to obtain and convert the file to xlsx
, I would greatly appreciate it. Currently, I am using the following method to convert the buffer to xlsx
:
xlsx.read(file, { type: "buffer" })