Anonymous
Не удалось загрузить файл или сборку SixLabors.Fonts ClosedXML NugetPackage
Сообщение
Anonymous » 04 дек 2024, 15:51
Когда я пытаюсь экспортировать таблицу базы данных в Excel с помощью пакета Nuget ClosedXML, я получаю эту ошибку в заголовке. Я попробовал это локально на локальном хосте, но все работает отлично.
Я проверил файлы dll. в производстве, и SixLabors.dll присутствует. Вот мой код
Я использую Asp .Net Core 6
Код: Выделить всё
public IActionResult ExportProductsToExcel()
{
const string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
string fileName = "Products " + DateTime.UtcNow.ToString().Replace("AM", "").Replace("PM", "") + ".xlsx";
try
{
using var stream = GetProductExcelStream();
var content = stream.ToArray();
return File(content, contentType, fileName);
}
catch (Exception ex)
{
Helpers.LogAPIResponse(_hostingEnvironment.WebRootPath, "ExportProductsToExcel", "Export products Logging", ex);
return View();
}
}
public MemoryStream GetProductExcelStream()
{
using var workbook = new XLWorkbook();
List vcproductCatalogs = _context.VcproductCatalogs.ToList();
var worksheet = workbook.Worksheets.Add("Products");
// worksheet.Cell(1, 1).Value = "Id";
worksheet.Cell(1, 1).Value = "Name";
worksheet.Cell(1, 2).Value = "SKU";
worksheet.Cell(1, 3).Value = "Description";
worksheet.Cell(1, 4).Value = "Format";
worksheet.Cell(1, 5).Value = "Vintage";
worksheet.Cell(1, 6).Value = "Appelation";
worksheet.Cell(1, 7).Value = "Classification";
worksheet.Cell(1, 8).Value = "Color";
worksheet.Cell(1, 9).Value = "Price";
worksheet.Cell(1, 10).Value = "Active";
worksheet.Cell(1, 11).Value = "Cover Image";
var index = 1;
foreach (VcproductCatalog product in vcproductCatalogs)
{
// worksheet.Cell(index + 1, 1).Value = category.Id;
worksheet.Cell(index + 1, 1).Value = product.Name;
worksheet.Cell(index + 1, 2).Value = product.Sku;
worksheet.Cell(index + 1, 3).Value = product.Description;
worksheet.Cell(index + 1, 4).Value = product.Format;
worksheet.Cell(index + 1, 5).Value = product.Vintage;
worksheet.Cell(index + 1, 6).Value = product.Appelation;
worksheet.Cell(index + 1, 7).Value = product.Classification;
worksheet.Cell(index + 1, 8).Value = product.Color;
worksheet.Cell(index + 1, 9).Value = product.Price;
worksheet.Cell(index + 1, 10).Value = product.Active.ToString();
worksheet.Cell(index + 1, 11).Value = product.CoverImage.Replace("\r\n", "");
index += 1;
}
worksheet.Columns().AdjustToContents();
worksheet.Rows().AdjustToContents();
// Change the first row color
for (int i = 1; i
Подробнее здесь: [url]https://stackoverflow.com/questions/76263421/could-not-load-file-or-assembly-sixlabors-fonts-closedxml-nugetpackage[/url]
1733316681
Anonymous
Когда я пытаюсь экспортировать таблицу базы данных в Excel с помощью пакета Nuget ClosedXML, я получаю эту ошибку в заголовке. Я попробовал это локально на локальном хосте, но все работает отлично. Я проверил файлы dll. в производстве, и SixLabors.dll присутствует. Вот мой код Я использую Asp .Net Core 6 [code] public IActionResult ExportProductsToExcel() { const string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; string fileName = "Products " + DateTime.UtcNow.ToString().Replace("AM", "").Replace("PM", "") + ".xlsx"; try { using var stream = GetProductExcelStream(); var content = stream.ToArray(); return File(content, contentType, fileName); } catch (Exception ex) { Helpers.LogAPIResponse(_hostingEnvironment.WebRootPath, "ExportProductsToExcel", "Export products Logging", ex); return View(); } } public MemoryStream GetProductExcelStream() { using var workbook = new XLWorkbook(); List vcproductCatalogs = _context.VcproductCatalogs.ToList(); var worksheet = workbook.Worksheets.Add("Products"); // worksheet.Cell(1, 1).Value = "Id"; worksheet.Cell(1, 1).Value = "Name"; worksheet.Cell(1, 2).Value = "SKU"; worksheet.Cell(1, 3).Value = "Description"; worksheet.Cell(1, 4).Value = "Format"; worksheet.Cell(1, 5).Value = "Vintage"; worksheet.Cell(1, 6).Value = "Appelation"; worksheet.Cell(1, 7).Value = "Classification"; worksheet.Cell(1, 8).Value = "Color"; worksheet.Cell(1, 9).Value = "Price"; worksheet.Cell(1, 10).Value = "Active"; worksheet.Cell(1, 11).Value = "Cover Image"; var index = 1; foreach (VcproductCatalog product in vcproductCatalogs) { // worksheet.Cell(index + 1, 1).Value = category.Id; worksheet.Cell(index + 1, 1).Value = product.Name; worksheet.Cell(index + 1, 2).Value = product.Sku; worksheet.Cell(index + 1, 3).Value = product.Description; worksheet.Cell(index + 1, 4).Value = product.Format; worksheet.Cell(index + 1, 5).Value = product.Vintage; worksheet.Cell(index + 1, 6).Value = product.Appelation; worksheet.Cell(index + 1, 7).Value = product.Classification; worksheet.Cell(index + 1, 8).Value = product.Color; worksheet.Cell(index + 1, 9).Value = product.Price; worksheet.Cell(index + 1, 10).Value = product.Active.ToString(); worksheet.Cell(index + 1, 11).Value = product.CoverImage.Replace("\r\n", ""); index += 1; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); // Change the first row color for (int i = 1; i Подробнее здесь: [url]https://stackoverflow.com/questions/76263421/could-not-load-file-or-assembly-sixlabors-fonts-closedxml-nugetpackage[/url]