Chris McKelt

Remembering Thoughts

 

Recent comments

Archive

Authors

Categories

None


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012

Winforms export datatable to excel without COM+

Simple export of a datatable to excel without using COM+

Excel will ask if you want to open this as 'An XML List'

SaveFileDialog fileDialog = new SaveFileDialog();
fileDialog.Filter = "Excel files (*.xls)|*.xls";
fileDialog.FileName = "My_File_Name.xls";
fileDialog.ShowDialog();
DataTable dt = GetFilteredDataTable(DisplayedWorkbookView.EmployeesByFocusGroup);
using (FileStream fs = (FileStream)fileDialog.OpenFile())
{
using (StreamWriter sw = new StreamWriter(fs))
{
sw.Write("<?xml version=\"1.0\" standalone=\"yes\"?>");
dt.WriteXml(sw, XmlWriteMode.IgnoreSchema);
sw.Close();
}
fs.Close();
}

Posted by chris on Tuesday, July 22, 2008 8:02 AM
Permalink | Comments (5) | Post RSSRSS comment feed

Comments (5) -

Jim United Kingdom

Saturday, July 11, 2009 11:37 PM

Jim

Nice blog, just bookmarked it for later reference

Pierre Cardin United States

Tuesday, July 14, 2009 3:34 PM

Pierre Cardin

I like your blog curently we are looking for a part time article writer would you be interested?

Grohe United States

Thursday, September 30, 2010 5:52 PM

Grohe

Great website...and cool article man...thanx for the great post...keep on posting such articles... Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.

krishna charan India

Wednesday, October 06, 2010 11:36 PM

krishna charan

Nice article. thankx a lot .

serwery hp United States

Tuesday, October 26, 2010 12:29 PM

serwery hp

When I search for blogs I never know what I will find and that is half of the fun of it really. I was surprised I ran across yours though. It is excellent writing though. You have talent in there – keep it up.