c# FastReport开发报表
2013-10-10 17:26
621 查看
本文介绍c#应用FastReport开发报表,因此首先附该工具下载地址:http://download.csdn.net/detail/hws1058648831a/6378499
下载解压后可以直接使用,里面还有相关实例供参考。
下面看看一个简单的例子:
1 打开visual studio 2010创建一个工程名称为WfmFastReport,编辑界面,然后添加FastReport.dll ,FastReport.Bars.dll,FastReport.Editor.dll的引用。
FastReport.dll ,FastReport.Bars.dll,FastReport.Editor.dll在下载包里有的。
代码非常简单,如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using FastReport;
using FastReport.Editor;
namespace WfmFastReport
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private DataSet data;
private void button1_Click(object sender, EventArgs e)
{
string conStr = @"server=***;user id=**;password=***;initial catalog=****";
try
{
SqlConnection con = new SqlConnection(conStr);
con.Open();
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.Connection = con;
sqlcmd.CommandText = "select top 100 * from item";
SqlDataAdapter sda = new SqlDataAdapter(sqlcmd);
data = new DataSet();
sda.Fill(data);
con.Close();
sda.Dispose();
MessageBox.Show("加载数据成功!");
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
try
{
FastReport.Report report = new FastReport.Report();
string filename = @"C:\Documents and Settings\Administrator\桌面\检查项目.frx";
report.Load(filename);
report.RegisterData(data);
report.GetDataSource(data.Tables[0].TableName).Enabled = true;
report.Show();
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
}
}
检查项目.frx文件就是FastReport设计出的报表模板,非常简单,有兴趣的朋友可以试一试。
下面看看效果:
下载解压后可以直接使用,里面还有相关实例供参考。
下面看看一个简单的例子:
1 打开visual studio 2010创建一个工程名称为WfmFastReport,编辑界面,然后添加FastReport.dll ,FastReport.Bars.dll,FastReport.Editor.dll的引用。
FastReport.dll ,FastReport.Bars.dll,FastReport.Editor.dll在下载包里有的。
代码非常简单,如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using FastReport;
using FastReport.Editor;
namespace WfmFastReport
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private DataSet data;
private void button1_Click(object sender, EventArgs e)
{
string conStr = @"server=***;user id=**;password=***;initial catalog=****";
try
{
SqlConnection con = new SqlConnection(conStr);
con.Open();
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.Connection = con;
sqlcmd.CommandText = "select top 100 * from item";
SqlDataAdapter sda = new SqlDataAdapter(sqlcmd);
data = new DataSet();
sda.Fill(data);
con.Close();
sda.Dispose();
MessageBox.Show("加载数据成功!");
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
try
{
FastReport.Report report = new FastReport.Report();
string filename = @"C:\Documents and Settings\Administrator\桌面\检查项目.frx";
report.Load(filename);
report.RegisterData(data);
report.GetDataSource(data.Tables[0].TableName).Enabled = true;
report.Show();
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
}
}
检查项目.frx文件就是FastReport设计出的报表模板,非常简单,有兴趣的朋友可以试一试。
下面看看效果:
相关文章推荐
- c# FastReport开发报表
- FastReport for .Net 报表开发实例(C#源码下载)
- c# FastReport开发报表
- C#报表开发工具ReportViewer vs Stimulsoft Reports.Net
- FastReport.Net C#程序邦定报表模版
- Fastreport.net 如何在开发MVC应用程序时使用报表
- FastReport for.Net开发指南-主从表(Master/Detail)报表设计详解
- 在C#中根据Excel文件画FastReport .NET报表模板
- FastReport.Net_ C#程序邦定报表模版
- 我的开发履历:FAST-REPORT 报表工具接口封装.2006.8
- FastReport ASP.Net开发Web报表时直接打印的问题
- FastReport.Net C#程序邦定报表模版
- 使用C#和Excel进行报表开发(七)-设置单元格的显示格式
- C#报表控件ReportViewer rdlc 例(4)
- 转载 使用ActiveReport for .net 进行报表开发
- 浅谈FastReport. Net报表样式风格,事实上多数人都低估了其作用
- FastReport.net在用户的应用程序中创建报表
- 使用C#和Excel进行报表开发(三)-生成统计图(Chart)5
- 使用C#和Excel进行报表开发(二)-操作统计图
- 使用C#和Excel进行报表开发(二)-操作统计图(Chart)