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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
David SmithPosted Apr 27, 2010, 11:08 AM
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;
}
Dipa AhujaPosted Apr 27, 2010, 5:01 AM
David SmithPosted Apr 27, 2010, 4:38 AM
Dipa AhujaPosted Apr 27, 2010, 2:17 AM