Re: export dataset to excel in winform
- From: "Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT dot.state.fl.us>
- Date: Wed, 7 Sep 2005 08:29:23 -0400
Hi,
Take a look at this code, I'm using it and works great,
http://support.microsoft.com/default.aspx?scid=kb;EN-US;316934
Now, I do not need to create an excel table, I have embedded in my .EXE an
empty excel file with the format I need
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Hans [DiaGraphIT]" <hans.arsjo@xxxxxxx> wrote in message
news:89CBF363-6655-417D-B698-04AF205D7571@xxxxxxxxxxxxxxxx
> Hi!
>
> I want to export a dataset to an excel file. I found following code on
> the
> net...
> ( http://www.codeproject.com/csharp/Export.asp )
>
> Excel.ApplicationClass excel = new ApplicationClass();
>
> excel.Application.Workbooks.Add(true);
> DataTable table = DATASETNAME.Tables[0];
> int ColumnIndex=0;
> foreach(Datacolumn col in table.Columns)
> {
> ColumnIndex++;
> excel.Cells[1,ColumnIndex]=col.ColumnName;
> }
> int rowIndex=0;
> foreach(DataRow row in table.Row)
> {
> rowIndex++;
> ColumnIndex=0;
> foreach(DataColumn col in table.Columns)
> {
> ColumnIndex++;
> excel.Cells[rowIndex+1,ColumnIndex]=row.Cells[col.ColumnName].Text;
>
> }
> }
> excel.Visible = true;
> Work*** work*** = (Work***)excel.Active***;
> work***.Activate();
> )
>
>
> I asume that this code will work just fine for me, but how do I include an
> applicationclass for Excel?
>
> Do I need to include an excel.dll file for this occasion, and if so where
> do
> i find this dll fie?
>
>
> ---------------
> Best regards
> - Hans -
> ---------------
> (Have fun programming with ... C#)
.
- Follow-Ups:
- Re: export dataset to excel in winform
- From: Hans [DiaGraphIT]
- Re: export dataset to excel in winform
- References:
- export dataset to excel in winform
- From: Hans [DiaGraphIT]
- export dataset to excel in winform
- Prev by Date: Re: From ushot to byte[]
- Next by Date: Re: Keeping files together within .NET
- Previous by thread: RE: export dataset to excel in winform
- Next by thread: Re: export dataset to excel in winform
- Index(es):