当前位置:网站首页>C#实现水晶报表绑定数据并实现打印3-二维码条形码
C#实现水晶报表绑定数据并实现打印3-二维码条形码
2022-07-05 16:40:00 【coder i++】
C#实现水晶报表绑定数据并实现打印3-二维码条形码
在水晶报表中显示条形码/二维码
1、将数字或字符转换为条形码或二维码
2、将条形码或二维码在报表中展示
操作二维码的dll
zxing.net
参考:https://blog.csdn.net/xiaoyong_net/article/details/51242190
插入图片
参考:https://www.cnblogs.com/babyt/archive/2009/05/26/1490368.html
主要是如何读取本地图片显示在报表中。
如果是CR XI及以上版本,可以用更简便的方法,参考:水晶报表图片动态加载的另一种简单方案
本文的方法是:水晶报表中如何动态加载图片(图片文件版本及数据库版本) 中的图片文件版本。
本文适用于VS2003及VS2005自带版本的水晶报表,当然同样适用于CR XI及以上版本,就是烦了点。
本文使用VS2005及自带版本的水晶报表。
在这里,我把命题重新提炼一下:
已经有一个完整的报表,现在报表需要加载一个本地磁盘图片做为logo。报表中的Logo随着本地图片的变化自动变化。一般我们通过插入一个pictureobject来插入磁盘图片,但是插入后,图片就成为报表的一份,达不到变化的目的。
1、首先我们已经有一个单表的完整的水晶报表应用
2、为了能挂接我们的本地图片,在dataset里新建一个表mylogo。里面放上两个字段,字段类型为System.Byte[]或System.SByte[]
注意,默认类型里只有System.Bytet 和System.SByte,要自己输入的。
这个mylogo就是一个中介,我们把本地图片读到这个表里,水晶报表从这个表里读到图片显示。
3、在现有报表里加入一个子报表,数据源就是这个mylogo 把两个字段拖到子报表上。
4、代码是这样的
//设置数据源信息
DataSet1 ds1 = new DataSet1();
OleDbDataAdapter da = new OleDbDataAdapter();
String connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath ("~/app_data/test.mdb")+";";
OleDbConnection cn = new OleDbConnection(connstr);
//获取记录集,注意,最终获取的记录集需要与xsd的结构一致!
da = new OleDbDataAdapter("SELECT EmployeeId1 as EmployeeId,EmployeeName1 as EmployeeName From Employee1", cn);
da.Fill(ds1, "Employee");
//把本地图片先写入到数据集
//将图片读到stream,并转换为byte[]
//图片1
FileStream fs1 = new FileStream(@"c:\1.bmp", FileMode.Open, FileAccess.Read);
BinaryReader br1 = new BinaryReader(fs1);
byte[] bt1 = br1.ReadBytes((int)fs1.Length);
//图片2
FileStream fs2 = new FileStream(@"c:\a2.jpg", FileMode.Open, FileAccess.Read);
BinaryReader br2 = new BinaryReader(fs2);
byte[] bt2 = br2.ReadBytes((int)fs2.Length);
fs1.Close();
fs2.Close();
//写入到ds1中(仅1行)
ds1.myLogo.AddmyLogoRow(bt1, bt2);
//以上为数据部分,与报表无关
//-----------------------------------------------------------
//以下为报表部分
//使用报表对象加载报表
string reportPath = Server.MapPath("~/app_data/crystalreport1.rpt");
myReport.Load(reportPath);
//绑定数据集,注意,一个报表用一个数据集。
myReport.SetDataSource(ds1);
CrystalReportViewer1.ReportSource = myReport;
边栏推荐
- Is it safe to open a securities account by mobile phone? Detailed steps of how to buy stocks
- How can C TCP set heartbeat packets to be elegant?
- [Jianzhi offer] 62 The last remaining number in the circle
- What is ROM
- 【剑指 Offer】62. 圆圈中最后剩下的数字
- EasyX second lesson
- 机器学习编译第2讲:张量程序抽象
- Application of threshold homomorphic encryption in privacy Computing: Interpretation
- Jarvis OJ 简单网管协议
- Is it safe for qiniu business school to open a stock account? Is it reliable?
猜你喜欢

First day of learning C language

Summary of PHP pseudo protocol of cisp-pte

兰空图床苹果快捷指令

Scratch colorful candied haws Electronic Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022

Hiengine: comparable to the local cloud native memory database engine

SQL injection of cisp-pte (Application of secondary injection)
![[brush questions] effective Sudoku](/img/5b/3064170bebd1ccbee68d6a85d23830.png)
[brush questions] effective Sudoku

深耕5G,芯讯通持续推动5G应用百花齐放

Etcd build a highly available etcd cluster

Embedded -arm (bare board development) -2
随机推荐
Excuse me, is the redis syntax used in DMS based on the commands of the redis community version of the cloud database
【性能测试】全链路压测
easyNmon使用汇总
[wechat applet] read the life cycle and route jump of the applet
【剑指 Offer】66. 构建乘积数组
编译libssh2报错找不到openssl
Writing method of twig array merging
PHP人才招聘系统开发 源代码 招聘网站源码二次开发
Machine learning compilation lesson 2: tensor program abstraction
Precision epidemic prevention has a "sharp weapon" | smart core helps digital sentinels escort the resumption of the city
Learnopongl notes (I)
C# TCP如何限制单个客户端的访问流量
The third lesson of EasyX learning
CMake教程Step6(添加自定义命令和生成文件)
[Jianzhi offer] 62 The last remaining number in the circle
激动人心!2022开放原子全球开源峰会报名火热开启!
Is it safe to open a securities account by mobile phone? Detailed steps of how to buy stocks
Using C language to realize palindrome number
Deeply cultivate 5g, and smart core continues to promote 5g applications
Rider 设置选中单词侧边高亮,去除警告建议高亮