Can you save the report to PDF or HTML or any Pictureformat
I have a windows verision and want to distrubute my report.
/Anders
/Anders
using System;
using System.Data;
using System.IO;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
public class Demo : Form
{
private ReportViewer reportViewer;
private DataTable LoadSalesData()
{
// Load data from XML file
DataSet dataSet = new DataSet();
dataSet.ReadXml("data.xml");
return dataSet.Tables[0];
}
private void ExportMenuHandler(object sender, EventArgs e)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string fileNameExtension;
byte[] bytes = reportViewer.LocalReport.Render(
"Excel", null, out mimeType, out encoding, out fileNameExtension,
out streamids, out warnings);
using (FileStream fs = new FileStream("output.xls", FileMode.Create))
{
fs.Write(bytes, 0, bytes.Length);
}
MessageBox.Show("Report exported to output.xls", "Info");
}
public void AddMenu()
{
MainMenu mainMenu = new MainMenu();
MenuItem fileMenu = new MenuItem("&File");
MenuItem exportItem = new MenuItem("&Export");
exportItem.Click += new EventHandler(ExportMenuHandler);
fileMenu.MenuItems.Add(exportItem);
mainMenu.MenuItems.Add(fileMenu);
this.Menu = mainMenu;
}
private void Form_Load(object sender, EventArgs e)
{
// Set Processing Mode
reportViewer.ProcessingMode = ProcessingMode.Local;
// Set RDL file
reportViewer.LocalReport.ReportPath = "Report1.rdlc";
// Supply a DataTable corresponding to each report data source
reportViewer.LocalReport.DataSources.Add(
new ReportDataSource("Sales", LoadSalesData()));
// Process and render the report
reportViewer.RefreshReport();
}
public Demo()
{
this.Text = "Report Control Demo";
this.ClientSize = new System.Drawing.Size(950, 600);
AddMenu();
reportViewer = new ReportViewer();
reportViewer.Dock = DockStyle.Fill;
this.Controls.Add(reportViewer);
this.Load += new System.EventHandler(this.Form_Load);
}
[STAThread]
public static int Main(string[] args)
{
Application.Run(new Demo());
return 0;
}
}