VS2017、WPF使⽤报表⼯具RDLC完成报表,打印预览和直接打印
最近需要⽤到WPF做⼀个报表
然后经过各种查阅资料
终于整出来了⼀个Demo
软件是VS2017 framework是4.5
1.配置环境
⼯具,获取扩展和更新
generic是什么牌子打印机然后安装RDLC,然后重启
新建项⽬
项⽬的引⽤⾥⾯添加
System.Printing
System.Management
System.Drawing
NuGet包⾥⾯添加
Microsoft.ReportViewer V11.0.3366.16
2.创建实体类和数据集
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RDLCPrinter
{
public class Customer
{
public string carrierCompanyName { get; set; }        public string checkInTime { get; set; }
public string startPoint { get; set; }
public string outStock { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RDLCPrinter
{
class Plan
{
public string carrierCompanyName { get; set; }  //承运单位        public string driver { get; set; } //司机
public string driverId { get; set; } //司机id
public string vehicleNo { get; set; } //车牌号
public string mobile { get; set; } //电话
public string planNo { get; set; } //调度单号
public string startPoint { get; set; } //装点
public string endPoint { get; set; } //卸点
public string flowName { get; set; } //流向
public string prodName { get; set; } //品名
public string planWeight { get; set; } //重量
public string planQuantity { get; set; } //件数
public string remark { get; set; } //备注
public string cardNo { get; set; }
public string planStatusName { get; set; }//签到状态
public string checkInTime { get; set; }//签到时间
public string scanDateTime { get; set; }//扫码⽇期和时间        public string scanTime { get; set; }//扫码时间
public string outStock { get; set; }//仓库
}
}
然后创建两个数据集
数据集⾥ 右键 添加 DataTable把实体类的属性都加进去或者
⼯具箱 双击DataTable
加完之后是这样的
然后创建⼀个rdlc
左边 新建 数据集

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。