簡體   English   中英

當使用Epplus的小計功能時,我得到“Excel發現不可讀的內容......”錯誤

[英]When use subtotal function with Epplus, I get “Excel found unreadable content in…” error

我的網頁上有一個由Epplus庫生成的簡單Excel文檔; 但是當我使用excel函數“subtotal”時,我收到以下錯誤:

Excel在...中找到了不可讀的內容

這是代碼:

protected void Page_Load(object sender, EventArgs e)
{
   ExcelPackage pck = new ExcelPackage();
   ExcelWorksheet ws = pck.Workbook.Worksheets.Add("hoja1");

   ws.Cells["A1"].Value = 1;
   ws.Cells["A2"].Value = 2;
   ws.Cells["A3"].Value = 3;
   ws.Cells["A1:A3"].Style.Numberformat.Format = "#,##0";

   ws.Cells["A4"].Formula= "SUBTOTAL(9;A1:A3)";

   Response.Clear();
   Response.AddHeader("content-disposition", 
        string.Format("attachment;filename=\"{0}\"", "Reporte.xlsx"));
   Response.ContentType = 
        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
   Response.BinaryWrite(pck.GetAsByteArray());
   Response.End();
}

和xml文檔詳細說明:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
   <logFileName>error057400_01.xml</logFileName>
   <summary>
      Se han detectado errores en el archivo "C:\xxxxxx\Content.IE5\MAW7NL0X\Reporte.xlsx"
   </summary>
   <removedRecords summary="Lista de registros eliminados:">
      <removedRecord>
          Registros quitados: Fórmula de /xl/worksheets/sheet1.xml parte
      </removedRecord>
</removedRecords></recoveryLog>

注意:如果我切換到使用以下功能,一切正常。 為什么我的小計不起作用?

ws.Cells["A4"].Formula= "SUM(A1:A3)";

不確定這是否是問題,但嘗試更換“;” 用“,”:

ws.Cells["A4"].Formula= "SUBTOTAL(9,A1:A3)";

祝好運。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM