nissl-lab / npoi

a .NET library that can read/write Office formats without Microsoft Office installed. No COM+, no interop.
Apache License 2.0
5.74k stars 1.43k forks source link

IName.RefersToFormula raise an Exception on .Net Core 3.0+ #535

Closed b6g9 closed 3 years ago

b6g9 commented 3 years ago

XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet ws = (XSSFSheet)wb.CreateSheet("sheet1"); XSSFRow row = (XSSFRow)ws.CreateRow(0); row.CreateCell(0).SetCellValue("Name"); IName name = wb.CreateName(); name.RefersToFormula = "'sheet1'!$A$1:$A$1"; When I ran them on .Net Core 3.0+, may cause an Exception like: Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'stream') at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen) at System.IO.StreamReader..ctor(Stream stream) at NPOI.SS.Formula.Function.FunctionMetadataReader.CreateRegistry() at NPOI.SS.Formula.Function.FunctionMetadataRegistry.GetInstance() at NPOI.SS.Formula.Function.FunctionMetadataRegistry.GetFunctionByName(String name) at NPOI.SS.Formula.FormulaParser.IsValidCellReference(String str) at NPOI.SS.Formula.FormulaParser.ParseSimpleRangePart() at NPOI.SS.Formula.FormulaParser.ParseRangeable() at NPOI.SS.Formula.FormulaParser.ParseRangeExpression() at NPOI.SS.Formula.FormulaParser.ParseSimpleFactor() at NPOI.SS.Formula.FormulaParser.PercentFactor() at NPOI.SS.Formula.FormulaParser.PowerFactor() at NPOI.SS.Formula.FormulaParser.Term() at NPOI.SS.Formula.FormulaParser.AdditiveExpression() at NPOI.SS.Formula.FormulaParser.ConcatExpression() at NPOI.SS.Formula.FormulaParser.ComparisonExpression() at NPOI.SS.Formula.FormulaParser.IntersectionExpression() at NPOI.SS.Formula.FormulaParser.UnionExpression() at NPOI.SS.Formula.FormulaParser.Parse() at NPOI.SS.Formula.FormulaParser.Parse(String formula, IFormulaParsingWorkbook workbook, FormulaType formulaType, Int32 sheetIndex, Int32 rowIndex) at NPOI.XSSF.UserModel.XSSFName.set_RefersToFormula(String value) But when I change to .NET Framework 4.5.1+, they work fine. Could you help me, please? ps: my NPOI version is v2.5.2

tonyqus commented 3 years ago

Please rollback to 2.5.1. This is a known issue of 2.5.2.

tonyqus commented 3 years ago

duplicate with #517