Skip to content

Commit 0947549

Browse files
committed
improved MergedCells
* fixed unexpected situation: merged cell is nothing, but obviously can exist in collection of some XLSX files of real world sometimes, probably a bug in Epplus library after deleting sheets or merged cells?
1 parent f327617 commit 0947549

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

ExcelOps-EpplusFreeFixCalcsEdition/EpplusFreeExcelDataOperations.SharedCode.vb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,11 @@ Namespace ExcelOps
10681068
If Me.Workbook.Worksheets(sheetName) Is Nothing Then Throw New ArgumentOutOfRangeException(NameOf(sheetName), "Sheet not found: " & sheetName)
10691069
Dim AllMergedCells = Me.Workbook.Worksheets(sheetName).MergedCells()
10701070
For MyCounter As Integer = 0 To AllMergedCells.Count - 1
1071-
Result.Add(New ExcelOps.ExcelRange(sheetName, AllMergedCells(MyCounter)))
1071+
If AllMergedCells(MyCounter) IsNot Nothing Then
1072+
Result.Add(New ExcelOps.ExcelRange(sheetName, AllMergedCells(MyCounter)))
1073+
Else
1074+
'unexpected situation: merged cell is nothing, but obviously can exist in collection of some XLSX files of real world sometimes, probably a bug in Epplus library after deleting sheets or merged cells?
1075+
End If
10721076
Next
10731077
Return Result
10741078
End Function

0 commit comments

Comments
 (0)