无法将图像绑定到ColdFusion报告输入参数 [英] Cannot bind image to ColdFusion report input parameter
问题描述
我正在使用ColdFusion Report Builder for CF9,并尝试将图表作为PNG图像传递到报告中.这是我的CFML代码:
< cfchart format ="png" name ="chartImage">< cfchartseries type ="bar" query ="chart" itemcolumn ="title" valuecolumn ="level"></cfchart>< cfreport format ="pdf" template ="report.cfr" name ="grid">< cfreportparam name ="reportTitle" value =#reportType.title#">< cfreportparam name ="chartImage" value =#chartImage#"></cfreport>
在CF Report Builder中,我定义了一个名为 chartImage
的输入参数,并将其设置为 BLOB
的类型(也尝试过输入 Image
类型),遵循这些说明./p>
我遇到此错误,但无法克服它:
报告数据绑定错误不兼容[B值分配给参数ColdFusionReport数据集中的chartImage..
我还已将参数类型更改为 String
,以base-64字符串形式传递,然后在报表中将其转换为二进制,但是这会引发错误,并带有无用的消息> [B
.
如何获取此图像以正确绑定作为输入参数?
我认为对此问题的兴趣不足,这说明CF Report Builder的普及.虽然我无法克服绑定错误,但确实找到了合理的解决方法.
我不是将图像直接绑定为二进制值,而是将图表图像写入temp目录,然后将该路径作为字符串参数传递到报表中.然后,报告可以从文件系统中找到映像并将其附加到报告中,而不会遇到任何麻烦.运行报告后,我从文件系统中删除了图表,以确保一切都保持整洁.
以下是此解决方案的更新代码:
< cfchart format ="png" name ="chartImage">< cfchartseries type ="bar" query ="chart" itemcolumn ="title" valuecolumn ="level"></cfchart>< cfset chartImageFile = getTempDirectory()&'\'&createUUID()>< cfset fileWrite(chartImageFile,chartImage)>< cfreport format ="pdf" template ="report.cfr" name ="grid">< cfreportparam name ="reportTitle" value =#reportType.title#">< cfreportparam name ="chartImage" value =#chartImageFile#"></cfreport>< cfset fileDelete(chartImageFile)>
这不是很优雅,但是关于CF Report Builder的任何事情都没有特别优雅.
I am working with ColdFusion Report Builder for CF9 and trying to pass a chart into a report as a PNG image. Here's my CFML code:
<cfchart format="png" name="chartImage">
<cfchartseries type="bar" query="chart" itemcolumn="title" valuecolumn="level">
</cfchart>
<cfreport format="pdf" template="report.cfr" name="grid">
<cfreportparam name="reportTitle" value="#reportType.title#">
<cfreportparam name="chartImage" value="#chartImage#">
</cfreport>
In CF Report Builder I have defined an Input Parameter called chartImage
and set it to a type of BLOB
(also tried type Image
), following these instructions exactly.
I am getting this error and haven't been able to overcome it:
Report data binding error Incompatible [B value assigned to parameter chartImage in the ColdFusionReport dataset..
I've also changed the parameter type to String
, passed in a base-64 string and then converted it to binary within the report, but that throws an error with an unhelpful message of [B
.
How can I get this image to bind correctly as an input parameter?
I suppose the lack of interest in this question speaks to the popularity of CF Report Builder. While I have not been able to overcome the binding error, I did find a reasonable workaround.
Instead of directly binding the image as a binary value, I am writing the chart image to the temp directory and then passing that path into the report as a string parameter. The report then can find the image from the file system and attach it to the report without any trouble. Once the report has been run, I delete the chart from the file system to ensure everything stays nice and tidy.
Here's the updated code with this solution:
<cfchart format="png" name="chartImage">
<cfchartseries type="bar" query="chart" itemcolumn="title" valuecolumn="level">
</cfchart>
<cfset chartImageFile = getTempDirectory() & '\' & createUUID()>
<cfset fileWrite(chartImageFile, chartImage)>
<cfreport format="pdf" template="report.cfr" name="grid">
<cfreportparam name="reportTitle" value="#reportType.title#">
<cfreportparam name="chartImage" value="#chartImageFile#">
</cfreport>
<cfset fileDelete(chartImageFile)>
It's not very elegant, but nothing about CF Report Builder has been particularly elegant.
这篇关于无法将图像绑定到ColdFusion报告输入参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!