【问题标题】:Insert image to crystal reports将图像插入水晶报表
【发布时间】:2014-04-23 19:36:55
【问题描述】:

在水晶报表中插入图片 我正在使用 ADO.NET 数据连接

<xs:element name="Drawing" type="xs:byte" minOccurs="0" />

对于图像字段,那么我如何使用该图像字节数据在我的水晶报告 2013 中显示图像。 我没有使用任何后端编码,因为检索到的数据中可能有很多图像, 这是我的表“绘图”的数据结构是我存储为字节的数据的图像字段

我正在使用包含图像的报告作为子报告

【问题讨论】:

    标签: c# asp.net crystal-reports


    【解决方案1】:

    我不确定我是否理解你的问题,但让我分享一些可能会引导你找到有用的东西。我知道您说没有“后端代码”,但我希望这可能包含一些对您的案例有用的提示。

    当我们在 Crystal Reports 中使用图像时,它的类型在 XSD 中是 base64Binary。

    在数据集中,它的类型是字节[]。

    我们将图像保存为数据库中的序列化字符串。类似的东西:

    FileStream stream = new FileStream(filePath, FileMode.Open);
    BinaryReader binreader = new BinaryReader(stream);
    byte[] buffer = new byte[(int) stream.Length];
    buffer = binreader.ReadBytes((int) stream.Length);
    string serialized = Convert.ToBase64String(buffer)
    

    我们将其作为字节数组取回以放入数据集中:

    byte[] buffer = Convert.FromBase64String(serialized)
    

    在 Crystal Report 设计工具中,我们只需将字段拖到文档中即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-25
      • 2011-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-27
      相关资源
      最近更新 更多