Jump to content
Changes to the Jaspersoft community edition download ×

nopain_nogain

Members
  • Posts

    5
  • Joined

  • Last visited

nopain_nogain's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. What you want to export file type? Html?xls?pdf? This is my test code,export fill type is html,and it run successful. String reportFilePath = root_path + "WEB-INF/classes/com/sunshine/jasper/report.jasper"; JasperReport report = (JasperReport) JRLoader.loadObject(reportFilePath); JasperPrint jasperPrint = JasperFillManager.fillReport(report,null, conn); JRHtmlExporter exporter = new JRHtmlExporter(); req.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,jasperPrint); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"image?image="); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out); exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "GBK"); exporter.exportReport(); Hope help you.
  2. Hi,i want to know you want to create crosstab or other? You english is no perfect,and me to,because i'm chinese,but i'm work on learning english.joying......
  3. Hi all,my questioni is OK, i reference the jasperReport carry demo . Add this code: <textField> <reportElement x="2" y="3" width="35" height="16"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Integer"><![CDATA[$V{marks_Nothing}]]></textFieldExpression> </textField> Hope help other.
  4. My crosstab run successful,i want to add column totals and row totals in crosstab,and i find many data ,not find one method. Use crosstab wizard create crosstab,late setp ,select add column totals and row totals,and add after,i don't now column totals field what's run? Thanks so much. This is my jrxml file <?xml version="1.0" encoding="UTF-8"?> <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="ShipmentsReport" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="812" leftMargin="15" rightMargin="15" topMargin="10" bottomMargin="10"> <property name="net.sf.jasperreports.export.pdf.tagged" value="true"/> <property name="net.sf.jasperreports.export.pdf.tag.language" value="EN-US"/> <style name="Sans_Normal" isDefault="true" fontName="DejaVu Sans" fontSize="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/> <style name="Sans_Large" isDefault="false" style="Sans_Normal" fontSize="10"/> <style name="Sans_Bold" isDefault="false" fontName="DejaVu Sans" fontSize="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/> <subDataset name="SubDataset3"> <queryString> <![CDATA[select a.name course_name,b.name course_type_name,c.marks,d.name as school_name,e.name as classname from t_course a,t_course_type b,t_marks c,t_schoolmates d ,t_class e where a.type_id in(b.id) and a.id=c.course_id and d.id=c.student_id and d.class_id in(e.id)]]> </queryString> <field name="classname" class="java.lang.String"/> <field name="course_type_name" class="java.lang.String"/> <field name="marks" class="java.lang.Integer"/> <field name="school_name" class="java.lang.String"/> <field name="course_name" class="java.lang.String"/> </subDataset> <queryString> <![CDATA[sELECT name from T_schoolmates group by name order by name]]> </queryString> <columnHeader> <band height="147"> <crosstab isRepeatColumnHeaders="false"> <reportElement x="0" y="15" width="812" height="108"/> <crosstabDataset> <dataset> <datasetRun subDataset="SubDataset3"> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> </datasetRun> </dataset> </crosstabDataset> <crosstabHeaderCell> <cellContents> <box> <pen lineWidth="1.0"/> </box> <staticText> <reportElement style="Sans_Large" x="0" y="0" width="103" height="50"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <text><![CDATA[XXXXXXXXXXXXXXXXX]]></text> </staticText> </cellContents> </crosstabHeaderCell> <rowGroup name="classname" width="50" totalPosition="End"> <bucket> <bucketExpression class="java.lang.String"><![CDATA[$F{classname}]]></bucketExpression> </bucket> <crosstabRowHeader> <cellContents> <box> <pen lineWidth="1.0"/> </box> <textField> <reportElement x="0" y="0" width="50" height="16"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$V{classname}]]></textFieldExpression> </textField> </cellContents> </crosstabRowHeader> <crosstabTotalRowHeader> <cellContents backcolor="#60FFFF" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabTotalRowHeader> </rowGroup> <rowGroup name="school_name" width="53" totalPosition="End"> <bucket> <bucketExpression class="java.lang.String"><![CDATA[$F{school_name}]]></bucketExpression> </bucket> <crosstabRowHeader> <cellContents> <box> <pen lineWidth="1.0"/> </box> <textField> <reportElement x="0" y="0" width="53" height="16"/> <textElement verticalAlignment="Middle"/> <textFieldExpression class="java.lang.String"><![CDATA[$V{school_name}]]></textFieldExpression> </textField> </cellContents> </crosstabRowHeader> <crosstabTotalRowHeader> <cellContents backcolor="#E0FFFF" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabTotalRowHeader> </rowGroup> <columnGroup name="course_type_name" height="25" totalPosition="End" headerPosition="Stretch"> <bucket> <bucketExpression class="java.lang.String"><![CDATA[$F{course_type_name}]]></bucketExpression> </bucket> <crosstabColumnHeader> <cellContents> <box> <pen lineWidth="1.0"/> </box> <textField pattern="yyyy"> <reportElement x="0" y="0" width="72" height="25"/> <textElement textAlignment="Center" verticalAlignment="Middle"/> <textFieldExpression class="java.lang.String"><![CDATA[$V{course_type_name}]]></textFieldExpression> </textField> </cellContents> </crosstabColumnHeader> <crosstabTotalColumnHeader> <cellContents backcolor="#FFFF60" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabTotalColumnHeader> </columnGroup> <columnGroup name="course_name" height="25" totalPosition="End"> <bucket> <bucketExpression class="java.lang.String"><![CDATA[$F{course_name}]]></bucketExpression> </bucket> <crosstabColumnHeader> <cellContents> <box> <pen lineWidth="1.0"/> </box> <textField> <reportElement x="0" y="0" width="37" height="25"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$V{course_name}]]></textFieldExpression> </textField> </cellContents> </crosstabColumnHeader> <crosstabTotalColumnHeader> <cellContents backcolor="#FFFFFF" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabTotalColumnHeader> </columnGroup> <measure name="marks_Nothing" class="java.lang.Integer" calculation="Sum"> <measureExpression><![CDATA[$F{marks}]]></measureExpression> </measure> <crosstabCell width="37" height="16"> <cellContents backcolor="#FFFFFF" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> <textField pattern="#0.0"> <reportElement x="0" y="0" width="37" height="16"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression class="java.lang.Integer"><![CDATA[$V{marks_Nothing}]]></textFieldExpression> </textField> </cellContents> </crosstabCell> <crosstabCell width="35" height="16" columnTotalGroup="course_name"> <cellContents backcolor="#FFFFFF" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabCell> <crosstabCell width="0" height="16" columnTotalGroup="course_type_name"> <cellContents backcolor="#FFFF60" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabCell> <crosstabCell width="37" height="0" rowTotalGroup="school_name"> <cellContents backcolor="#E0FFFF" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabCell> <crosstabCell height="0" rowTotalGroup="school_name" columnTotalGroup="course_name"> <cellContents backcolor="#E0FFC0" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabCell> <crosstabCell width="0" height="0" rowTotalGroup="school_name" columnTotalGroup="course_type_name"> <cellContents backcolor="#E0FF60" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabCell> <crosstabCell width="37" height="0" rowTotalGroup="classname"> <cellContents backcolor="#60FFFF" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabCell> <crosstabCell height="0" rowTotalGroup="classname" columnTotalGroup="course_name"> <cellContents backcolor="#60FFC0" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabCell> <crosstabCell width="0" height="0" rowTotalGroup="classname" columnTotalGroup="course_type_name"> <cellContents backcolor="#60FF60" mode="Opaque"> <box> <pen lineWidth="1.0"/> </box> </cellContents> </crosstabCell> </crosstab> </band> </columnHeader> <detail> <band/> </detail> </jasperReport> Post Edited by 郅 å¸…æ° at 04/03/09 03:22
  5. This is my code,and it runing succeed.the jasper file and zx.jpg in one folder. Code:report36.jrxml:<?xml version="1.0" encoding="GBK"?><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="report name" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> <parameter name="imagePath" class="java.lang.String"/> <background> <band/> </background> <title> <band height="79"> <staticText> <reportElement x="223" y="26" width="130" height="41"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="24" isBold="true"/> </textElement> <text><![CDATA[测试图片]]></text> </staticText> </band> </title> <pageHeader> <band/> </pageHeader> <columnHeader> <band height="195"> <image> <reportElement x="12" y="17" width="516" height="165"/> <imageExpression class="java.lang.String"><![CDATA[$P{imagePath}]]></imageExpression> </image> </band> </columnHeader> <detail> <band/> </detail> <columnFooter> <band/> </columnFooter> <pageFooter> <band/> </pageFooter> <summary> <band/> </summary></jasperReport>servlet: protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { OutputStream out = resp.getOutputStream(); resp.setContentType("text/html;charset=GBK"); String root_path = this.getServletContext().getRealPath("/"); root_path = root_path.replace('', '/'); // 拿到*.jasper文件的路径 String reportFilePath = root_path + "WEB-INF/classes/com/sunshine/jasper/report36.jasper"; File reportFile = new File(reportFilePath); if (!reportFile.exists()) throw new IOException("ä¼å…¥çš„模æ¿æ–‡ä»¶ä¸å­˜åœ¨!"); //Connection conn = DB.getConnection(); Map imageMap = new HashMap(); imageMap.put("imagePath", root_path + "WEB-INF/classes/com/sunshine/jasper/zx.jpg"); try { JasperReport report = (JasperReport) JRLoader.loadObject(reportFilePath); JasperPrint jasperPrint = JasperFillManager.fillReport(report,imageMap, new JREmptyDataSource()); JRHtmlExporter exporter = new JRHtmlExporter(); req.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,jasperPrint); exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"image?image="); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out); exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "GBK"); exporter.exportReport(); out.close(); } catch (Exception ex) { ex.printStackTrace(); } }
×
×
  • Create New...