ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2016-01-25 08:48:29

Navasender
Member
Registered: 2015-06-09
Posts: 10

Memory WorkBook in VB NET

Hello Jing,

I am trying to extract data from a Memory Workbook in VB NET. I can load it without problem with the next sentece.

Public Workbook = ReoGridControl.CreateMemoryWorkbook

However, when I try to refer to one sheet:

        sheet = WorkbookModel.Worksheets("Sheet01")

give an error of type:  'System.MissingMemberException'  "public member Worksheets can't be found"

Could you tell me what I am doing wrong?

Thank you.

Offline

#2 2016-01-25 09:36:50

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Memory WorkBook in VB NET

Hi, what is the type of WorkbookModel, maybe you should use:

sheet = Workbook.Worksheets("Sheet01")

And, are you sure the sheet name is 'Sheet01' rather than 'Sheet1' ?

Offline

#3 2016-01-25 11:04:27

Navasender
Member
Registered: 2015-06-09
Posts: 10

Re: Memory WorkBook in VB NET

Sorry, the correct code is as follow. The name for my workbook is WorkbookModel

Public WorkbookModel = ReoGridControl.CreateMemoryWorkbook

sheet = WorkbookModel.Worksheets("Sheet01")

The problem is that WorksSheets doesn't appear as a member of the Workbook when I write  "WorkbookModel. "

Offline

#4 2016-01-25 13:00:48

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Memory WorkBook in VB NET

There should be an environment problem. Please try remove the DLL reference and add it again for your project. Also please tell me the version of ReoGrid you are using. Below is an example which I've tested now in VB.NET:

Dim worksheet = ReoGridControl.CreateMemoryWorkbook
Dim sheet = worksheet.Worksheets("Sheet1")
sheet("A1") = 123

Offline

#5 2016-01-25 16:19:24

Navasender
Member
Registered: 2015-06-09
Posts: 10

Re: Memory WorkBook in VB NET

I am using the version 0.9.3. The previous code work well when all is in the same subrrutine. The problem is when the object worksheet is a global variable like the following:
Module Test
Public workbook = ReoGridControl.CreateMemoryWorkbook

Public Sub LoadExcel()
        Dim sheet As Worksheet
        Dim path As String
        path = "C:\Users\Ant\Documents\ModelEst.xlsx"
        workbook.Load(path, IO.FileFormat.Excel2007)
        sheet = workbook.Worksheets("Sheet1")              'this sentence gives me an error
    End Sub
end module

Offline

#6 2016-01-26 00:52:50

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Memory WorkBook in VB NET

You must explicitly specify the type of class member variable since .NET compiler can't determine the type automatically for a class member. Try this:

Public workbook As IWorkbook = ReoGridControl.CreateMemoryWorkbook

And make sure you have imported the namespace at top:

Imports unvell.ReoGrid

Offline

#7 2016-01-26 06:27:48

Navasender
Member
Registered: 2015-06-09
Posts: 10

Re: Memory WorkBook in VB NET

Thank you very much. Now it works perfectly.

Offline

Board footer

Powered by FluxBB