Deleting a comment causes excel 2007 to choke on the file.
Here is a repro case:
[Test]
[Ignore("Run interactively as this spawns excel")]
public void TestCommentDelete()
{
var path = new FileInfo("test.xlsx");
// scope 1: write with a comment
{
var pack = new ExcelPackage();
var sheet = pack.Workbook.Worksheets.Add("test");
var cell = sheet.Cells[1, 1];
cell.Value = "hi";
cell.AddComment("hello world", "me");
pack.SaveAs(path);
}
// scope 2: read and remove the comment
{
var pack = new ExcelPackage(path);
var sheet = pack.Workbook.Worksheets["test"];
var cell = sheet.Cells[1, 1];
var comment = cell.Comment;
sheet.Comments.Remove(comment);
pack.Save();
}
// scope 3: read and make sure well formed
{
var pack = new ExcelPackage(path);
var sheet = pack.Workbook.Worksheets["test"];
var cell = sheet.Cells[1, 1];
var comment = cell.Comment;
Assert.IsNull(comment);
// now run excel - it will choke on it
Process.Start(new ProcessStartInfo(path.FullName));
}
And here is the recovery report from Excel 2007
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="
http://schemas.openxmlformats.org/spreadsheetml/2006/main">error133480_02.xmlErrors were detected in file 'D:\svn\main\trunk\Shared\Tests\bin\Debug\test.xlsx'</summary><removedParts summary="Following is a list of removed parts:"><removedPart>Removed Part: Drawing shape.</removedPart></removedParts></recoveryLog>