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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
public void Print(
string Titre1,
string Titre2,
string Titre3,
Hashtable Tableau)
{
//Alimenter DataSet
Data.Temp Data = new ProBTP.Utils.Reporting.Data.Temp();
foreach (object key in Tableau.Keys)
{
Data.Tab2Cols.Rows.Add(new object[] {key, Tableau[key]});
}
//Initialiser le report
LocalReport report = new LocalReport();
report.ReportPath = @"Reports\HashTable.rdlc"; //A changer
report.GetParameters();
ReportParameter[] p = new ReportParameter[3];
p[0] = new
ReportParameter("Titre1", Titre1);
p[1] = new
ReportParameter("Titre2", Titre2);
p[2] = new
ReportParameter("Titre3", Titre3);
report.SetParameters(p);
report.DataSources.Add(new ReportDataSource("Temp_Tab2Cols", Data.Tab2Cols));
report.Refresh();
//Partie impression
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>EMF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.25in</MarginTop>" +
" <MarginLeft>0.25in</MarginLeft>" +
" <MarginRight>0.25in</MarginRight>" +
" <MarginBottom>0.25in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
m_streams = new List<Stream>();
report.Render("IMAGE", deviceInfo, CreateStream, out warnings);
foreach (Stream stream in m_streams)
stream.Position = 0;
if (m_streams == null || m_streams.Count == 0)
throw new Exception("Error: no stream to print.");
PrintDocument printDoc = new PrintDocument();
if (!printDoc.PrinterSettings.IsValid)
{
throw new Exception("Erreur : Impossible de trouver l'imprimante par défaut !");
}
else
{
printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
m_currentPageIndex = 0;
printDoc.Print();
}
} |
Partager