Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

NullReferenceException when deleting a row with a comment in it (regression) #70

Closed
coxymla opened this issue Nov 24, 2017 · 1 comment

Comments

@coxymla
Copy link

coxymla commented Nov 24, 2017

We recently upgraded our EPPlus to latest from 4.0.4, and the library seems to have introduced a regression.
It happens when deleting a row that has a comment in it.

System.NullReferenceException : Object reference not set to an instance of an object.
   at OfficeOpenXml.ExcelCommentCollection.Delete(Int32 fromRow, Int32 fromCol, Int32 rows, Int32 columns)
   at OfficeOpenXml.ExcelWorksheet.DeleteRow(Int32 rowFrom, Int32 rows)

Minimal repro:

var documentPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\workbook with comment.xlsx");
var outputPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\WorkbookWithCommentOutput.xlsx");
var fileInfo = new FileInfo(documentPath);
Assert.IsTrue(fileInfo.Exists);
using (var workbook = new ExcelPackage(fileInfo))
{
    var ws = workbook.Workbook.Worksheets.First();
    ws.DeleteRow(3); // NRE thrown here
    workbook.SaveAs(new FileInfo(outputPath));
}

workbook with comment.xlsx

JanKallman added a commit that referenced this issue Jan 12, 2018
@JanKallman
Copy link
Owner

Fixed in 4.5.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants