1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
private void genererReport(ReportViewer reportViewer1, ReportParameter[] Trp, string rpt)
{
reportViewer1.LocalReport.ReportEmbeddedResource = "ServiceX.Reports." + rpt + ".rdlc";
reportViewer1.LocalReport.ReportPath = "";
reportViewer1.LocalReport.SetParameters(Trp);
reportViewer1.LocalReport.Refresh();
reportViewer1.RefreshReport();
string path = @"C:\ModelesRapports\";
string nAO = m_nAO.Replace("/", "_");
string pathAO = @"C:\ModelesRapports\" + nAO + @"\";
string nomFile = rpt + "_" + nAO;
string filename = pathAO + nomFile + ".DOC";
try
{
// writing bytes to file
if (!Directory.Exists(pathAO))
{
Directory.CreateDirectory(pathAO);
}
if (File.Exists(pathAO + filename))
{
File.Delete(pathAO + filename);
}
Byte[] mybytes = reportViewer1.LocalReport.Render("WORD");
using (FileStream fs = File.Create((filename)))
{
fs.Write(mybytes, 0, mybytes.Length);
}
}
catch (Exception ex)
{
}
} |
Partager