【发布时间】:2021-08-15 21:44:04
【问题描述】:
我需要从myFolder 下载所有xlsx 文件我有两种方法getExcelSheets 来获取所有excel 工作表列表
然后使用此信息通过调用getFileContentById 方法使用@microsoft.graph.downloadUrl 下载文件,但我未能获取并将其转换为xlsx 格式
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;
}
关于我如何获取文件然后将其转换为xlsx的任何提示我正在使用此方法将缓冲区转换为xlsx
xlsx.read(file, { type: "buffer" })
【问题讨论】:
标签: excel typescript microsoft-graph-api xlsx