Rtf模板开发例如背景,纹理分栏等等功能都能用word工具实现不再具体总结大家可以参考word教程。。。。。
一.组
定义一个组的目的是告诉XMLPublisher对重复的数据行进行循环显示,也就是说需要使用for-each进行数据记录的循环显示
<?for-each:XML group element tag name?>
……
<?endfor-each?>
分页是自然的,但如果想在某处强制分页如新组新页,那么可以使用Word的分页符(CTRL+ENTER快捷键),但会导致最后出现空白页;这样只能使用如下几种方式:
1、 分组声明中加@section,如<?for-each@section:G_PO_HEADER?>。
2、 <?end for-each?>前加<?split-by-page-break:?>。这个翻译后,实际上是:
<xsl:iftest="position()<last()">
< xsl:attribute name="break-before">page</xsl:attribute>
< /xsl:if>
3、 <?end for-each?>前加<xsl:attributename="break-after">page</xsl:attribute>,此法下RTF最后无空白页,但PDF有空白页。
4、 <?end for-each?>前加<xsl:attributename="break-before">page</xsl:attribute>此法下RTF、PDF最后都有空白页。
1、 任意条件分页,需要借助IF+上面的break-after或者break-before,如:
<?if:CURRENCY_CODE="CNY"?>
< xsl:attribute name="break-before">page</xsl:attribute>
< ?end if?>
2、 固定行分页,需要借助IF+上面的break-after或者break-before,在行<?end for-each?>前,如下语句控制每页5行:
<?if:position() mod 5 =0?>
< xsl:attribute name="break-before">page</xsl:attribute>
< ?end if?>
1、 标准的页眉页脚,即单个页眉页脚,使用Word的功能即可。
2、 扩展的页眉页脚,可使用<?start:body?><?endbody?>把主体部分“框”起来,凡是在这两个标记之外的东西,都将被当作页眉页脚。
1、 可以用Word的“自动图文集”,在任意地方插入页码,这个是“自然页码”。
2、 如果在某种情况下想让页码从特定值开始,比如新的组页码重新编号,则需要借助命令,如在for-each后写:<?initial-page-number:1?>。这里的“1”,实际上也可以用数据文件中的XML元素来替换。
1、 Word可在页眉页脚部分实现首页不同或奇偶页不同,没法实现末页不同,即使借助代码控制,实际实现的也是末页布局不同,而非“页眉页脚”不同。
<?start@last-page:body?><?end body?>
报表本身仅有一页时,则用<?start@last-page-first:body?><?endbody?>
例子“Advanced/LastPage”,注意布局需要独立成页,即之前需要加分页符。
2、 以偶数页结束,主要目的是显示偶数页页眉页脚
<?section:force-page-count;’end-on-even-layout’?>
如果仅显示空白页,则用<?section:force-page-count;’end-on-even’?>
3、 以奇数页结束,主要目的是显示奇数页页眉页脚
<?section:force-page-count;’end-on-odd-layout’?>
如果仅显示空白页,则用<?section:force-page-count;’end-on-odd’?>
七.嵌套模板
由于在页眉和页脚中不允许使用窗体域,而当报表页眉页脚中希望插入XML数据的时候,可以考虑使用嵌套模板。
嵌套模板是在模板中定义一个子模板,然后在需要的地方调用它,如在页眉页脚中调用它。
定义子模板
子模板标记之间可以使用任何的标记和内容,和模板的主体部分没有任何区别
<?template:internaltemplate name?>
……
<?end template?>
. 调用子模板
<?call:internaltemplate name?>
八.图片插入
接插入图片
可以直接在模板中插入jpg、gif或png格式图片
URL链接图片
•在模板中随意插入一张图片
•在设置图片对话框中的网站标签页中,在可选文字中输入如下的URL格式链接
url:{’http://image location’}
url:{’http://www.oracle.com/images/ora_log.gif’}
OA Media 库图片
•在模板中随意插入一张图片
•在设置图片对话框中的网站标签页中,在可选文字中输入如下的URL格式链接
url:{’${OA_MEDIA}/image name’}
url:{’${OA_MEDIA}/ORACLE_LOGO.gif’}
九. 超链接
•使用word中的插入超链接功能来插入静态链接
•如果超链接包括了模板中的数据元素,可以在运行时动态的创建超链接,在链接地址中按如下格式输入:
{URL_LINK}
URL_LINK可以是一个完整的URL地址,也可以使URL地址中的一部分。
它是动态传入的数据元素,如下传入URL的参数:
http://www.oracle.com?product={PRODUCT_NAME}
PRODUCT_NAME是运行时传入值的数据元素名称
如下是一个完整的URL地止
{SUPPLIER_URL}
SUPPLIER_URL 是运行时传入值的数据元素名称
十.表格
XML Publisher 支持通过XML数据来动态创建表格内容和题头
动态创建题头的步骤:
à使用<?tagname?>标记的方式来插入题头,并将其格式化为题头。这里不能使用表单
域的功能。
例如报表要求将公司名称显示为题头,XML数据标记名为<COMPANY_NAME>,在
报表模板中需要显示标题的地方输入<?COMPANY_NAME?>即可
à通过word的内置功能创建表格的其他内容
在运行的时候,系统自动替换表格中和题头标记的值
十一. 复选框
可以在模板中定义复选框,并根据传入的值来决定是否被选中
定义复选框的步骤:
使用word中的复选框型窗体域功能添加复选框
打开复选框型窗体域选项窗口
设置默认值:未选中或选中
在窗体域帮助文字中输入复选框选中的条件表达式,它必须是一个布尔表达式,只能返回true或false
如:XML数据中包括了<population>的元素,如果<population>的值大于10000
则复选框被选中,则在窗体域帮助文字中输入如下的条件表达式:
<?population>10000?>
十二.IF语句
<?if:condition?>
……
<?end if?>
例子
<?if:VENDOR_NAME=’COMPANYA’?>
……
<?end if?>
样板文本中使用IF语句
<?if@inlines:condition?>
……
<?end if?>
例子
1.The program was<?if:SUCCESS=’N’?>not<?end if?> successful
结果The program was
not
successful
2.The program was<?if@inlines:SUCCESS=’N’?>not<?end if?> successful
结果: The program wassuccessful.
十三.If-then-Else 语句
<?xdofx:if element_condition then result1 elseresult2 end if?>
例子:
<?xdofx:if AMOUNT > 1000 then 'Higher‘
Else
if AMOUNT < 1000 then 'Lower‘
Else
'Equal‘
end if?>
十四. Choose 语句
<?choose:?>
<?when:expression?>
……
<?when:expression?>
……
<?otherwise?>
十五. 格式化列
根据条件显示或隐藏列
<?if@column:condition?>
……
<?end if?>
例子:
<?if@column:condition?>
<?quantity?>
<?end if?>
<?if@column: /items/@type="PRIVATE"?>
<?quantity?>
<?end if?>
十六. 格式化行
当条件满足的时候加亮行
设置行的背景颜色
满足条件的时候才显示行
根据条件来格式化表格的行
<?if:condition?> <?end if?>
<?if@row:condition?>
<xsl:attributename="background-color"
xdofo:ctx="incontext">lightgray
</xsl:attribute>
<?end if?>
十七. 单元格加亮(字体加亮)
可以根据条件来加亮单元格
<?if:condition>
<xsl:attribute xdofo:ctx="block"name="background-color">
red
</xsl:attribute>
<?end if?>
例子:
<?if:debit>1000?>
<xsl:attribute xdofo:ctx="block"name="background-color">
red
</xsl:attribute>
<?end if?>
举例
Settingfont to bold if invoice amount isgreater than $1,000.
<?if:ACCTD_AMT>1000?><xsl:attributexdofo:ctx="block" name="font-weight">bold</xsl:attribute><?endif?>
Invoice Number |
Invoice Amount |
Grp: Invoice13222-2 |
Settingbackground color to greenif invoice amount is greater than $1,000.
<?if:ACCTD_AMT>1000?><xsl:attributexdofo:ctx="block" name="background-color">green</xsl:attribute><?endif?>
Invoice Number |
Invoice Amount |
Grp: Invoice13222-2 |
CH$100.00EFE |
十八. 计算合计值
1. 首先尽量用report生成总计,就不用写总计,直接加个总计域就行
2. 如果report生成的数据没有总计,那么可以使用固有函数实现
We have two choices when it comes tothe totals:
- In this case, the XML data contains the values at supplier level so we can just use a new field containing, <?ENT_SUM_VENDOR?> and <?ACCTD_SUM_VENDOR?> respectively.
- Alternatively we can use a native XSL SUM function to calculate the summary
<?sum(…..)?>例如<?sum(ENT_AMT)?> and<?sum(ACCTD_AMT)?>
This worksvery well but you should note that you are now performing calculations in themiddle tier which is not as performant as in the database. You should performas much of your business processing in the database as possible.
You also notice that we can give somecontext to the total by adding another form field to contain the supplier name,<?VENDOR_NAME?>, as we are in the invoices level we can simply referencethe parent vendor name value for the supplier.
可以对多个字段进行合计,由于页合计在XML数据中是不存在的,所以需要定义一个变量,定义变量的同时将计算的字段关联起来了
<?add-page-total:TotalFieldName;’element’?>
TotalFieldName:合计值对应的字段
’element’:被合计的XML元素名称
<?add-page-total:dt;’debit’?>
<?add-page-total:ct;’credit’?>
<?add-page-total:net;’debit - credit’?>
十九. 显示页合计