Jump to content
We've recently updated our Privacy Statement, available here ×

image problem in exel


vargheseps4u
Go to solution Solved by ajinkya_c,

Recommended Posts

 

Hi,

    I am trying to add an image into my exel report.  I tried this but no success. can any one help me

Here is the code am using and jrxm.

--------------------------------------- jrxml -----------------------------------------------------------------

 

<jasperReport
name="testImage"
columnCount="1"
printOrder="Vertical"
orientation="Portrait"
pageWidth="595"
pageHeight="842"
columnWidth="535"
columnSpacing="0"
leftMargin="30"
rightMargin="30"
topMargin="20"
bottomMargin="20"
whenNoDataType="NoPages"
isTitleNewPage="false"
isSummaryNewPage="false">
<property name="ireport.scriptlethandling" value="2" />
<property name="ireport.encoding" value="UTF-8" />
<import value="java.util.*" />
<import value="net.sf.jasperreports.engine.*" />
<import value="net.sf.jasperreports.engine.data.*" />
 
<parameter name="chartInfoImg" isForPrompting="false" class="java.io.InputStream"/>
 
<background>
<band height="0"  isSplitAllowed="true" >
</band>
</background>
<title>
<band height="50"  isSplitAllowed="true" >
</band>
</title>
<pageHeader>
<band height="50"  isSplitAllowed="true" >
</band>
</pageHeader>
<columnHeader>
<band height="30"  isSplitAllowed="true" >
</band>
</columnHeader>
<detail>
<band height="100"  isSplitAllowed="true" >
<image  onErrorType="Icon" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
<reportElement
x="70"
y="7"
width="308"
height="88"
key="image-1"/>
<box></box>
<graphicElement stretchType="NoStretch"/>
<imageExpression class="java.io.InputStream"><![CDATA[$P{chartInfoImg}]]></imageExpression>
</image>
</band>
</detail>
<columnFooter>
<band height="30"  isSplitAllowed="true" >
</band>
</columnFooter>
<pageFooter>
<band height="50"  isSplitAllowed="true" >
</band>
</pageFooter>
<lastPageFooter>
<band height="50"  isSplitAllowed="true" >
</band>
</lastPageFooter>
<summary>
<band height="50"  isSplitAllowed="true" >
</band>
</summary>
</jasperReport>
--------------------------------------------------------------------------------------------------------
====================== java code =========================================
HashMap jasperParameter = new HashMap();
       File f = new File("f://yourImage.jpg");
       FileInputStream fi = new FileInputStream(f);
       jasperParameter.put("chartInfoImg", fi);
       JasperReport jasperReport = JasperCompileManager.compileReport("f://testImage.jrxml");
       JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, new JREmptyDataSource());
       JRXlsExporter exporter = new JRXlsExporter();
            exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
            exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "F://simplereport1.xls" );
            exporter.exportReport();
=======================================================================
Thanks in advance

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...