Error "System.NullReferenceException" when create new instance of XLWorkbook.
Do you want to request a feature or report a bug?
- [x] Bug
- [ ] Feature
- [ ] Question
Did you test against the latest CI build?
- [x] Yes
- [ ] No
Version of ClosedXML
e.g. 0.95.4
What is the current behavior?
Error "System.NullReferenceException: Object reference not set to an instance of an object." when create new instance of XLWorkbook.
Excel workbook contains pivot tables.
Stack trace:
at ClosedXML.Excel.XLBorder.SetLeftBorder(XLBorderStyleValues value) in C:\projects\closedxml\ClosedXML\Excel\Style\XLBorder.cs:line 378
at ClosedXML.Excel.XLWorkbook.LoadBorderValues(BorderPropertiesType source, Func`2 setBorder, Func`2 setColor) in C:\projects\closedxml\ClosedXML\Excel\XLWorkbook_Load.cs:line 1982
at ClosedXML.Excel.XLWorkbook.LoadBorder(Border borderSource, IXLBorder border) in C:\projects\closedxml\ClosedXML\Excel\XLWorkbook_Load.cs:line 1971
at ClosedXML.Excel.XLWorkbook.LoadPivotStyleFormats(XLPivotTable pt, PivotTableDefinition ptd, PivotCacheDefinition pcd, Dictionary`2 differentialFormats) in C:\projects\closedxml\ClosedXML\Excel\XLWorkbook_Load.cs:line 1047
at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet) in C:\projects\closedxml\ClosedXML\Excel\XLWorkbook_Load.cs:line 785
at ClosedXML.Excel.XLWorkbook.LoadSheets(Stream stream) in C:\projects\closedxml\ClosedXML\Excel\XLWorkbook_Load.cs:line 49
What is the expected behavior or new feature?
Must create new instance of XLWorkbook.
Is this a regression from the previous version?
This problem occurs in version v0.95.3 and v0.95.4.
Reproducibility
Code to reproduce problem:
public XLWorkbook GetXLWorkbook(MemoryStream excelFile)
{
return new XLWorkbook(excelFile);
}
- [ ] I attached a sample spreadsheet. (You can drag files on to this issue)
I'm having the exact same issue, but when opening a file, not when creating a new one. I can't attach the sample file right now, because it contains sensitive data, but if I manage to reproduce the issue I wll.
Hello, I am having the same issue also when opening a file. Also have sensitive data in the file.
some file work and some file error on "Object reference not set to an instance of an object." I am using ClosedXML version 0.101.0
Code sample MyWorkBookStat = new WorkBookStat(); // reset streamExcel.Seek(0, SeekOrigin.Begin); var workbook = new XLWorkbook(streamExcel);
We have the same problem. But we use the path to open de excel file.
When I open and save the excel file. I'm able to read it using ClosedXML (0.101.0). But I'm unable to open it without saving it first in excel. Since I can't edit the file to remove sensitive data, I've created a diff report between the two files. I've removed the sharedStrings.xml file as it didn't contain any real differences and it contained sensitive data. Hopefully this diff report will help research this issue better. The file with the word COPY in it is the file that I was able to read after opening and saving it.
Hi, this problem for me resolved with update to 0.102.1