当前位置: 首页 > 知识库问答 >
问题:

PHPJasperXML无法用php打印表数据

呼延升
2023-03-14

    <?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="eleve_admis" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="466e7fc7-2c42-45cc-9626-1e50658cbee4">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
    <style name="Table_TH" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#828282"/>
            <topPen lineWidth="0.5" lineColor="#828282"/>
            <leftPen lineWidth="0.5" lineColor="#828282"/>
            <bottomPen lineWidth="0.5" lineColor="#828282"/>
            <rightPen lineWidth="0.5" lineColor="#828282"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#828282"/>
            <topPen lineWidth="0.5" lineColor="#828282"/>
            <leftPen lineWidth="0.5" lineColor="#828282"/>
            <bottomPen lineWidth="0.5" lineColor="#828282"/>
            <rightPen lineWidth="0.5" lineColor="#828282"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#828282"/>
            <topPen lineWidth="0.5" lineColor="#828282"/>
            <leftPen lineWidth="0.5" lineColor="#828282"/>
            <bottomPen lineWidth="0.5" lineColor="#828282"/>
            <rightPen lineWidth="0.5" lineColor="#828282"/>
        </box>
    </style>
    <subDataset name="eleve_admis_dataset" uuid="3df422c8-c3c8-4109-ba68-e0d8d87701b2">
        <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
        <parameter name="class_id_table" class="java.lang.String"/>
        <queryString language="SQL">
            <![CDATA[SELECT CONCAT(' ',student_lastname, ' ', ' ' , student_middlename, ' ', student_firstname) as Fullname, DATE_FORMAT(student_date_of_birth, "%d/%c/%Y") as dob, student_sex, 
IF(student_sex = "Femme", "F", "M") as sex
FROM student as S, student_class as C
 WHERE S.stu_class = C.class_id AND C.class_id = "$P{class_id_table}"]]>
        </queryString>
        <field name="Fullname" class="java.lang.String">
            <property name="com.jaspersoft.studio.field.label" value="Fullname"/>
        </field>
        <field name="dob" class="java.lang.String">
            <property name="com.jaspersoft.studio.field.label" value="dob"/>
        </field>
        <field name="student_sex" class="java.lang.String">
            <property name="com.jaspersoft.studio.field.label" value="student_sex"/>
            <property name="com.jaspersoft.studio.field.tree.path" value="student"/>
        </field>
        <field name="sex" class="java.lang.String">
            <property name="com.jaspersoft.studio.field.label" value="sex"/>
        </field>
    </subDataset>
    <parameter name="class_id" class="java.lang.String"/>
    <queryString language="SQL">
        <![CDATA[select CONCAT("Lisf For", '  ', class_no, '  ',class_description ) as classe, CONCAT("DATE:  ", DATE_FORMAT(CURDATE(), "%d/%c/%Y")) as date
FROM student_class
WHERE class_id = "$P{class_id}"]]>
    </queryString>
    <field name="classe" class="java.lang.String">
        <property name="com.jaspersoft.studio.field.label" value="classe"/>
    </field>
    <field name="date" class="java.lang.String">
        <property name="com.jaspersoft.studio.field.label" value="date"/>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="98" splitType="Stretch">
            <textField>
                <reportElement x="14" y="50" width="535" height="40" uuid="4e2a3adb-6a43-4b28-8669-17c9f81a6486"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="15" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{classe}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="360" y="0" width="190" height="30" uuid="ba6e5b18-4b85-4e4d-be68-338316e2b427"/>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{date}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <detail>
        <band height="213" splitType="Stretch">
            <componentElement>
                <reportElement x="90" y="10" width="383" height="80" uuid="a4ea31f7-b6a9-4be7-b304-72afa82cba5f">
                    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                    <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
                    <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
                    <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
                    <property name="net.sf.jasperreports.export.headertoolbar.table.name" value=""/>
                </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="eleve_admis_dataset" uuid="07815e66-5865-4839-ad1d-27cade45b0eb">
                        <datasetParameter name="class_id_table">
                            <datasetParameterExpression><![CDATA[$P{class_id}]]></datasetParameterExpression>
                        </datasetParameter>
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="200" uuid="77d235be-53cc-4ba2-9f46-6f40cc3c38dd">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="200" height="30" uuid="a7dbdc1d-52be-49f4-a402-bb0afcb02aa2"/>
                                <textElement textAlignment="Left" verticalAlignment="Middle">
                                    <font fontName="trebuchet&#xD;&#xA;" size="12" isBold="true"/>
                                </textElement>
                                <text><![CDATA[  Nom ]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="50">
                            <textField>
                                <reportElement x="0" y="0" width="200" height="50" uuid="30821ecb-5df5-43a3-8ca7-13563d10487a"/>
                                <textElement textAlignment="Left" verticalAlignment="Middle">
                                    <font fontName="trebuchet&#xD;&#xA;" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{Fullname}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90" uuid="5caeec2a-89eb-4a8f-9ac0-6f87897919fd">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30" uuid="789641df-5783-471b-a757-128097c085ab"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="trebuchet&#xD;&#xA;" size="12" isBold="true"/>
                                </textElement>
                                <text><![CDATA[ Age]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="50">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="50" uuid="2d2780b8-8120-4b16-872a-60134a5144f5"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="trebuchet&#xD;&#xA;" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{dob}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="93" uuid="3f04649c-337e-4da6-a915-f010d97d093f">
                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
                        <jr:columnHeader style="Table_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="93" height="30" uuid="78655fb0-fe8a-4f0b-866e-239b0392f7b3"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="trebuchet&#xD;&#xA;" size="12" isBold="true"/>
                                </textElement>
                                <text><![CDATA[  Sexe]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="50">
                            <textField>
                                <reportElement x="0" y="0" width="93" height="50" uuid="8550aef2-10d9-408c-9b17-6684eb7bf77d"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle">
                                    <font fontName="trebuchet&#xD;&#xA;" size="14"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{sex}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
</jasperReport>
<?php 

     require_once("../private/initialize.php");
     include_once('phpjasperxml_0.9d/class/tcpdf/tcpdf.php');
     include_once("phpjasperxml_0.9d/class/PHPJasperXML.inc.php"); // PHPJasperXML

     error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

     $class_id = (int)$_GET['class'];

     $params = array();
     $params['class_id'] = $class_id; 
     $params['class_id_table'] = $class_id;

     $PHPJasperXML = new PHPJasperXML();
     //$PHPJasperXML->debugsql=true;
     $PHPJasperXML->arrayParameter =  $params;
     $PHPJasperXML->load_xml_file("reports/eleve_admis.jrxml"); // Name of the reports file
     $PHPJasperXML->transferDBtoArray($servername,$username, $password, $database);
     $PHPJasperXML->outpage("I"); 

?>

对于这件事,我将非常感激任何帮助。或者其他开源库使用PHP生成报告的任何建议

暂时还没有答案

 类似资料:
  • 然后在main方法中,我尝试创建一个列表并打印出其中的元素。 没有语法错误,但当我尝试运行上面的代码时,终端不会返回任何内容。

  • 我在eclipse中使用FreeMarker2.3.23生成报告。下面是数据模型的代码: ----FTL堆栈跟踪(“~”表示与嵌套相关):

  • 我们希望打印到连接在apache运行的POS打印机上。由于应用程序的设计和部署,打印应该从服务器上完成(它应该检测订单并发送到不同的打印机和不同格式的打印...账单,厨房订单,等等...)。出于这个原因和其他原因(例如,从iPad访问应用程序),我们放弃了像QZ-Print applet这样的选项,并需要直接在服务器端打印。 提前谢了。

  • 我尝试在A4纸上以横向打印JavaFX WebView (JavaFX 8_25)中的HTML页面,但它以纵向打印出来,字体很小 系统输出显示纵向方向 纸张=纸:A4 (210 x 297mm) 尺寸=594.90087890625x841.3598022460938 MM 东方=纵向左边缘=54.0 右边缘=54.0 顶部边缘=54.0 底部边缘=54.0 我发现以横向模式打印HTML页面的唯一

  • 问题内容: 我正在学习Python,甚至无法编写第一个示例: 这给 指向2。 为什么是这样?我正在使用3.1版 问题答案: 那是因为在Python 3中,他们用 函数 替换了该 语句 。 __ 现在的语法与以前差不多,但是需要parens: 从“ python 3新增功能”文档中:

  • 问题内容: 我正在构建一个PHP脚本,该脚本将JSON数据提供给另一个脚本。我的脚本将数据构建到一个大的关联数组中,然后使用来输出数据。这是一个示例脚本: 上面的代码产生以下输出: 如果您的数据量很少,那就太好了,但是我希望遵循以下几点: 有没有办法在PHP中做到这一点而又没有丑陋的破解?似乎有人在Facebook上找到了答案。 问题答案: PHP 5.4提供了用于调用的选项。 http://ph