9

I would like to add comments at 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();

When try open the resulted "fileout.xlsx", it showed a dialog box saying to recover as much as possible... Then the recovered fileout.xlsx displays errors:

"Removed Part: /xl/comments1.xml part with XML error. (Comments) Load error. Line 5, column 0. Removed Part: /xl/comments5.xml part with XML error. (Comments) Load error. Line 5, column 24."

It appears that EPPlus produced a wrong format xml when there are comments. I would like to share my solutions for this problem:

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

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

I hope someone might be helped by this.

1
  • Thank you, this has helped me too. You should post your solution as an answer and accept that, if you can. Commented Mar 21, 2017 at 16:39

3 Answers 3

8

Some one suggested to post it as answer. Here it is:

The problem disappears if like this: I just added a NON-BLANK header line for the comments, such as "REF" here:

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

I hope someone might be helped by this.

Sign up to request clarification or add additional context in comments.

Comments

1

I see the same problem.for my instance,I use function AddComent with empty value in second parameter. at first ,my code like this:

ExcelRange range = newsheet.SelectedRange[1, 1];
newExcel.SetBGColor(range, Color.Red);
range.AddComment("no data", "");

then I change the last code like this:

range.AddComment("no data", "some body");

It works

Comments

1

You can add a space " " it works too.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.