简体   繁体   English

从水晶报告中的路径加载动态图像

[英]load dynamic image from path in crystal report

I want to show an image in my report , I save path of image in my sqlserver database and now I want to load image from path .I search all of internet for that and try all of guidance , I first insert image into my report and after that I go to >Format Editor > picture > Graphic Location > and insert path of image into the textarea like this {Command.path} but when I run , it doesn't show any picture .我想在我的报告中显示一个图像,我将图像的路径保存在我的 sqlserver 数据库中,现在我想从路径加载图像。我在互联网上搜索了所有内容并尝试了所有指导,我首先将图像插入到我的报告中,然后之后,我转到>Format Editor > picture > Graphic Location >并将图像路径插入文本区域,就像这样{Command.path}但是当我运行时,它不显示任何图片。 Now how should I do ?现在我该怎么办?
I use visual studio 2013 and latest version of crystal report .我使用 Visual Studio 2013 和最新版本的 Crystal Report 。

Use a conditional formula to dynamically change the location of a report’s image.

1. Add an image to the report: -> Insert -> Picture
This image will act as a placeholder.
Ensure that the placeholder is the same size as the one that will be dynamically loaded, otherwise, the image will be scaled.

2. Change the image’s Graphic Location:
   ->right click image
   ->select Format Graphic…
   ->select Picture tab
   ->click the conditional-formula button (looks like x+2)
   ->set the formula’s text to the name of the formula or parameter field that will contain the image’s URL
   ->save the formula and click the OK button
   ->Save the report

It worked for me. 

Source: cogniza.com

According to this , you're doing it right.根据this ,你做对了。 Perhaps try to set a formula field equal to {Command.path} and use that instead to see if crystal just isn't parsing it properly?也许尝试将公式字段设置为等于{Command.path}并使用它来查看水晶是否没有正确解析它? That way you can display the formula field and see how it displays.这样您就可以显示公式字段并查看它的显示方式。 Perhaps you're storing it in the DB with quotation marks or spaces?也许你用引号或空格将它存储在数据库中? Alternatively, using a parameter should definitely work, so you could make a sub-report with {Command.path} as a parameter that it uses to load up the image.或者,使用参数肯定可以工作,因此您可以使用{Command.path}作为用于加载图像的参数来制作子报告。

You can actually do it by:您实际上可以通过以下方式做到:

  1. Add a datasource for your report.为您的报告添加数据源。 Be sure to include the path image.确保包含路径图像。
  2. Add a default image.添加默认图像。
  3. From Format Editor > picture > Graphic Location , add the path image field.从 Format Editor > picture > Graphic Location ,添加路径图像字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM