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

lswx2016

Members
  • Posts

    2
  • Joined

  • Last visited

lswx2016'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. When i exported the xlsx file and opened it,Excel reminds me found the error and need to recover it. Then the file could be opened,but got the warning. The infmation is: A repaired record : The format of the /xl/styles.xml part (style) The Code pasted below: public void generateReportEXCEL (List<JasperPrint> jasperPrintList,String[] names, HttpServletRequest req, HttpServletResponse resp) throws IOException, JRException {resp.reset();resp.resetBuffer();resp.setContentType("application/vnd.ms-excel");resp.setHeader("Content-Disposition", "attachment;filename="test.xlsx"");ServletOutputStream outputStream = resp.getOutputStream(); JRXlsxExporter exporter = new JRXlsxExporter();exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream));SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration(); configuration.setDetectCellType(true);//Set configuration as you like it!!configuration.setCollapseRowSpan(false);configuration.setWhitePageBackground(false);configuration.setSheetNames(names); exporter.setConfiguration(configuration); exporter.exportReport();outputStream.flush();outputStream.close();}
  2. Recently,i worked on the jasperreport in springmvc.I have successfully exported the excel file. But When i opened the file, it poped up a warning:File format and extension mismatch。 Andbody came across the same situation?Thx for any help. The Code is here: public void generateReportEXCEL (List<JasperPrint> jasperPrintList, HttpServletRequest req, HttpServletResponse resp) throws IOException, JRException {resp.reset();resp.resetBuffer();resp.setContentType("application/vnd.ms-excel");resp.setHeader("Content-Disposition", "attachment;filename="test.xls"");ServletOutputStream outputStream = resp.getOutputStream(); JRXlsxExporter exporter = new JRXlsxExporter();exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream));SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration(); configuration.setDetectCellType(true);//Set configuration as you like it!!configuration.setCollapseRowSpan(false);configuration.setWhitePageBackground(false); exporter.setConfiguration(configuration);exporter.exportReport();outputStream.flush();outputStream.close();}The pom.xml relatived:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>SpringJasper</groupId> <artifactId>SpringJasperMaven</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>SpringJasperMaven Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>4.1.4.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-web</artifactId><version>4.1.4.RELEASE</version></dependency> <dependency><groupId>org.springframework</groupId><artifactId>spring-tx</artifactId><version>4.1.4.RELEASE</version></dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.4.RELEASE</version> </dependency> <dependency><groupId>net.sf.jasperreports</groupId><artifactId>jasperreports</artifactId><version>6.3.0</version></dependency> <dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.9</version></dependency> <dependency><groupId>tomcat</groupId><artifactId>jasper-compiler-jdt</artifactId><version>5.5.23</version></dependency> <dependency><groupId>org.hibernate</groupId><artifactId>hibernate-validator</artifactId><version>4.3.1.Final</version></dependency> <dependency><groupId>org.hibernate</groupId><artifactId>hibernate-annotations</artifactId><version>3.2.1.ga</version></dependency> <dependency><groupId>javax.validation</groupId><artifactId>validation-api</artifactId><version>1.0.0.GA</version></dependency> <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>1.1</version></dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.6</version></dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <finalName>SpringJasperMaven</finalName> </build></project>
×
×
  • Create New...