I want to add hyperlinks to my report. The hyperlink set in one report should take me to another subreport. Could you please tell me if this is feasible. If it is could you please provide step by step approach to achieve this?
问题:
回答1:
First, yes, it is feasible.
Second, here are your step-by-step instructions:
- Right click on element you want to link from and select Hyperlink.
- Choose Hyperlink target: Blank
- Choose Hyperlink type: Reference
- In the reference tab, type the url to invoke the subreport (with parameters). For example, in one of my reports I call the ReportController servlet to create the subreport, like so: "./ReportController?reportName=ValidationDetailsChart&reportTitle=Validation%20Details&nParms=3&parmName_1=ORD_NUMBER&parmValue_1=" + $F{ORDER_NUMBER} + "&parmName_2=START_TIME_MS&parmValue_2=&parmName_3=END_TIME_MS&parmValue_3="
- Add a tooltip in the Tooltip tab (optional). Note you can reference variable and paramter values in the tooltip.
Note that there are other ways to do this, and your method may vary if you aren't using java and servlets to generate your reports. I would recommend looking at the ireport documentation for further instructions.
回答2:
I got the solution to my problem. I had no requirement where I had to to pass any value from one subreport to another. So I simply right clicked on the textfield that I wanted the link on. I set the Hyperlink target as "Self" and Hyperlink type as "LocalPage" and in Hyperlink Page expression I set the following expression : Integer.valueOf(i) ,where i is page number(in my case it was sheet number) where I want the hyperlink to take me. If you want you can also use the following property : Integer.valueOf($V{REPORT_COUNT}).
Thanks everyone for the response.
回答3:
For navigation within reports I have implemented using Hyperlinks and Anchors
Below is the text field with hyperlinkAnchorExpression, this will be the link. Note the hyperlinkType="LocalAnchor"
<textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="80" y="0" width="80" height="20" forecolor="#3286C7" uuid="9a8313d2-21f3-4cd2-8e40-f9cddeb3cdaf"/>
<box topPadding="3" leftPadding="3">
<topPen lineWidth="0.2"/>
<leftPen lineWidth="0.2"/>
<bottomPen lineWidth="0.2"/>
<rightPen lineWidth="0.2"/>
</box>
<textElement>
<font isUnderline="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{cAddress}.getId()]]></textFieldExpression>
<hyperlinkAnchorExpression><![CDATA[$F{cAddress}.getId().toString()]]></hyperlinkAnchorExpression>
</textField>
Below is the anchornameexpression, this will be called when a hyperlink is clicked and values is matched with the hyperlinkAnchorExpression value anywhere in the report.
</textField>
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="80" y="0" width="80" height="20" uuid="9a8313d2-21f3-4cd2-8e40-f9cddeb3cdaf"/>
<box topPadding="3" leftPadding="3">
<topPen lineWidth="0.2"/>
<leftPen lineWidth="0.2"/>
<bottomPen lineWidth="0.2"/>
<rightPen lineWidth="0.2"/>
</box>
<textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
<anchorNameExpression><![CDATA[$F{id}.toString()]]></anchorNameExpression>
</textField>
I have implemented this to navigate across reports and subreports. Hope this will be helpful.