GotReportViewer http://www.gotreportviwer.com/
Generate RDLC dynamically (great)
namespace DynamicTable
{
public partial class Form1 : Form
{
private DataSet m_dataSet;
private MemoryStream m_rdl;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
OpenDataFile("test.xml", false);
}
private void ShowReport()
{
this.reportViewer1.Reset();
this.reportViewer1.LocalReport.LoadReportDefinition(m_rdl);
this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("MyData", m_dataSet.Tables[0]));
this.reportViewer1.RefreshReport();
}
private MemoryStream GenerateRdl(List<string> allFields, List<string> selectedFields)
{
MemoryStream ms = new MemoryStream();
RdlGenerator gen = new RdlGenerator();
gen.AllFields = allFields;
gen.SelectedFields = selectedFields;
gen.WriteXml(ms);
ms.Position = 0;
return ms;
}
private void DumpRdl(MemoryStream rdl)
{
using (FileStream fs = new FileStream(@"c:\test.rdlc", FileMode.Create))
{
rdl.WriteTo(fs);
}
}
private List<string> GetAvailableFields()
{
DataTable dataTable = m_dataSet.Tables[0];
List<string> availableFields = new List<string>();
for (int i = 0; i < dataTable.Columns.Count; i++)
{
availableFields.Add(dataTable.Columns[i].ColumnName);
}
return availableFields;
}
private void OpenDataFile(string filename, bool showOptionsDialog)
{
try
{
m_dataSet = new DataSet();
m_dataSet.ReadXml(filename);
List<string> allFields = GetAvailableFields();
ReportOptionsDialog dlg = new ReportOptionsDialog(allFields);
if (showOptionsDialog)
{
if (dlg.ShowDialog() != DialogResult.OK)
return;
}
List<string> selectedFields = dlg.GetSelectedFields();
if (m_rdl != null)
m_rdl.Dispose();
m_rdl = GenerateRdl(allFields, selectedFields);
DumpRdl(m_rdl);
ShowReport();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
OpenDataFile(openFileDialog1.FileName, true);
}
}
}
}
http://www.cnblogs.com/waxdoll/archive/2007/02/09/dynamic_serverreport_reportserver_database.html
http://spacefold.com/lisa/post/2008/05/25/Walkthrough-A-Simple-ish-Runtime-Quick-Report.aspx
http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition/ReportDefinition.xsd
http://spacefold.com/lisa/post/2009/07/26/YAPS-about-Dynamic-Layouts.aspx
http://www.codeproject.com/KB/reporting-services/DynamicReport.aspx
http://www.wangchao.net.cn/bbsdetail_546410.html (great)
http://www.cnblogs.com/wdxinren/archive/2006/08/23/484123.html (great)
http://blog.csdn.net/lgjlry/archive/2008/12/10/3492914.aspx (great)
http://www.pin5i.com/showtopic.aspx?topicid=19621&forumpage=1&onlyauthor=1
http://www.ureader.com/msg/115712546.aspx (great)
http://yorozuya.exeexe.net/vbdotnet_fyireporting/rdl0010.html (great)