Export Access table to Excel
Can some assist on how to export mdb or access 2007 datatable to .xls
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Dipa AhujaRank #1,168 · 1.5K reputationPosted Apr 26, 2010, 10:17 PM EDT
David SmithRank #999 · 2K reputationPosted Apr 27, 2010, 12:38 AM EDT
Dipa AhujaRank #1,168 · 1.5K reputationPosted Apr 27, 2010, 1:01 AM EDT
David SmithRank #999 · 2K reputationPosted Apr 27, 2010, 7:08 AM EDT
I dont know if its the binding source or not. but its weird.
public void Export()
{
LocalReport lr = new LocalReport();
BindingSource bs = new BindingSource();
DatatabeDataSet test = new CLUDatatabeDataSet OpDatabaseDataSet();
bs.DataSource = test;
bs.DataMember = "Datatable";
// the ReportDataSource.Name must be the name of the class that is the DataSource
lr.DataSources.Add(new ReportDataSource("CLU_OpDatabaseDataSet_Datatable", bs));
// the ReportEmbeddedResource is the same as what is in the ReportViewer properties
lr.ReportEmbeddedResource = "EventLogSam.DatatableReport.rdlc";
string deviceInfo = "
"
"
"
"
Warning[] warnings;
m_streams = new List
try
{
lr.Render("Excel", deviceInfo, CreateStream, out warnings);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return;
}
foreach (Stream stream in m_streams)
stream.Position = 0;
}
private Stream CreateStream(string name, string fileNameExtension,
Encoding encoding, string mimeType, bool willSeek)
{
Stream stream = new FileStream(sExportPath, FileMode.Create);
m_streams.Add(stream);
return stream;
}