Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
| Search | Today's Posts | Mark Forums Read
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
 
Old May 18th, 2010, 03:03 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default 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!
 
Old May 18th, 2010, 03:21 AM
Authorized User
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
Default

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:
ackid32 (May 18th, 2010)
 
Old May 18th, 2010, 06:10 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default 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..
 
Old May 18th, 2010, 09:30 AM
Authorized User
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
Default

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
 
Old May 19th, 2010, 02:40 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default 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
 
Old May 19th, 2010, 02:49 AM
Authorized User
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
Thanked 8 Times in 8 Posts
Default

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
 
Old May 20th, 2010, 07:44 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

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
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old May 21st, 2010, 12:13 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default Hi

Quote:
Originally Posted by vb5prgrmr View Post
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
 
Old May 21st, 2010, 12:15 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default multiple sheet

Quote:
Originally Posted by Shasur View Post
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
 
Old May 21st, 2010, 03:51 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Quote:
Originally Posted by ackid32 View Post
is it possible to create CSV file with multiple sheets
Unfortunately you can't CSV is for a sheet alone
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)




Similar Threads
Thread Thread Starter Forum Replies Last Post
Create excel file without Excel being installed NoXuS C# 4 August 29th, 2009 12:38 PM
Error when create Excel 2007 file in Visual Basic 2008 sektor Visual Basic 2008 Essentials 0 January 21st, 2009 03:58 AM
Create excel file in vb monika.vasvani VB Databases Basics 0 July 17th, 2008 10:24 PM
Problem in opening excel file in MS Excel 2000 kallol Visual C++ 0 November 16th, 2007 05:48 AM
Excel.exe error kliu9 Excel VBA 0 October 26th, 2004 05:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.