Exporting Report without reportviewer

private void MyReport()
{
DateTime date = DateTime.Now.AddMonths(-1);
string FileName = "MyReport_" + date.ToString("MMyyyy") + ".xls";
string path = @"d:\MyReportFolder\MyReport\";
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SqlConnection Sqlconnection = null;
SqlCommand cmdgetStatusreport;
if (!Directory.Exists(path + FileName))
{
try
{
Sqlconnection = new SqlConnection(ConnectionString);
Sqlconnection.Open();
cmdgetStatusreport = new SqlCommand("MyReport_sp",
Sqlconnection);
cmdgetStatusreport.CommandType = CommandType.StoredProcedure;
cmdgetStatusreport.CommandTimeout = 0;
SqlDataAdapter daStatusreport = new
SqlDataAdapter(cmdgetStatusreport);
SqlDataAdapter daStatusreport1 = new
SqlDataAdapter(cmdgetStatusreport);
daStatusreport.Fill(ds);
daStatusreport1.Fill(dt);
Sqlconnection.Close();
}
catch (Exception ex)
{
WriteFileMappingLog("Status ReportViewer: " +
ex.Message.ToString());
}
Microsoft.Reporting.WinForms.ReportViewer ReportViewer1 = new
ReportViewer();
ReportViewer1.Reset();
ReportViewer1.LocalReport.Dispose();
ReportViewer1.LocalReport.DataSources.Clear();
string rdlcpath = AppDomain.CurrentDomain.BaseDirectory.ToString()
+ @"\Report1.rdlc"; ;
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = rdlcpath;
//
"D:\\Sunil\\newDevelopement\\MyReport\\Report1.rdlc";
ReportViewer1.LocalReport.DataSources.Add(new
ReportDataSource("VMCMembershipDataSet_VMCAccount_StatusReport".ToString().Trim(),
ds.Tables[0]));
try
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
string deviceInfo = null;
byte[] bytes = ReportViewer1.LocalReport.Render(
"Excel", deviceInfo, out mimeType, out encoding,
out extension,
out streamids, out warnings);
// writing bytes to file
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
FileStream fs = new FileStream(path + FileName,
FileMode.Create,FileAccess.ReadWrite);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
catch (Exception ex)
{
WriteFileMappingLog("Status ReportViewer: render " +
ex.Message.ToString());
}
}
}