Visual Studio Option Strict=On when working with Range.Value

dear support,


I am coding in VB .NET with the “Option Strict = ON” setting for enhanced type checking purposes.

however, i have an Aspose.Cells range object and I would like to get to the underlying values.

Without option strict, i can do
for each x as objetc in arange.value
next x

Obviously, this does not work with the option strict parameter set. Also, since range.Value can return an object, a one dimensional or a twodimensional objetc, this gives me problems to iterate over all underlying data

Any ideas ?

many thanks.


Hi,


Thanks for your posting and using Aspose.Cells.

We were able to observe this issue with the following code and by setting the Option strict On in VB.NET project as shown in this screenshot and found the issue.

This issue has been logged as

  • CELLSNET-45319 - Range.Value creates compilation problem when Option strict for VB.NET Project is ON

VB.NET
Dim cells As Cells = …

Dim arange As Range = cells.CreateRange(“A1:A1”)

For Each x As Object In arange.Value
Next x

Hi,

Thanks for using Aspose.Cells.

We have looked into this issue and found that it is not a bug. Please use the following code and it should fix your issue. Let us know your feedback.

VB.NET
Sub Main()
Dim workbook As Workbook = New Workbook("D:\\filetemp\book1.xlsx")
Dim cells As Cells = workbook.Worksheets(0).Cells

Dim arange As Range = cells.CreateRange("A1:B2")

If (arange.RowCount = 1 And arange.ColumnCount = 1) Then
Console.WriteLine(arange.Value)
Else
Dim a As Object(,) = DirectCast(arange.Value, Object(,))
For Each x As Object In a
Console.WriteLine(x)
Next x
End If
End Sub

will give it a try at the earliest

works great !!!

many thanks

Hi,


Good to know that your issue is sorted out by the suggested code. Feel free to write us back if you have further comments or questions, we will be happy to assist you soon.

Thank you.