excel - "Open an existing file in Spreadsheetgear using VB.Net -
i trying open existing file in workbookview
(named wkbmain
in code given below) placed on windows form. using next code:
private sub menuitemopen_click(sender object, e eventargs) dim lobjdialog new openfiledialog wkbmain.getlock() seek if lobjdialog.showdialog() = dialogresult.ok wkbmain = spreadsheetgear.factory.getworkbook(lobjdialog.filename, system.globalization.cultureinfo.currentculture) end if grab ex exception wkbmain.releaselock() end seek end sub
but assignment
wkbmain = spreadsheetgear.factory.getworkbook(lobjdialog.filename, system.globalization.cultureinfo.currentculture)`)
throws exception:
unable cast object of type 'ᢷ' type 'spreadsheetgear.windows.forms.workbookview'.
please suggest solution
you need set workbookview.activeworkbook property object returned factory.getworkbook(...), not on workbookview object itself. example:
wkbmain.activeworkbook = spreadsheetgear.factory.getworkbook(lobjdialog.filename, system.globalization.cultureinfo.currentculture))
vb.net excel spreadsheetgear
No comments:
Post a Comment