JasperViewer不会在Windows

时间:2016-05-28 18:07:45

标签: jasper-reports

不确定为什么JasperViewer不会在Windows中打印unicode字符。我试图安装一些孟加拉语字体,但没有用。

我只是从mysql中检索数据,在报告中我将数字替换为孟加拉语unicode数字。它在Linux(debian)中运行良好。但是当我在Windows(10)中运行Application jar文件时,字体完全被破坏了。除了表格外没有显示任何内容。

我做错了什么?

今天在这里格式化xml代码更难!所以我把它粘贴在http://pastebin.com/XC3EiZyF

字体扩展名: enter image description here

enter image description here

Java方法:

public void ClickButton(ActionEvent event) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, JRException, SQLException {


    //System.out.println(dir);
    String date = viewReport.getText();



    String reportSrcFile = "/home/famed/IdeaProjects/Salary Sheet/src/SalarySheet/salary2.jrxml";



    JasperReport report = JasperCompileManager.compileReport(new File("").getAbsolutePath()+"/rtemp/salary2.jrxml");
    System.out.println(report.toString());

    Connection conn = SqlConnect.con();


    // Parameters for report
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("repDate", viewReport.getText());
    if(displayDate.getText().isEmpty()){
        parameters.put("displayDate",viewReport.getText());
    }
    else {
        parameters.put("displayDate",displayDate.getText());
    }

    System.out.println("The Date:");
    System.out.println(parameters.get("repDate"));

    JasperPrint print = JasperFillManager.fillReport(report,
            parameters, conn);


    JasperViewer jv = new JasperViewer(print);
    jv.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jv.setTitle("Test Report");

    jv.setVisible(true);
}

JRXML:

<?xml version="1.0" encoding="UTF-8"?>
<detail>
    <band height="304" splitType="Stretch">
        <componentElement>
            <reportElement x="168" y="104" width="200" height="200" uuid="433fbb6e-081e-4bab-ab86-a02e4a7187c9">
                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                <property name="com.jaspersoft.studio.table.style.table_header" value="Table 1_TH"/>
                <property name="com.jaspersoft.studio.table.style.column_header" value="Table 1_CH"/>
                <property name="com.jaspersoft.studio.table.style.detail" value="Table 1_TD"/>
            </reportElement>
            <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                <datasetRun subDataset="Dataset2" uuid="fd0beb84-562e-4cb7-bd56-6ff5ee927304">
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                </datasetRun>
                <jr:column width="100" uuid="112d200e-48b9-473a-83c8-0d4cdc7ac60c">
                    <jr:columnHeader style="Table 1_CH" height="30">
                        <staticText>
                            <reportElement x="0" y="0" width="100" height="30" uuid="8ab8f29f-6229-4abb-9754-489041715c02"/>
                            <text><![CDATA[নাম]]></text>
                        </staticText>
                    </jr:columnHeader>
                    <jr:columnFooter style="Table 1_CH" height="30"/>
                    <jr:detailCell style="Table 1_TD" height="30">
                        <textField>
                            <reportElement x="0" y="0" width="100" height="30" uuid="03c38867-008d-495f-9429-c980edcec9fa"/>
                            <textFieldExpression><![CDATA[String.valueOf($F{emp_name}).replaceAll("0","০").replaceAll("1","১").replaceAll("2","২").replaceAll("3","৩").replaceAll("4","৪").replaceAll("5","৫").replaceAll("6","৬").replaceAll("7","৭").replaceAll("8","৮").replaceAll("9","৯")]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="100" uuid="08c7b00b-bb51-4974-9f80-437a800016c0">
                    <jr:columnHeader style="Table 1_CH" height="30">
                        <staticText>
                            <reportElement x="0" y="0" width="100" height="30" uuid="92539beb-73ef-4729-be59-e744fa0339fb"/>
                            <text><![CDATA[বাড়ী ভাড়া]]></text>
                        </staticText>
                    </jr:columnHeader>
                    <jr:columnFooter style="Table 1_CH" height="30"/>
                    <jr:detailCell style="Table 1_TD" height="30">
                        <textField>
                            <reportElement x="0" y="0" width="100" height="30" uuid="07286a2f-7346-40ee-aa69-4c68851020a4"/>
                            <textFieldExpression><![CDATA[String.valueOf($F{home_fare_percent}).replaceAll("0","০").replaceAll("1","১").replaceAll("2","২").replaceAll("3","৩").replaceAll("4","৪").replaceAll("5","৫").replaceAll("6","৬").replaceAll("7","৭").replaceAll("8","৮").replaceAll("9","৯")]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
            </jr:table>
        </componentElement>
    </band>
</detail>

1 个答案:

答案 0 :(得分:0)

(代表OP发布)。

我让它发挥作用。我忘了在添加jar文件后更改字体名称!