473,378 Members | 1,456 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,378 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 10196
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.