環境
OS = Win7 Pro
開発ツール = VS2015 Pro
帳票ツール = クリスタルレポートOEM版 Ver21
言語 = VB.net (ASP.NET)
いつもお世話になっております。
現在クリスタルレポートを使用して
jpgファイルを動的に表示させようとしていますが、
エラーにもなりませんが、画像も表示されません。
因みに作成した画像を
レポートで右クリ ⇒ 挿入 ⇒ ピクチャで「qrimage.jpg」を選択すると
表示はされます。
どうしても動的に作成して表示させる必要があるのですが、
何がいけないのかご指摘頂けないでしょうか?
下記に設定情報やプログラムを記載させて頂きます。
--------クリスタルレポート側の設定--------
①OLEオブジェクトの配置
(1)レポートで右クリ ⇒ 挿入 ⇒ OELオブジェクトを選択
(2)オブジェクトの種類一覧から、「ペイントブラシの絵」を選択し、レポートヘッダに配置
(jpgだから「ペイントブラシ・・・」を選択しておりますが、間違っていたらご教示下さい)
②式フィールドを追加
(1)フィールドエクスプローラの式フィールドを右クリ ⇒ 新規を選択
(2)式名に「Picture」と名前をつける
③OLEオブジェクトに式フィールドを設定
(1)①で作成したOLEオブジェクトを右クリ ⇒ オブジェクトの書式設定
(2)ピクチャタブを押下し、保存場所欄にある「x-2」をクリック
(3)保存場所フィールドに「"'Picture'"」を入力し保存する
--------VB側の記載--------
Dim crReportDocument As New ReportDocument
crReportDocument.Load(Server.MapPath("CrystalReport1.rpt"))
Dim QR = New QR_Encode()
QR.BackColor = Color.Red
QR.ForeColor = Color.Blue
' 「C:\test\qrimage.jpg」にQRコードの画像作成
' ファイルが出来ている事は確認済み
Dim obj = QR.EncodeData(1, 30, True, -1, 10, "1234567890 123456789012345678901234567", "C:\test\qrimage.jpg", False, 255, 255)
' 5秒待機
System.Threading.Thread.Sleep(5000)
' OLEオブジェクトにQRコード画像を設定
crReportDocument.DataDefinition.FormulaFields.Item("Picture").Text = "'C:\test\qrimage.jpg'"
' クリスタルレポートをPDFとして出力
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim Fname As String
Fname = My.Settings.downloadsPath
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = Fname
crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
crReportDocument.Export()
' クライアントのブラウザに書き込み
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(Fname)
Response.Flush()
Response.Close()
' エクスポートされたファイルを削除
System.IO.File.Delete(Fname)
以上、何卒宜しくお願い申し上げます。