 |
| VB How-To Ask your "How do I do this with VB?" questions in this forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 18th, 2010, 03:03 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
create excel file without excel.exe
Hello,
I want to create an excel file from all the data gathered in my application. The problem I have is that Excel is not installed on my PC so creating the xls file by means of communicating with Excel.exe (OLE, ActiveX, ...) is not an option.
Installing Excel on the PC also isn't an option since the PC's are used inside a production environment and installing Excel on every PC would simply cost too much.
So, in short, I'm looking for code/examples/dll's/third party toolkits that allow me to create an excel xls file from within my application.
Thanks in advance for all the help!
|
|

May 18th, 2010, 03:21 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
|
|
While I am pretty sure that you cannot create a native xls format file without having excel, at least you can do it easily, you can create a csv (Comma Seperated Values) file that excel can read easily. However, if you must have the native format, see http://www.wotsit.org/list.asp?search=xls
Good Luck
|
|
The Following User Says Thank You to vb5prgrmr For This Useful Post:
|
|
|

May 18th, 2010, 06:10 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
but some dlls are there?
if im using excel on some machines an error
"Class does not support automation or does not support expected interface" - Error No.430 came.
is there any remedy
i heard that some dll-s are available. i've googled, but nothing found. hope i get a solution here 
Last edited by ackid32; May 18th, 2010 at 08:25 AM..
|
|

May 18th, 2010, 09:30 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
|
|
That sounds more like a problem between versions of excel but without seeing the code that causes the problem I can only guess...
Good Luck
|
|

May 19th, 2010, 02:40 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
code
here it is
dim xx as new excel.application
dim yy as new excel.workbook
set yy=xx.workbooks.add in this line the error occurs
in my reference i add excel.exe
the problem is that this code work fine on my one system and not in the other (i installed office xp on both systems with same configurations)
could u find the solution?
thanks
|
|

May 19th, 2010, 02:49 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
|
|
Okay,... on your machine, design it as you have but before you compile it, change your code to use CreateObject (see your friends, yahoo, google, ask, answers, bing for "vb6 createobject excel application"). It is a simple enough change to make and also you will have to remove the reference to excel before you compile. Also, add error trapping to catch the error if it is unable to create the excel application object. If that is successful then pretty much everything else should be successful unless you have used something that is not a part of a previous version of excel and the machine your program is on has that previous version.
Good Luck
|
|

May 20th, 2010, 07:44 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
|
|
As vb5prgrmr has said, CSV files are the best option. You can save the CSV file as ".XLS". When the user opens it he needs to save a copy in Native Excel format
The best option would be to go for OpenXML and create Excel (.xlsx) file as an XML file through code
Cheers
Shasur
|
|

May 21st, 2010, 12:13 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Hi
Quote:
Originally Posted by vb5prgrmr
Okay,... on your machine, design it as you have but before you compile it, change your code to use CreateObject (see your friends, yahoo, google, ask, answers, bing for "vb6 createobject excel application"). It is a simple enough change to make and also you will have to remove the reference to excel before you compile. Also, add error trapping to catch the error if it is unable to create the excel application object. If that is successful then pretty much everything else should be successful unless you have used something that is not a part of a previous version of excel and the machine your program is on has that previous version.
Good Luck
|
I used the createobject method also but the result is same.
the error is '
"class does not support automation or does not support expected interface"
Error No-430
the same error with both type of codes
can u figure it out
|
|

May 21st, 2010, 12:15 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
multiple sheet
Quote:
Originally Posted by Shasur
As vb5prgrmr has said, CSV files are the best option. You can save the CSV file as ".XLS". When the user opens it he needs to save a copy in Native Excel format
The best option would be to go for OpenXML and create Excel (.xlsx) file as an XML file through code
Cheers
Shasur
|
is it possible to create CSV file with multiple sheets
|
|

May 21st, 2010, 03:51 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
|
|
Quote:
Originally Posted by ackid32
is it possible to create CSV file with multiple sheets
|
Unfortunately you can't CSV is for a sheet alone
|
|
 |