vb.net 如何在 SSRS 中显示二维码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36811438/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 19:50:15  来源:igfitidea点击:

How do I show a qr code in SSRS?

c#sql-servervb.netreporting-servicesreportbuilder

提问by Douglas Acosta

I am in the quest to build a report in ssrs/report builder that contains a qr code, is it possible to achieve this?

我正在寻求在 ssrs/report builder 中构建一个包含 qr 代码的报告,有可能实现吗?

I was thinking in implementing a class using c#/vb.net that codes any url/mail address into a QR Code and then import that code into the report to use it.

我正在考虑使用 c#/vb.net 实现一个类,该类将任何 url/邮件地址编码为二维码,然后将该代码导入报告中以使用它。

What would be your advice?

你的建议是什么?

回答by Vladislav

Generate QR Code? barcodes in an SSRS report with the QRCoder library

生成二维码?带有 QRCoder 库的 SSRS 报告中的条形码

These are the steps required to create an SSRS report that displays QR code symbols using the QRCoder library:

  1. Obtain existing or compile the two QRCoder assemblies with strong names and the PartiallyTrustedCallers attribute
  2. Install the two assemblies to the global assembly cache (GAC) using the gacutil.exe utility
  3. Create a new SSRS report that queries a table of test data
  4. Add a reference to the QRCoderImageToByteArray GAC assembly
  5. Add a custom code function that sends a string to the QRCoderImageToByteArray assembly and accepts a byte array in return
  6. Add a field to the report and increase the physical dimensions of the field to accomodate a larger QR code symbol
  7. Drag-and-drop an image componenet to the new field to bring up the image properties dialogue
  8. Change the image source to Database, add a function that references the custom code function and change the MIME type to image/png
  9. Set the size property of the image component to fill the available field space while maintaining the original aspect ratio
  10. Execute the report to display the data and the QR code generated from the data

以下是使用 QRCoder 库创建显示 QR 代码符号的 SSRS 报告所需的步骤:

  1. 使用强名称和 PartiallyTrustedCallers 属性获取或编译两个 QRCoder 程序集
  2. 使用 gacutil.exe 实用程序将两个程序集安装到全局程序集缓存 (GAC)
  3. 创建一个新的 SSRS 报告来查询测试数据表
  4. 添加对 QRCoderImageToByteArray GAC 程序集的引用
  5. 添加自定义代码函数,将字符串发送到 QRCoderImageToByteArray 程序集并接受字节数组作为回报
  6. 向报告添加字段并增加字段的物理尺寸以容纳更大的二维码符号
  7. 将图像组件拖放到新字段以显示图像属性对话框
  8. 将图片源改为Database,添加引用自定义代码函数的函数,将MIME类型改为image/png
  9. 设置图像组件的大小属性以填充可用字段空间,同时保持原始纵横比
  10. 执行报表显示数据和数据生成的二维码

This solution based on QRCoder.

此解决方案基于QRCoder

The main points are to register assemblies in GAC, write code calling these assemblies from the report: custom report function

要点是在GAC中注册程序集,编写代码从报告中调用这些程序集: 自定义报告功能

And use that code as source for image component: using component as image source

并使用该代码作为图像组件的源代码: 使用组件作为图像源

回答by BoCoKeith

Here is a CodePlex page with an open source C# QR generatorthat someone has already implemented in SSRS.

这是一个 CodePlex 页面,其中包含有人已经在 SSRS 中实现的开源 C# QR 生成器

(Follow at the link in the Reviews section for the SSRS implementation.)

(按照 SSRS 实施的“评论”部分中的链接进行操作。)

I'm sure you could create or find a solution that is easier to integrate, but I don't think you have to start from scratch.

我相信您可以创建或找到更易于集成的解决方案,但我认为您不必从头开始。

回答by BIDeveloper

By far the easiest way is to embed an image into your SSRS report. The URL of the image would be (non working example) http://qrcodegen.com&Params=12345

到目前为止,最简单的方法是将图像嵌入到您的 SSRS 报告中。图像的 URL 将是(非工作示例)http://qrcodegen.com&Params=12345

Clearly you would need to choose a reputable company to link to. We use a free service (not my idea) - but even the pay ones are cheap.

显然,您需要选择一家信誉良好的公司进行链接。我们使用免费服务(不是我的主意) - 但即使是付费服务也很便宜。

In order for this to work, the report server will need access to the site you opt for.

为了使其工作,报表服务器需要访问您选择的站点。