473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Generate an Excel file (without Excel)


I want to generate an Excel file (.xls format) from some database data.

I don't want to use Excel.exe because of all the automation and security
issues.

Does Microsoft document the .xls file format anywhere?

Feb 26 '07 #1
9 10200
On Mon, 26 Feb 2007 08:41:29 -0800, John Bailo wrote:
I want to generate an Excel file (.xls format) from some database data.

I don't want to use Excel.exe because of all the automation and security
issues.

Does Microsoft document the .xls file format anywhere?
I don't think documenting the format would be of much use, because
'recreating excel is just not worth the bother. You do though have a couple
of options:

- You could use the well documented XML Excel format, if your clients have
a version of Excel capable of opening the same. You code would thus spit
out Excel XML
- Even easier, You could use a third party library to generate the files.
Aspose make a pretty fully functional library for this.
--
Bits.Bytes
http://bytes.thinkersroom.com
Feb 26 '07 #2

This looks like a good library on SourceForge:

http://sourceforge.net/projects/koogra/

".Net implementation of an Excel file reader for reading unencrypted
Excel 97 and up BIFF based files."

I'm wondering if it can write the files as well...

Rad [Visual C# MVP] wrote:
On Mon, 26 Feb 2007 08:41:29 -0800, John Bailo wrote:

>>I want to generate an Excel file (.xls format) from some database data.

I don't want to use Excel.exe because of all the automation and security
issues.

Does Microsoft document the .xls file format anywhere?


I don't think documenting the format would be of much use, because
'recreating excel is just not worth the bother. You do though have a couple
of options:

- You could use the well documented XML Excel format, if your clients have
a version of Excel capable of opening the same. You code would thus spit
out Excel XML
- Even easier, You could use a third party library to generate the files.
Aspose make a pretty fully functional library for this.
Feb 26 '07 #3
PS

"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:1i****************@thinkersroom.com...
On Mon, 26 Feb 2007 08:41:29 -0800, John Bailo wrote:
>I want to generate an Excel file (.xls format) from some database data.

I don't want to use Excel.exe because of all the automation and security
issues.

Does Microsoft document the .xls file format anywhere?

I don't think documenting the format would be of much use, because
'recreating excel is just not worth the bother. You do though have a
couple
of options:

- You could use the well documented XML Excel format, if your clients have
a version of Excel capable of opening the same. You code would thus spit
out Excel XML
- Even easier, You could use a third party library to generate the files.
Aspose make a pretty fully functional library for this.
TMS Software (www.tmssoftware.com) have a product called FlexCel that costs
125 Euros.

PS
--
Bits.Bytes
http://bytes.thinkersroom.com

Feb 26 '07 #4
On Mon, 26 Feb 2007 08:41:29 -0800, John Bailo <ja*****@texeme.comwrote:

¤
¤ I want to generate an Excel file (.xls format) from some database data.
¤
¤ I don't want to use Excel.exe because of all the automation and security
¤ issues.
¤
¤ Does Microsoft document the .xls file format anywhere?

You can create an Excel Workbook file using Jet OLEDB and Jet SQL:

Dim ConnectionString As String

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Test Files\ExcelWB.xls;Extended Properties=Excel 8.0"

Dim ExcelConnection As New System.Data.OleDb.OleDbConnection(ConnectionString )
ExcelConnection.Open()

Dim SQLDDLCommand As String = "CREATE TABLE tblCustomers " & _
"(CustomerID INTEGER, " & _
"[Last Name] TEXT(50), " & _
"[First Name] TEXT(50), " & _
"Phone TEXT(10), " & _
"Email TEXT(50))"

Dim ExcelCommand As New System.Data.OleDb.OleDbCommand(SQLDDLCommand, ExcelConnection)
ExcelCommand.ExecuteNonQuery()

ExcelConnection.Close()
Paul
~~~~
Microsoft MVP (Visual Basic)
Mar 9 '07 #5
Kam

Any idea how to apply an existing template when saving the file?!

I am producing a CSV file which I then want to save as xls using a
particular template.

Any help would highly be appreciated. Thank you.

Kam

Paul Clement wrote:
On Mon, 26 Feb 2007 08:41:29 -0800, John Bailo <ja*****@texeme.comwrote:

¤
¤ I want to generate an Excel file (.xls format) from some database data.
¤
¤ I don't want to use Excel.exe because of all the automation and security
¤ issues.
¤
¤ Does Microsoft document the .xls file format anywhere?

You can create an Excel Workbook file using Jet OLEDB and Jet SQL:

Dim ConnectionString As String

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Test Files\ExcelWB.xls;Extended Properties=Excel 8.0"

Dim ExcelConnection As New System.Data.OleDb.OleDbConnection(ConnectionString )
ExcelConnection.Open()

Dim SQLDDLCommand As String = "CREATE TABLE tblCustomers " & _
"(CustomerID INTEGER, " & _
"[Last Name] TEXT(50), " & _
"[First Name] TEXT(50), " & _
"Phone TEXT(10), " & _
"Email TEXT(50))"

Dim ExcelCommand As New System.Data.OleDb.OleDbCommand(SQLDDLCommand, ExcelConnection)
ExcelCommand.ExecuteNonQuery()

ExcelConnection.Close()
Paul
~~~~
Microsoft MVP (Visual Basic)
Mar 14 '07 #6
On Wed, 14 Mar 2007 14:57:09 +0000, Kam <ka**@NOSPAM.comwrote:

¤
¤ Any idea how to apply an existing template when saving the file?!
¤
¤ I am producing a CSV file which I then want to save as xls using a
¤ particular template.
¤
¤ Any help would highly be appreciated. Thank you.
¤

Template files are only known by Microsoft Excel, so you would have to create the Workbook using the
Excel application first.
Paul
~~~~
Microsoft MVP (Visual Basic)
Mar 14 '07 #7
Kam
I got a custom template ready in a local folder, are you saying that I
would not be able to use it when saving the workbook from C# application?!
Thanks for the quick response.
Kam

Paul Clement wrote:
On Wed, 14 Mar 2007 14:57:09 +0000, Kam <ka**@NOSPAM.comwrote:

¤
¤ Any idea how to apply an existing template when saving the file?!
¤
¤ I am producing a CSV file which I then want to save as xls using a
¤ particular template.
¤
¤ Any help would highly be appreciated. Thank you.
¤

Template files are only known by Microsoft Excel, so you would have to create the Workbook using the
Excel application first.
Paul
~~~~
Microsoft MVP (Visual Basic)
Mar 14 '07 #8
On Wed, 14 Mar 2007 15:55:45 +0000, Kam <ka**@NOSPAM.comwrote:

¤ I got a custom template ready in a local folder, are you saying that I
¤ would not be able to use it when saving the workbook from C# application?!
¤

No, what I am saying is that you can't use ADO.NET to do it. Instead you would need to use
automation with the Excel application.

http://support.microsoft.com/kb/302084
Paul
~~~~
Microsoft MVP (Visual Basic)
Mar 16 '07 #9
Kam
Firstly, apologise for the not getting back to you any earlier as I was
dealing with other probs and projects...

Anyhow, the process is as follow:

- Produce an XML document which then passed to BizTalk server to process

- BizTalk could either produce XML or CSV file but not Excel spreedsheet

- I got a local spreedsheet template that I need to utilise when
creating the Excel file (i.e. Mapping the XML document to Excel)

I need to be able to map the XML to Excel in code and utilise the
template to store the Excel file.

Any sample code or links or suggestions will highly be appreciated.

Thank you and hope to hear from you very soon.........

Kam


Paul Clement wrote:
On Wed, 14 Mar 2007 15:55:45 +0000, Kam <ka**@NOSPAM.comwrote:

¤ I got a custom template ready in a local folder, are you saying that I
¤ would not be able to use it when saving the workbook from C# application?!
¤

No, what I am saying is that you can't use ADO.NET to do it. Instead you would need to use
automation with the Excel application.

http://support.microsoft.com/kb/302084
Paul
~~~~
Microsoft MVP (Visual Basic)
Mar 23 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: shank | last post by:
<% Response.contenttype = "application/vnd.ms-excel" %> <% Response.AddHeader "Content-Disposition", "filename=hardware.xls" %> I'm using the above lines to generate a spreadsheet from a...
0
by: mscir | last post by:
Date: Thu, 08 Jul 2004 17:02:27 -0700 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <10ero4l3kp2qa65@corp.supernews.com> Reply-To: mscir@usa.com User-Agent: Mozilla/5.0...
2
by: Tools | last post by:
WinTranslator & MacTranslator Demo Editions Generate Design Diagrams from Your Source Code in Minutes Placitas, NM ? April 5, 2004 - Excel Software is pleased to announce the immediate...
3
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet...
0
by: Mike Knight | last post by:
(I've also posted this problem on microsoft.public.excel.programming) I have a MS Access 2003 Database named "AS400 Fields.mdb". This database contains links to tables on an AS400. In MS...
5
by: ken | last post by:
how ASP.NET to generate excel report(office 2003) to client what component i need to reference into the asp.net application and what component i need to install to the server? Moreover, does it...
3
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office...
3
by: Maxwell2006 | last post by:
Hi, We have Excel 2003 templates and we need to automatically generate excel 2003 xls files based on our SQL server database tables' data. Since we need to generate the xls files at out asp.net...
18
by: John Bailo | last post by:
I want to write an Excel file (.xls format) from some database data. I don't want to use Excel.exe because of all the automation and security issues. Does Microsoft document the .xls file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.