Xtrareport如何绑定dataSet数据

 时间:2026-02-14 14:30:47

1、report.datasource直接放一个dataset或datatable


此种方法在代码里实现,直接为report赋数据源
特点:
-无须生成xml
-生成模板文件.repx中不包含表结构信息
-可用于特定表的使用,一旦将repx复制到其他地方,则无法根据repx生成表结构

Xtrareport如何绑定dataSet数据

2、XReport 代码如下 作用就是绑定一下数据

XREPORT代码在设计器界面右键显示

Xtrareport如何绑定dataSet数据

3、public XtraReport1(DataTable dt)        {            InitializeComponent();            this.DataSource = dt;            //这里面的Text是xrtable的属性 区分大小写

Xtrareport如何绑定dataSet数据

4、this.xrTableCell1.DataBindings.Add("Text",dt,"bid");            this.xrTableCell2.DataBindings.Add("Text", dt, "bname");            this.xrTableCell3.DataBindings.Add("Text", dt, "shuoming");            this.xrTableCell4.Text = "编号";            this.xrTableCell5.Text = "名称";            this.xrTableCell6.Text = "备注";

Xtrareport如何绑定dataSet数据

5、private void button1_Click(object sender, EventArgs e)        {            DataTable dt = new DataTable();            string constr = "server=192.168.100.222;user=sa;pwd=p@ssw1rd;database=pwd1";

Xtrareport如何绑定dataSet数据

6、SqlConnection con = new SqlConnection(constr);            try            {                con.Open();                SqlCommand com = new SqlCommand("select bid,bname,shuoming from book",con);                SqlDataAdapter dpt = new SqlDataAdapter(com);

Xtrareport如何绑定dataSet数据

7、dpt.Fill(dt);                XtraReport1 report = new XtraReport1(dt);                report.Landscape = true;                documentViewer1.DocumentSource = report;                report.CreateDocument();            }            catch (Exception)            {                                throw;            }        }

Xtrareport如何绑定dataSet数据

  • PLSQL Developer怎么使用内置HTML阅读器
  • 简单vb语言入门做到用电脑说出你想说的话
  • 使用Notepad++的宏来自动完成重复编辑操作
  • sqlserver数据库日志分离
  • 目前市场三大主流cms对比
  • 热门搜索
    皮肤晒伤后怎么办 如何清除浏览器缓存 小米助手怎么刷机 在网上如何赚钱 空调如何拆卸 reits是什么意思 大熊猫生活在哪里 如何端正人生态度 他们生活的世界 食指戴戒指是什么意思