Jump to content
We've recently updated our Privacy Statement, available here ×

cool3690

Members
  • Posts

    11
  • Joined

  • Last visited

cool3690's Achievements

Apprentice

Apprentice (3/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. my jasperreport have connect mysql. Now I want to print the label I hope I can choose how much label I want to print but always fail I just can print but I want to print( I can assign each number when I print customer this is my code <%@ include file = "db.jsp"%> <!DOCTYPE html><html> <body><div class="container"> <form action = "index.jsp" method = "post"> <center ><input type=checkbox name='b' value="A0000"><font size="5">A customer</font></input> <input type="text" name="num" id="num" value="0"/><font size="5">格</font> <center ><input type=checkbox name='b' value="A0001"><font size="5">B customer</font></input> <input type="text" name="num2" id="num2" value="0"/><font size="5">格</font> </center> <center> <input type = "submit" name = "index" value = "送出" class="btn btn-success"> </form></div><% String[] b=request.getParameterValues("b"); int i; if(request.getParameter("index") != null && b!=null) { sql = "select* from send where "; ////// int number=Integer.parseInt(request.getParameter("num")); int number2=Integer.parseInt(request.getParameter("num2")); if(number>0 ){ for(i=0;i<number;i++) { sql=sql+ " c_id ='" + "A0000" + "' "; sql=sql+ " or "; } } if(number2>0 ){ for(i=0;i<number2;i++) { sql=sql+ " c_id ='" + "A0001" + "' "; sql=sql+ " or "; } } session.setAttribute("sql", sql); response.sendRedirect("show.jsp"); } %> </body></html>[/code]show.jsp <% String Lang3=""; Object sql1=session.getAttribute("sql"); if(sql1!=null){Lang3=sql1.toString();} String Lang3=""; Object sql1=session.getAttribute("Lang2"); if(sql1!=null){Lang3=sql1.toString();} ResultSet rs = stmt.executeQuery(sql1); File reportFile = new File(application.getRealPath("/report/r.jasper")); Map parameters = new HashMap(); JRDataSource dataSource = new JRResultSetDataSource(rs); byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, dataSource); response.setContentType("application/pdf"); response.setContentLength(bytes.length); ServletOutputStream outStream = response.getOutputStream(); outStream.write(bytes, 0, bytes.length); outStream.flush(); outStream.close(); rs.close();%> [/code]
  2. hello hozawa: I have try your advice "Print Order" to "Horizontal" in "Page Format" . but still fail it only show name in column 1-9 but cant show 10-18 column what step I lost? this is my xml code ..<?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="null" language="groovy" columnCount="9" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="90" columnSpacing="1" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" uuid="0dd970d6-f806-4840-b94d-1fa72ac4eb5f"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="13"/> <queryString language="SQL"> <![CDATA[select* from send]]> </queryString> <field name="name" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <group name="name"> <groupExpression><![CDATA[$F{name}]]></groupExpression> </group> <detail> <band height="276" splitType="Stretch"> <textField> <reportElement x="14" y="11" width="14" height="252" uuid="3bb01f3c-dbe2-4d34-b9de-a1bc9df7f1a1"/> <textElement> <font fontName="標楷體" size="18" pdfFontName="MHei-Medium" pdfEncoding="UniCNS-UCS2-V" isPdfEmbedded="true"/> </textElement> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> </band> <band height="276"/> </detail></jasperReport>..[/code]thanks
  3. hello Alex akovach https://drive.google.com/open?id=1IXuZos3Yo2W90hlaudpnQ0Z0k19UKU_S I have check Ignore Pagination but name only show in column 1 column 2-18 name,all disappear and also not show in next page how I can slove the problem thanks
  4. hey,there I have a problem https://drive.google.com/file/d/17eG2s8iGk66L-Av2Pw3vlW0dEa_BVmCR/view this is my report it have 18 columns(9x2) I have use mysql every column has show a name but when I show 10 name it will jump to next page but I hope I can jump to column10 how can I do to jump column10 please help me thanks
  5. I have a problem I want to download PDF automatically I also have data input and show on web is ok but when my pdf download ,it always blank why? <% String Lang3=""; Object sql1=session.getAttribute("Lang2"); if(sql1!=null){Lang3=sql1.toString();}//sql data ResultSet rs = stmt.executeQuery(Lang3); File reportFile = new File(application.getRealPath("/report/report3.jasper")); File reportFile2 = new File(application.getRealPath("/report/report3.jrxml")); Map parameters = new HashMap(); JRDataSource dataSource = new JRResultSetDataSource(rs); byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, dataSource); response.setContentType("application/pdf"); response.setContentLength(bytes.length); ServletOutputStream outStream = response.getOutputStream(); JasperPrint print = JasperFillManager.fillReport(reportFile.toString(), parameters, dataSource); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outStream); response.setHeader("Content-Disposition", "attachment;filename=" + "a" + ".pdf"); exporter.exportReport(); outStream.write(bytes, 0, bytes.length); outStream.flush(); outStream.close(); rs.close();%>[/code]thanks
  6. I hope my word space can large if santance is short and have small word space when the santance is long this is my code $F{youad}.length()<10 ? <paragraph lineSpacing="Proportional" lineSpacingSize="1.4"/> :<paragraph lineSpacing="Proportional" lineSpacingSize="0.4"/> [/code]why it can not run help me thanks
  7. HI I use jsp+jasperreport5.5 I have a colume I hope if I just have 5 letters it can have large spacing like this ex: H E L L O and if my word is long my letter spacing would small like this ex: elephant I also try add space in my sql colume like h e l l o but when I convert to pdf the space disappear....... how I can set up ? thanks
  8. I have a colume that want to show chinese text and I want it show vertical not Horizontal for example : I hope I can show 你 好 (O) not 你好(X) how I can solve this problem thanks
  9. I guess that you have not import jar or import wrong version import jar and you might slove it
  10. hello , hozawa I have add data source but it still can show the last data..... I hope I can show all the n% data <% String sql = "select * from send where name like 'n%' "; ResultSet rs = stmt.executeQuery(sql); JRDataSource dataSource = new JRResultSetDataSource(rs); File reportFile; Map parameters = new HashMap(); byte[] bytes={0}; ServletOutputStream outStream ; int i=0; while(rs.next()) { parameters.put("name",rs.getString("name")); parameters.put("youad",rs.getString("youad")); reportFile= new File(application.getRealPath("/report/report3.jasper")); bytes= JasperRunManager.runReportToPdf(reportFile.getPath(), parameters,dataSource); response.setContentType("application/pdf"); response.setContentLength(bytes.length); } outStream = response.getOutputStream(); outStream.write(bytes, 0, bytes.length); outStream.flush(); outStream.close(); rs.close(); %> [/code]
  11. [/code]hello, I try to write a report I hope I can select some sql data and show in the report this is my sql select * from send where name like 'n%' I hope I can show all the "n" data in report like n138 ,n140...... but my code only can show last data this is my code can anyone help me thank very much <%@page import="net.sf.jasperreports.engine.design.JasperDesign"%><%@page import="net.sf.jasperreports.engine.*" %><%@page import="net.sf.jasperreports.engine.JasperRunManager"%><%@page import="java.sql.DriverManager"%><%@page import="java.util.Map"%><%@page import="java.util.HashMap"%><%@page import="java.io.File"%><%@ page import="java.sql.*"%> <%@ include file = "db.jsp"%> //I have connect sql<%@page contentType="text/html" pageEncoding="UTF-8"%><% String sql = "select * from send where name like 'n%' "; ResultSet rs = stmt.executeQuery(sql); JRDataSource dataSource = new JRResultSetDataSource(rs); File reportFile; Map parameters = new HashMap(); byte[] bytes={0}; ServletOutputStream outStream ; int i=0; while(rs.next()) { parameters.put("name",rs.getString("name")); parameters.put("youad",rs.getString("youad")); reportFile= new File(application.getRealPath("/report/report3.jasper")); bytes= JasperRunManager.runReportToPdf(reportFile.getPath(), parameters); } response.setContentType("application/pdf"); response.setContentLength(bytes.length); outStream = response.getOutputStream(); outStream.write(bytes, 0, bytes.length); outStream.flush(); outStream.close(); rs.close();%> [/code]db.jsp <%@page contentType="text/html" pageEncoding="UTF-8"%><%@ page import="java.sql.*"%> <%! String user = "root"; String pass = ""; String url = "jdbc:mysql://localhost....."; Connection conn; Statement stmt; Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection(url,user,pass); stmt = conn.createStatement(); %> [/code]
×
×
  • Create New...