将数据库图像显示为stimulreport

时间:2012-07-24 06:32:57

标签: c# stimulsoft

我是在Stimulreport的帮助下做了一个报告,并希望在我的报告中显示来自数据库的图像。

图像采用byte []格式。

我该怎么做?

感谢。

2 个答案:

答案 0 :(得分:2)

您可以在Image组件的ImageData属性中使用以下表达式:

{StiImageHelper.GetImageFromObject(your_byte_array)}

答案 1 :(得分:1)

我有一个测试表,如:

enter image description here

和测试刺激报告如:

enter image description here

以下代码是我如何将图片从sql server发送到stimulsoft并制作报告的pdf文件:

protected void btnPrint_Click(object sender, EventArgs e)
    {
        SqlCommand myCommand = new SqlCommand("SELECT * FROM Product_Pipe_QR", new SqlConnection("my connection string"));
        SqlDataAdapter dataAdapter = new SqlDataAdapter(myCommand);
        DataSet dataSet = new DataSet("QR");
        dataAdapter.Fill(dataSet);

        StiReport stiReport = new StiReport();
        string path = "~/Report/Product/QR.mrt";
        stiReport.Load(Server.MapPath(path));

        stiReport.RegData(dataSet);

        stiReport.Render();

        if (!Directory.Exists(Server.MapPath("~/Report/PDF")))
            Directory.CreateDirectory(Server.MapPath("~/Report/PDF"));
        string ReportFileName = "Pipe_Report.pdf";
        stiReport.ExportDocument(StiExportFormat.Pdf, ReportFileName);
        FileStream file = File.Open(ReportFileName, FileMode.Open);
        Response.Clear();
        Response.AddHeader("Content-Disposition", "attachment; filename=" + ReportFileName);
        Response.AddHeader("Content-Length", file.Length.ToString());
        Response.ContentType = "application/pdf";
        file.Close();
        Response.WriteFile(ReportFileName);
    }

刺激词典中的UniqueSerialQRImage string和数据库中的QRImageimage type

相关问题