Is it possible to use styles from .jrtx file in Dy

2019-08-14 17:48发布

I'm using DynamicJasper to generate some reports on the fly and I'd like to use my .jrtx template. Is there a way to do that?

1条回答
干净又极端
2楼-- · 2019-08-14 18:15

Yes, you can use .jrtx tempalte. I had used it for formatting the text in my report. Here's a sample file for your reference.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperTemplate PUBLIC "-//JasperReports//DTD Template//EN" "http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">

<jasperTemplate>
    <style name="AddressAndGreenBarText" isDefault="false" forecolor="#000000" backcolor="#FFFFFF" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Times New Roman" fontSize="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Roman"/>
    <style name="BodyLetterTextAndBullet" isDefault="false" forecolor="#000000" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Times New Roman" fontSize="11" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Roman"/>
    <style name="Footer" isDefault="false" forecolor="#000000" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Times New Roman" fontSize="7" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Roman"/>
    <style name="BodyLetterLabels" isDefault="false" forecolor="#000000" backcolor="#FFFFFF" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Times New Roman" fontSize="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Bold"/>
    <style name="Signature" isDefault="false" forecolor="#000000" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Times New Roman" fontSize="28" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="AnkeCalligraph.ttf"/>
    <style name="ColumnAndGreenBarLabels" isDefault="false" forecolor="#000000" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Times New Roman" fontSize="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Bold"/>
    <style name="PhoneNumber" isDefault="false" forecolor="#000000" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Times New Roman" fontSize="15" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Bold"/>
    <style name="GeneralFont" isDefault="false" forecolor="#000000" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Arial" fontSize="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
    <style name="OtherHeading" isDefault="false" forecolor="#000000" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Arial" fontSize="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
    <style name="SubHeading" isDefault="false" forecolor="#000000" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Arial" fontSize="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
    <style name="Heading" isDefault="false" forecolor="#000000" hAlign="Left" vAlign="Top" rotation="None" lineSpacing="Single" fontName="Arial" fontSize="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
</jasperTemplate>

Go to Report Inspector -> Styles -> Add -> Style Reference. You can add the .jrtx file here. Let me know if need any other help.

查看更多
登录 后发表回答