Ciao,
ti basta farti un'applicazione Console che quindi diventi un exe che possa essere lanciato da windows, ed usare un codice di questo tipo:
public class ReportManager
{
static ReportViewer GetViewer(string path)
{
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = path;
viewer.Dock = DockStyle.Fill;
viewer.ShowPrintButton = false;
viewer.ShowExportButton = false;
viewer.ShowParameterPrompts = false;
return viewer;
}
public static byte[] Render(LocalReport report, string format)
{
//---queste ci vogliono
string mimeType;
string encoding;
string fileNameExtension;
string[] streams;
Warning[] warnings;
string deviceInfo = "<DeviceInfo>" +
"<PageHeight>29cm</PageHeight>" +
"<PageWidth>21cm</PageWidth>" +
"</DeviceInfo>";
return report.Render(format, deviceInfo, out mimeType,
out encoding,
out fileNameExtension, out streams,
out warnings);
}
public static void GeneraReport(string path, string fileDestinazione)
{
ReportViewer viewer = GetViewer(path);
LocalReport report = viewer.LocalReport;
byte[] bytes = Render(report, "PDF");
File.WriteAllBytes(fileDestinazione, bytes);
}
}
la tua applicazione console avrà un entrypoint di questo tipo:
[STAThread]
static void Main(string[] args)
{
//--- riceve in input il nome del report da renderizzare
//--- metto un valore di default se devi provarlo
if (args == null || args.Count() == 0)
args = new string[] { "ReportTest.rdlc" };
ReportManager.GeneraReport(args[0],"c:\\test.pdf");
}
Questo è un'esempio, tu adattalo e mettilo a posto come va meglio alla tua esigenza chiaramente...
Ciao.
Matteo Raumer
[MCAD .net, MVP Visual C#]
http://blogs.dotnethell.it/freeteo