如何在水晶报表中打印图片

时间:2016-12-06 00:24:05

标签: image printing crystal-reports report

我有一个客户编号和我想要查看的图像并打印输出 如何在水晶报告中打印图片

1 个答案:

答案 0 :(得分:0)

private void LoadImage(DataRow objDataRow,string strImageField,string FilePath)         {             尝试             {                 FileStream fs = new FileStream(FilePath,                            System.IO.FileMode.Open,System.IO.FileAccess.Read);                 byte [] Image = new byte [fs.Length];                 fs.Read(Image,0,Convert.ToInt32(fs.Length));                 fs.Close();                 objDataRow [strImageField] =图像;             }             catch(Exception ex)             {                 //Response.Write(“”+ ex.Message +“”);             }         }

???????????????????????????????? ................................

OleDbCommand Cmd = new OleDbCommand();             OleDbDataAdapter myAdapter = new OleDbDataAdapter();             Cmd.CommandText =“选择CCont,来自SaveImage的图像,其中CCont ='”+ textBoxet.Text +“'”;             Cmd.Connection = myConn;

        myAdapter.SelectCommand = Cmd;

        try
        {
            myConn.Open();
            myAdapter.Fill(ds.Tables[0]);
            myConn.Close();
        }
        catch (Exception ex)
        {
            throw;
        }


        for (int index = 0; index < ds.Tables[0].Rows.Count; index++)
        {
            if (ds.Tables[0].Rows[index]["image"].ToString() != "")
            {
                string s = ds.Tables[0].Rows[index]["image"].ToString();

                if (File.Exists(s))
                {
                    LoadImage(ds.Tables[0].Rows[index], "image", s);
                }
                else
                {
                    LoadImage(ds.Tables[0].Rows[index], "image",
                              "DefaultPicturePath");
                }
            }
            else
            {
                LoadImage(ds.Tables[0].Rows[index], "image",
                          "DefaultPicturePath");
            }
        }

        try
        {
            // Finally display report in crystal report viewer
            ReportDocument crDoc = new ReportDocument();
            crDoc.Load("CrystalReport1.rpt");
            crDoc.SetDataSource(ds.Tables[0]);

}