Я экспортирую некоторые данные в Excel.Работает нормально.Но теперь требуется загрузить тот же файл Excel в хранилище BLOB-объектов.Я могу загрузить файл непосредственно в BLOB, если я дам статический файл.Но не могли бы вы помочь мне, как я могу загрузить его в blob вместо экспорта или поделитесь своей идеей, если у вас есть.Ниже мой код экспорта.
public void ExportToExcel(DataTable table)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
ExcelPackage excel = new ExcelPackage();
var workSheet = excel.Workbook.Worksheets.Add(ddlModel.SelectedItem.Text + "_Support");
var totalCols = table.Columns.Count;
var totalRows = table.Rows.Count;
try
{
for (var col = 1; col <= totalCols; col++)
{
workSheet.Cells[1, col].Value = table.Columns[col - 1].ColumnName;
workSheet.Cells[1, col].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
workSheet.Cells[1, col].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
workSheet.Cells[1, col].Style.Font.Color.SetColor(System.Drawing.Color.Blue);
workSheet.Cells[1, col].Style.Font.Bold = true;
workSheet.Cells[1, col].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
workSheet.Cells[1, col].Style.WrapText = false;
workSheet.Cells[1, col].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);//Applying Borders
workSheet.Cells[1, col].AutoFitColumns(30);
}
for (var row = 1; row <= totalRows; row++)
{
for (var col = 0; col < totalCols; col++)
{
workSheet.Cells[row + 1, col + 1].Value = table.Rows[row - 1][col];
workSheet.Cells[row + 1, col + 1].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
workSheet.Cells[row + 1, col + 1].AutoFitColumns(30);
}
}
}
catch (Exception ex)
{
ExceptionLogging.SendErrorToText(ex);
Response.Redirect("~/CustomErrors/CustomError.aspx");
}
using (var memoryStream = new MemoryStream())
{
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment; filename=" + ddlModel.SelectedItem.Text + "_support" + ".xlsx");
excel.SaveAs(memoryStream);
memoryStream.WriteTo(Response.OutputStream);
Response.Flush();
Response.End();
}
}
, а вот мой метод BLOB-объектов, где я хочу передать URL файла.
BlobStorageFunctions.CallBlobGettingStartedSamples(fileURL).
Пожалуйста, предложите.