Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException on XLWorkbook.Save() #435

Closed
2 of 3 tasks
v0idname opened this issue Aug 9, 2017 · 3 comments
Closed
2 of 3 tasks

NullReferenceException on XLWorkbook.Save() #435

v0idname opened this issue Aug 9, 2017 · 3 comments
Milestone

Comments

@v0idname
Copy link

v0idname commented Aug 9, 2017

Do you want to request a feature or report a bug?

  • Bug
  • Feature

Version of ClosedXML

0.85.0, 0.86.0, 0.87.1, 0.88.0

What is the current behavior?

NullReferenceException on second call of XLWorkbook.Save() after XLWorksheet.Delete():

ClosedXML.Excel.XLWorkbook.DeleteSheetAndDependencies(WorkbookPart wbPart, String sheetId)
ClosedXML.Excel.XLWorkbook.<>c__DisplayClass94_0.<CreateParts>b__7(String ws)
System.Collections.Generic.List`1.ForEach(Action`1 action)
ClosedXML.Excel.XLWorkbook.CreateParts(SpreadsheetDocument document, Boolean evaluateFormulae)
ClosedXML.Excel.XLWorkbook.CreatePackage(String filePath, SpreadsheetDocumentType spreadsheetDocumentType, Boolean validate, Boolean evaluateFormulae)
ClosedXML.Excel.XLWorkbook.Save(Boolean validate, Boolean evaluateFormulae)
ClosedXML.Excel.XLWorkbook.Save()

Code to reproduce problem:

using ClosedXML.Excel;
public void Main()
{
    string fileName = ".\\test.xlsx";

    // file can be created manually or by ClosedXML:
    XLWorkbook book1 = new XLWorkbook();
    book1.AddWorksheet("sheet1");
    book1.AddWorksheet("sheet2");
    book1.SaveAs(fileName);

    XLWorkbook book2 = new XLWorkbook(fileName);
    book2.Worksheet(1).Delete();
    book2.Save();
    book2.Save();    // <- NullReferenceException
}
@v0idname v0idname changed the title NullReferenceException on Excel.XLWorkbook.Save() NullReferenceException on XLWorkbook.Save() Aug 9, 2017
@igitur
Copy link
Member

igitur commented Aug 9, 2017

Issue template clearly states: Attach the file.

@v0idname
Copy link
Author

v0idname commented Aug 9, 2017

I updated issue.
I didn't attach the file earlier, because I have an error with any file (created manually or by ClosedXML, empty or not).

@igitur
Copy link
Member

igitur commented Aug 23, 2017

ClosedXML v0.89.0-beta1 has been published and is ready for your testing.

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

No branches or pull requests

2 participants