How to export an image that is a blob in database from a jasper reports to excel?

后端 未结 1 516
无人及你
无人及你 2020-12-11 09:08

In ireportDesigner 5.6.0, I am adding an image from database. When I add that image,in xml it is shown as java.lang.Object and I have changed it to java.a

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-11 09:54

    With additional info that you added this is what I would do:

    1. The correct field class should be java.sql.Blob (corrispond to the database mapping)

      
         
      
      
    2. The image expression should be (On the Blob we call the getBinaryStream() that gives us a java.io.InputStream)

       
          
          
       
      

    To improve code some it would be great to check that $F{companyLogo}!=null,

    a small note... why not pass it as parameter, hence load it in your java and pass it as a java.io.InputStream or java.io.Image... this way maybe also your jasper gets cleaner...

    0 讨论(0)
提交回复
热议问题