有没有办法将 spreadsheetlight excel 文件直接写入 blob 存储?

Is there a way to write a spreadsheetlight excel file directly to blob storage?

我正在将一些旧的应用程序服务代码移植到 Microsoft Azure 中,需要一点帮助。

我正在从存储过程中提取一些数据并创建一个 SpreadsheetLight 文档(这是从旧代码中引入的,因为我的用户希望保留已经内置到该过程中的大量格式)。该代码工作正常,但我需要将文件直接写入我们的 azure blob 容器,而无需先保存本地副本(因为此过程将 运行 在管道中)。使用我找到的一些示例代码作为指南,我能够通过在本地保存然后将其上传到 blob 存储来使其在调试中工作......但现在我需要找到一种方法来删除本地保存之前上传。

好吧,我实际上是无意中找到了解决方案。

string connectionString = "YourConnectionString";
string containerName = "YourContainerName";
string strFileNameXLS = "YourOutputFile.xlsx";

BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
BlobContainerClient blobContainerClient = blobServiceClient.GetBlobContainerClient(containerName);
BlobClient blobClient = blobContainerClient.GetBlobClient(strFileNameXLS);

SLDocument doc = YourSLDocument();

using (MemoryStream ms = new MemoryStream())
{
    doc.SaveAs(ms);
    ms.Position = 0;
    await blobClient.UploadAsync(ms, true);
    ms.Close();
}