EPPLUS adds comment results when opening excel file

I would like to add comments in one cell, so .. I did:

  ... 
  ExcelPackage package = new ExcelPackage(new MemoryStream());
  var ws = package.WorkBook.WorkSheet[1];
  ws.Cells[1, 1].AddComment("Lot Price: $12,000", "");
  ... 
  package.SaveAs(new FileInfo("fileout.xlsx"));
  package.Dispose();

While trying to open the file "fileout.xlsx" above, it showed a dialog box that says to recover as much as possible ... Then, the restored .xlsx file displays errors:

"Remote part: /xl/comments1.xml part with an XML error. (Comments) Error loading. Line 5, column 0. Deleted part: /xl/comments5.xml with an XML error. (Comments) Download error. Line 5, column 24.

It seems that EPPlus produced the wrong xml format when there are comments. I would like to share my solutions on this issue:

I just added a NON-BLANK header line for comments such as "REF" here:

ws.Cells[1, 1].AddComment("Lot Price: $12,000", "REF");

I hope this helps someone.

+4
1

- . :

, : NON-BLANK , "REF" :

ws.Cells [1, 1].AddComment( " : $12 000", "REF" );

, - .

+1

Source: https://habr.com/ru/post/1667927/


All Articles