When you use an intermediate function with Epplus, I get the message "Excel found unreadable content in ..."

I have a simple Excel document created by the Epplus library on my web page; however, when I use the excel "subtotal" function, I get the following error:

Excel found unreadable content in ...

Here is the code:

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(); } 

And an XML document with details:

 <?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> 

Note. If I switch to using the following function, everything will work fine. Why is my debut not working?

 ws.Cells["A4"].Formula= "SUM(A1:A3)"; 
+4
source share
1 answer

Not sure if this is a problem or not, but try replacing ";" with ",":

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

Good luck.

+18
source

All Articles