我有一个XML文件,要转换为EXCEL(XLS)。想到使用Jasper Report工具将其转换为XLS。在turorial中,我们需要从XML创建一个JRXML模板,然后编译JRXML以生成.jasper文件。我想知道如何将xml映射到jrxml。帮助我从XML创建JRXML文件。
我的样本xml是
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mig:menu-compare xmlns:mig="http://www..com//" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www..com/">
<mig:menu-info>
<mig:menu type="ons" name="HCOTA"/>
<mig:menu type="ux" name="RTACOF"/>
</mig:menu-info>
<mig:field-details>
<mig:fields existence="both">
<mig:field name="taChrgOffMsg.taChrgOffCrit.Acct.foracid">
<mig:field-type type="ons">
<mig:group-name>cota</mig:group-name>
<mig:page-name>cotacrit</mig:page-name>
<mig:control-type>Text Field</mig:control-type>
<mig:ui-field>acctId</mig:ui-field>
<mig:label>FLT000265</mig:label>
<mig:label-desc>A/c. ID</mig:label-desc>
<mig:mandatory>Y</mig:mandatory>
</mig:field-type>
<mig:field-type type="ux">
<mig:group-name>Rtacof</mig:group-name>
<mig:page-name>Rtacof_criteria_form</mig:page-name>
<mig:page-name-desc>Transaction A/c. Details</mig:page-name-desc>
<mig:control-type>FinAccountId</mig:control-type>
<mig:ui-field>acctId$accountId</mig:ui-field>
<mig:label>FLT001251</mig:label>
<mig:label-desc>A/c. ID</mig:label-desc>
<mig:mandatory>Y</mig:mandatory>
<mig:section-structure>group1.section1.subSection1.finRow1.finCell1</mig:section-structure>
<mig:form>criteria</mig:form>
</mig:field-type>
</mig:field>
<mig:field name="taChrgOffMsg.taChrgOffCrit.chargeOffType">
<mig:field-type type="ons">
<mig:group-name>cota</mig:group-name>
<mig:page-name>cotacrit</mig:page-name>
<mig:control-type>Radio Button</mig:control-type>
<mig:ui-field>chargeOffMode</mig:ui-field>
<mig:label>FLT004530</mig:label>
<mig:label-desc>Charge Off Mode</mig:label-desc>
<mig:mandatory>cotaProps.chargeOffMode_MANDATORY</mig:mandatory>
</mig:field-type>
<mig:field-type type="ux">
<mig:group-name>Rtacof</mig:group-name>
<mig:page-name>Rtacof_criteria_form</mig:page-name>
<mig:page-name-desc>Transaction A/c. Details</mig:page-name-desc>
<mig:control-type>FinRadioButtonGroup</mig:control-type>
<mig:ui-field>chargeMode</mig:ui-field>
<mig:label>FLT003817</mig:label>
<mig:label-desc>Charge Off Mode</mig:label-desc>
<mig:mandatory>N</mig:mandatory>
<mig:section-structure>group1.section1.subSection12.finRow2.finCell4</mig:section-structure>
<mig:form>criteria</mig:form>
</mig:field-type>
</mig:field>
</mig:fields>
<mig:fields existence="nonMap">
<mig:field>
<mig:field-type type="ons">
<mig:group-name>cota</mig:group-name>
<mig:page-name>cotacrit</mig:page-name>
<mig:control-type>Desc. Label</mig:control-type>
<mig:ui-field>acctCrncy</mig:ui-field>
<mig:label></mig:label>
<mig:mandatory>N</mig:mandatory>
</mig:field-type>
</mig:field>
<mig:field>
<mig:field-type type="ons">
<mig:group-name>cota</mig:group-name>
<mig:page-name>cotacrit</mig:page-name>
<mig:control-type>Desc. Label</mig:control-type>
<mig:ui-field>acctSol</mig:ui-field>
<mig:label></mig:label>
<mig:mandatory>N</mig:mandatory>
</mig:field-type>
</mig:field>
<mig:field>
<mig:field-type type="ux">
<mig:group-name>Rtacof</mig:group-name>
<mig:page-name>Rtacof_tranDetail_form</mig:page-name>
<mig:page-name-desc>Charge Off Transaction Details</mig:page-name-desc>
<mig:control-type>FinText</mig:control-type>
<mig:ui-field>dtotalCollVa</mig:ui-field>
<mig:label>FLT003816</mig:label>
<mig:label-desc>Total Collateral Value</mig:label-desc>
<mig:section-structure>tranDetailG1.tranDetailS1.sg_accDet.finRow32.finCell103</mig:section-structure>
<mig:form>tranDetail</mig:form>
</mig:field-type>
</mig:field>
<mig:field>
<mig:field-type type="ux">
<mig:group-name>Rtacof</mig:group-name>
<mig:page-name>Rtacof_tranDetail_form</mig:page-name>
<mig:page-name-desc>Charge Off Transaction Details</mig:page-name-desc>
<mig:control-type>FinText</mig:control-type>
<mig:ui-field>dassetClassM</mig:ui-field>
<mig:label>FLT003810</mig:label>
<mig:label-desc>Main/Sub Asset Classification</mig:label-desc>
<mig:section-structure>tranDetailG1.tranDetailS1.sg_accDet.finRow32.finCell93</mig:section-structure>
<mig:form>tranDetail</mig:form>
</mig:field-type>
</mig:field>
</mig:fields>
<mig:fields existence="ux">
<mig:field name="taChrgOffMsg.taChrgOffCrit.Acct.acctName">
<mig:field-type type="ux">
<mig:group-name>Rtacof</mig:group-name>
<mig:page-name>Rtacof_criteria_form</mig:page-name>
<mig:page-name-desc>Transaction A/c. Details</mig:page-name-desc>
<mig:control-type>FinAccountId</mig:control-type>
<mig:ui-field>acctId$accountNameDesc</mig:ui-field>
<mig:label>FLT001251</mig:label>
<mig:label-desc>A/c. ID</mig:label-desc>
<mig:mandatory>Y</mig:mandatory>
<mig:section-structure>group1.section1.subSection1.finRow1.finCell1</mig:section-structure>
<mig:form>criteria</mig:form>
</mig:field-type>
</mig:field>
</mig:fields>
<mig:fields existence="ons">
<mig:field name="taChrgOffMsg.taChrgOffCrit.funcCode">
<mig:field-type type="ons">
<mig:group-name>cota</mig:group-name>
<mig:page-name>cotacrit</mig:page-name>
<mig:control-type>Combo Box</mig:control-type>
<mig:ui-field>funcCode</mig:ui-field>
<mig:label>FLT000204</mig:label>
<mig:label-desc>Function</mig:label-desc>
<mig:mandatory>Y</mig:mandatory>
</mig:field-type>
</mig:field>
</mig:fields>
</mig:field-details>
</mig:menu-compare>
答案 0 :(得分:0)
请按照以下步骤操作:
步骤1:在excel文件中设计所需输出的jrxml文件。
步骤2:您需要一个数据源来填充jrxml文件。在您的情况下,您将需要JasperReport的XmlDataSource。因此,从您的xml文件创建一个XmlDataSource。
步骤3:填写报告并使用JasperExporter将其导出到excel文件。