11Option Strict On
22Option Explicit On
33
4- Imports NUnit.Framework
4+ Imports CompuMaster.Epplus4.FormulaParsing.Excel.Functions.Text
55Imports CompuMaster.Excel.ExcelOps
6+ Imports NUnit.Framework
67Imports NUnit.Framework.Interfaces
78
89Namespace ExcelOpsTests.Engines
@@ -1287,7 +1288,7 @@ Namespace ExcelOpsTests.Engines
12871288# End Region
12881289
12891290# Region "Excel error values in cells"
1290- <Test> Public Sub LookupErrorCellValue(<Values( "invariant" , "de-DE" )> cultureName As String )
1291+ <Test> Public Sub LookupErrorCellValue(<Values( "invariant" , "de-DE" , "en-US" )> cultureName As String )
12911292 Dim TestControllingToolFileName As String = TestFiles.TestFileExcelOpsErrorValues.FullName
12921293 Dim TestSheet As String = "Tabelle1"
12931294
@@ -1298,28 +1299,37 @@ Namespace ExcelOpsTests.Engines
12981299
12991300 Console.WriteLine(eppeo.SheetContentMatrix(TestSheet, ExcelDataOperationsBase.MatrixContent.Errors).ToUIExcelTable)
13001301 '## Expected matrix like following
1301- '# |A |B |C |D |E
1302- '--+-------+------+-----+-----+-------
1303- '1 |#DIV/0!|#NAME?|#REF!|#NUM!|#VALUE!
1302+ '# |A |B |C |D |E |F
1303+ '--+-------+------+-----+-----+-----+----- --
1304+ '1 |#DIV/0!|#NAME?|#REF!|#REF!|# NUM!|#VALUE!
13041305
13051306 Assert.AreEqual( "#DIV/0!" , eppeo.LookupCellErrorValue( New ExcelOps.ExcelCell(TestSheet, "A1" , ExcelOps.ExcelCell.ValueTypes.All)))
13061307 Assert.AreEqual( "#NAME?" , eppeo.LookupCellErrorValue( New ExcelOps.ExcelCell(TestSheet, "B1" , ExcelOps.ExcelCell.ValueTypes.All)))
13071308 Assert.AreEqual( "#REF!" , eppeo.LookupCellErrorValue( New ExcelOps.ExcelCell(TestSheet, "C1" , ExcelOps.ExcelCell.ValueTypes.All)))
1308- Assert.AreEqual( "#VALUE!" , eppeo.LookupCellErrorValue( New ExcelOps.ExcelCell(TestSheet, "E1" , ExcelOps.ExcelCell.ValueTypes.All)))
1309+ Assert.AreEqual( "#REF!" , eppeo.LookupCellErrorValue( New ExcelOps.ExcelCell(TestSheet, "D1" , ExcelOps.ExcelCell.ValueTypes.All)))
1310+ Assert.AreEqual( "#VALUE!" , eppeo.LookupCellErrorValue( New ExcelOps.ExcelCell(TestSheet, "F1" , ExcelOps.ExcelCell.ValueTypes.All)))
13091311
13101312 'NOTE: Known expected behaviour for #NUM! error value is differently between the several engines
13111313 Select Case eppeo.EngineName
13121314 Case "Spire.Xls" , "FreeSpire.Xls" ', "Epplus (Polyform license edition)"
1313- Assert.AreEqual( Nothing , eppeo.LookupCellErrorValue( New ExcelOps.ExcelCell(TestSheet, "D1 " , ExcelOps.ExcelCell.ValueTypes.All)))
1315+ Assert.AreEqual( Nothing , eppeo.LookupCellErrorValue( New ExcelOps.ExcelCell(TestSheet, "E1 " , ExcelOps.ExcelCell.ValueTypes.All)))
13141316 Assert.Ignore(eppeo.EngineName & " is not fully compatible and doesn't show up with #NUM! error value in cell E1 (=10^1000)" )
13151317 Case Else
1316- Assert.AreEqual( "#NUM!" , eppeo.LookupCellErrorValue( New ExcelOps.ExcelCell(TestSheet, "D1 " , ExcelOps.ExcelCell.ValueTypes.All)))
1318+ Assert.AreEqual( "#NUM!" , eppeo.LookupCellErrorValue( New ExcelOps.ExcelCell(TestSheet, "E1 " , ExcelOps.ExcelCell.ValueTypes.All)))
13171319 End Select
13181320
13191321 End Sub )
13201322 End Sub
13211323
1322- <Test> Public Sub FindErrorCellsInWorkbook(<Values( "invariant" , "de-DE" )> cultureName As String )
1324+ <Test> Public Sub FindErrorCellsInWorkbook_LookupLastCell()
1325+ Dim TestControllingToolFileName As String = TestFiles.TestFileExcelOpsErrorValues.FullName
1326+ Dim TestSheet As String = "Tabelle1"
1327+ System.Console.WriteLine( "Testing XLSX: " & TestControllingToolFileName)
1328+ Dim eppeo As ExcelOps.ExcelDataOperationsBase = Me .CreateInstance(TestControllingToolFileName, ExcelDataOperationsBase.OpenMode.OpenExistingFile, New ExcelDataOperationsOptions(ExcelDataOperationsOptions.WriteProtectionMode.ReadOnly))
1329+ Assert.AreEqual( "F1" , eppeo.LookupLastCell(TestSheet).Address)
1330+ End Sub
1331+
1332+ <Test> Public Sub FindErrorCellsInWorkbook(<Values( "invariant" , "de-DE" , "en-US" )> cultureName As String )
13231333 Dim TestControllingToolFileName As String = TestFiles.TestFileExcelOpsErrorValues.FullName
13241334 Dim TestSheet As String = "Tabelle1"
13251335
@@ -1328,27 +1338,44 @@ Namespace ExcelOpsTests.Engines
13281338 Sub ()
13291339 Dim eppeo As ExcelOps.ExcelDataOperationsBase = Me .CreateInstance(TestControllingToolFileName, ExcelDataOperationsBase.OpenMode.OpenExistingFile, New ExcelDataOperationsOptions(ExcelDataOperationsOptions.WriteProtectionMode.ReadOnly))
13301340
1341+ Assert.AreEqual( "F1" , eppeo.LookupLastCell(TestSheet).Address)
13311342 Console.WriteLine(eppeo.SheetContentMatrix(TestSheet, ExcelDataOperationsBase.MatrixContent.Errors).ToUIExcelTable)
13321343 '## Expected matrix like following
1333- '# |A |B |C |D |E
1334- '--+-------+------+-----+-----+-------
1335- '1 |#DIV/0!|#NAME?|#REF!|#NUM!|#VALUE!
1344+ '# |A |B |C |D |E |F
1345+ '--+-------+------+-----+-----+-----+----- --
1346+ '1 |#DIV/0!|#NAME?|#REF!|#REF!|# NUM!|#VALUE!
13361347
13371348 Assert.AreEqual( 1 , eppeo.FindErrorCellsInWorkbook( "#DIV/0!" ).Count)
13381349 Assert.AreEqual( 1 , eppeo.FindErrorCellsInWorkbook( "#NAME?" ).Count)
1339- Assert.AreEqual( 1 , eppeo.FindErrorCellsInWorkbook( "#REF!" ).Count)
13401350 Assert.AreEqual( 1 , eppeo.FindErrorCellsInWorkbook( "#VALUE!" ).Count)
13411351
13421352 'NOTE: Known expected behaviour for #NUM! error value is differently between the several engines
13431353 Select Case eppeo.EngineName
1344- Case "Spire.Xls" , "FreeSpire.Xls" ', "Epplus (Polyform license edition)"
1345- Assert.AreEqual( 0 , eppeo.FindErrorCellsInWorkbook( "#NUM!" ).Count) 'Error detection not working (correctly) in engine
1346- Assert.AreEqual( 4 , eppeo.FindErrorCellsInWorkbook().Count)
1347- Assert.Ignore(eppeo.EngineName & " is not fully compatible and doesn't show up with #NUM! error value in cell E1 (=10^1000)" )
1348- Case Else
1354+ Case "Spire.Xls" , "FreeSpire.Xls"
1355+ Assert.AreEqual( Nothing , eppeo.LookupCellErrorValue(TestSheet, 0 , 3 ), "D1 >> #REF" ) 'Error detection not working (correctly) in engine at D1
1356+ Assert.AreEqual( "#NUM!" , eppeo.LookupCellErrorValue(TestSheet, 0 , 4 ), "E1 >> #NUM" ) 'Error detection not working (correctly) in engine at E1
1357+ Assert.AreEqual( 1 , eppeo.FindErrorCellsInWorkbook( "#NUM!" ).Count)
1358+ Assert.AreEqual( 1 , eppeo.FindErrorCellsInWorkbook( "#REF!" ).Count) 'Error detection not working (correctly) in engine at D1
1359+ Assert.AreEqual( 5 , eppeo.FindErrorCellsInWorkbook().Count)
1360+ 'Assert.Ignore(eppeo.EngineName & " is not fully compatible and doesn't show up with #NUM! error value in cell E1 (=SQRT(-1) alias =WURZEL(-1))")
1361+ Case "Epplus (Polyform license edition)"
1362+ Assert.AreEqual( Nothing , eppeo.LookupCellErrorValue(TestSheet, 0 , 3 ), "D1 >> #REF" ) 'Error detection not working (correctly) in engine at D1
13491363 Assert.AreEqual( 1 , eppeo.FindErrorCellsInWorkbook( "#NUM!" ).Count)
1364+ Assert.AreEqual( 1 , eppeo.FindErrorCellsInWorkbook( "#REF!" ).Count)
13501365 Assert.AreEqual( 5 , eppeo.FindErrorCellsInWorkbook().Count)
1366+ 'Assert.Ignore(eppeo.EngineName & " is not fully compatible and doesn't show up with #REF! error value in cell D1 (cell reference to a removed sheet (by EPPlus lib, which doesn't update formulas with #REF! on sheet removal)")
1367+ Case Else
1368+ Assert.AreEqual( 1 , eppeo.FindErrorCellsInWorkbook( "#NUM!" ).Count)
1369+ Assert.AreEqual( 2 , eppeo.FindErrorCellsInWorkbook( "#REF!" ).Count)
1370+ Assert.AreEqual( 6 , eppeo.FindErrorCellsInWorkbook().Count)
13511371 End Select
1372+
1373+ If eppeo.CalculationModuleDisabled = False Then
1374+ eppeo.RecalculateAll()
1375+ eppeo.RecalculateCell(TestSheet, 0 , 3 )
1376+ Console.WriteLine( "Values after explicit recalculation" )
1377+ Console.WriteLine(eppeo.SheetContentMatrix(TestSheet, ExcelDataOperationsBase.MatrixContent.Errors).ToUIExcelTable)
1378+ End If
13521379 End Sub )
13531380 End Sub
13541381
0 commit comments