Solved

how to generate excel docs

Posted on 2002-04-04
16
209 Views
Last Modified: 2010-04-02
Does anyone know of components available to generate excel documents?  Even a good lead on how to do this using office web components would work well for me.

There are some out there, but are there good multithraded ones?

Its a little off topic but I'm willing to pay the points for a good lead :)

Thanks,
Chris
0
Comment
Question by:chrisshebib
  • 5
  • 5
  • 2
  • +3
16 Comments
 
LVL 4

Expert Comment

by:AssafLavie
ID: 6920068
The excell documents Are COM components.
For instance, you can instantiate Excel.Sheet or Excel.Application and use them to manipulate the data inside the sheet and save it somewhere. Anything you can do manually in excel you can do using it's object model.
Open VB and Add a Reference to the Excell library. Then swtich to the object browser and check out the structure of this API. It's very easy to use.
You can also see the full documentation about it in the MSDN site.
0
 

Author Comment

by:chrisshebib
ID: 6920075
My apologies, I should have expanded...

I'm looking for something that is thread safe.  If you use office, my understanding is that multiple document creation would be serialized due to the excel object being single threaded.  Its possible that I'm wrong on this but I don't think so.  

Also, I would prefer not to install office on the server in order to do this.

Again, I should have said.  Thanks for your response all the same though.

Chris
0
 
LVL 4

Expert Comment

by:AssafLavie
ID: 6920087
The fact that the access is serialized is what makes it thread safe.
If you want to use multiple threads you can create an object per thread.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 86

Expert Comment

by:jkr
ID: 6921567
BTW, DAO should be able to generate Excel sheets also - all you have to do is using a DB connect string like

"Excel 8.0; DATABASE=c:\\mypath\\myfile.xls"
0
 

Author Comment

by:chrisshebib
ID: 6921895
Really, that is pretty interesting.  Do you know where I could get more information on how this works?  I really know nothing about DAO.

I'm going to be getting my data back from an sql 2000 server, can I turn that into excel sheets?

Chris
0
 
LVL 86

Expert Comment

by:jkr
ID: 6921970
Hmm, can't test it right now, but IIRC Access allows to save in Excel format...
0
 
LVL 3

Expert Comment

by:jtm111
ID: 6922083
Dude, here is a link to a tutorial on accessing Excel via C++. It should point you in the right direction.

http://www.codeproject.com/com/xoffice.asp
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6922291
Here's the source I use as a reference:
   http://support.microsoft.com/default.aspx?scid=kb;EN-US;q179706
0
 

Author Comment

by:chrisshebib
ID: 6922300
Thank you.

This is using the Office suite to generate the documents though, I'm not able to use office at this point on a production server.  I'm considering writting a component to generate the BIF format from scratch but the effort would be significant.

Anyone know of any third party COM components out there that would do this already?
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6922302
Your best bet, then, is to create a comma separated value(CSV) file.  You can still load it with Excel and keep formulas in it.

It really depends on what you want to do with the data after you create it.

If you want fancy stuff, you'll need the Office stuff as I posted before.  If you just want the file to load in Excel, then many formats will work (CSV, TXT, etc.)
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6922309
Example...
This output (stored in a .CSV file)will load properly in Excel.
The developer must keep track of what's in each virtual cell:

"First","Second","Third","FORMULA"
1,2,3,"=a2+b3+c2"
4,5,6,"=a2+b2+c3"
0
 

Author Comment

by:chrisshebib
ID: 6922310
Well, what my end goal is, is to create many excel docs per day.  The docs will have images in them, and some basic formatting.  I don't want to use office on a production server.  It sounds like I'm left finding a third part component that will generate excel docs by writing out the BIF format, or creating my own component to do it.

I would have thought that office web components would have done this for sure, but it doens't unfortunately.
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6922314
I understand.
You don't have to load office on the production server.
All you need is the OLB/TLB file from MS Office to incorporate into your product.

If that's still too heavy, why not create HTML?
You can have that load pictures from remote locations and it's easily maintained.  You can have formatting and colors and pictures and active content and a lot of other stuff without having to have ANY third party products or even Office.
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6922697
Also (I forgot this part),
if you know about mime types, you can output the HTML to look like Excel.  The users would load the reports (I'm assuming reports) with the browser and the contents would look like a spreadsheet.  You can still have formatting and formulas (if necessary).
This would not require anything special of the server, but the users would need to have the necessary mime type registered on their machines.  Since your original target was Excel, I'm sure all of your potential users have Excel loaded -- therefore, no problem.
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 200 total points
ID: 6923027
0
 

Author Comment

by:chrisshebib
ID: 6926299
Thanks Triskelion, I appreciate your ideas.

I would very much prefer that we use HTML to do this, but the customer may not go for it.  Until then, investigation into excel generation continues....

Thanks again,
Chris
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question