Export to excel format file

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a db winform app with strongly types dataset. How can I run a query
on one of the tables and then export the result as an excel formatted file?
I don't need to write directly into an excel file jut that the output is
saved in excel format so another user can open it in excel.

Thanks

Regards
 
How?

Hi

I have a db winform app with strongly types dataset. How can I run a query
on one of the tables and then export the result as an excel formatted
file?
I don't need to write directly into an excel file jut that the output is
saved in excel format so another user can open it in excel.

Thanks

Regards

Output to csv file comma delimited, Excel will open the file just fine.
 
I would consider a third party grid that saves to Excel. I believe any of
the major vendors will do this, including Telerik, Dev Express, Component
One, Component Art, Syncfusion or even FarPoint Spread. It will cost less
than creating the functionality.

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think Outside the Box! |
********************************************
 
Hi

I have infragistics grid which does that. I am not concerned with UI part
rather to just use one of the tables in the backend database and export a
selection of its records to an excel format file.

Thanks

Regards
 
Hi

I have a db winform app with strongly types dataset. How can I run a query
on one of the tables and then export the result as an excel formatted file?
I don't need to write directly into an excel file jut that the output is
saved in excel format so another user can open it in excel.

Thanks

Regards

Look at these articles, very useful for exporting an Excel file:

http://vb.net-informations.com/excel-2007/vb.net_export_from_database_to_excel.htm
http://vb.net-informations.com/excel-2007/vb.net_export_from_datagridview_to_excel.htm
http://vb.net-informations.com/excel-2007/vb.net_excel_chart_export.htm

HTH,

Onur Güzel
 
One easy way to do this, from a UI standpoint, is by creating an HTML table
and changing the MIME type to Excel. If you simply want to download a table,
however, you can use someting like ExcelWriter (Software Artisans) to
produce an Excel spreadsheet. This will mean you forward the person to the
actual file and have to clean things (or you will have to stream out as an
Excel MIME type).

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think Outside the Box! |
********************************************
 
I've never tested it myself but you can use Excel as an OLEDB
datasource so I'll bet you can Insert/Update against it.
- Excel as Datasource threadhttp://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...

Sure, OleDB can be used to insert/update and select data from Excel.
Same website contains a good article on this:

http://vb.net-informations.com/excel-2007/vb.net_excel_inset_data_oledb.htm
http://vb.net-informations.com/excel-2007/vb.net_excel_update_data_oledb.htm

...without Interop. However i thought OP was trying to create an Excel
file from the scratch at server-side, that's why i pointed that
article that demonstrates using Interop.

Thanks,

Onur Güzel
 
Sure, OleDB can be used to insert/update and select data from Excel.
Same website contains a good article on this:

http://vb.net-informations.com/exce...ns.com/excel-2007/vb.net_excel_update_data_ol...

..without Interop. However i thought OP was trying to create an Excel
file from the scratch at server-side, that's why i pointed that
article that demonstrates using Interop.

Thanks,

Onur Güzel

If he is trying to create this on the server-side, then interop is a
bad idea. It would require Excel to installed on the server, and if
you have multiple sessions going, you would have multiple instances of
Excel running. Microsoft does not recommend that Office be run in
this manner on the server side.

The op is better off doing one of three things (2 of which have
already been mentioned):

1) Create a csv file
2) Create an html document
3) Create a SpreadsheetML document (this is the xml format from
0ffice2003, but it will still work in 2007).

He can set the mime-type to an excel document as already suggested,
and Excel will gladly open this document, and the user is none the
wiser :)
 
Hi

I have a db winform app with strongly types dataset. How can I run a query
on one of the tables and then export the result as an excel formatted file?
I don't need to write directly into an excel file jut that the output is
saved in excel format so another user can open it in excel.

Thanks

Regards

I would create a report, show it in a report viewer on a form and the
user then has the option to save it as an Excel spreadsheet. This has
the possible advantage that the user may be satisfied with the display
of the data in the report and only need to save when necessary. No
third party tools and a relatively easy way of adding the
functionality to your application.

HTH
 
Back
Top