Click here to Skip to main content
14,699,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

We have a windows forms aplicaition written in VB.Net. In the application, we are exporting data from the database into an Spread Builder Workbook and we are saving that workbook on local drive. Now i don't want to save the workbook on local drive and i want to open it for reading to the user. For this i want to do open the workbook of spreadbuilder type into microsoft excel type. but I am unable to convert this casting.

The error message that i am getting is "Unable to cast object of type 'DataDynamics.SpreadBuilder.Workbook' to type 'Microsoft.Office.Interop.Excel.Workbook'."

Can any one suggest me how to convert the datadynamics.spreadbuilder.workbook type to Excel workbook type or is there a way to open the spreadbuilder workbook without saving?

Any suggestions will be appreaciated.

Thanks for your support.
Posted

1 solution

You really have no choice but to save and reload it, unless SpreadBuilder exposes some method to do the conversion for you.

You have no shot at casting or converting the one object type to the other because neither of them is in the others inheritence chain.

Your only other method is to write a conversion yourself where you take the properties of one object and copy the values into the properties of an instance of the other. You'll, of course, have to take into account any child object and children of those children.
   
Comments
VNMRao 26-Nov-13 6:23am
   
Thanks for your reply.
Then in that case I will try to create the excel work book instead of spreadbuilder workbook when downloading the data from database and try to save that file. I dont know whether it will work or not.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900