title: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence while exporting to excel
body: <p>I'm using <em>JasperReports API</em> to export report in <em>Excel</em> format. </p>
  
  <p>My <em>Java</em> code is:</p>
  
  <pre><code>Connection connection;
  FacesContext facesContext = FacesContext.getCurrentInstance();
  HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse();
  InputStream reportStream = facesContext.getExternalContext().getResourceAsStream("C:/summaryOfEmployees.jasper");
  ServletOutputStream servletOutputStream = response.getOutputStream();
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Session hibernateSession = null;
  hibernateSession = HibernateUtils.currentSession();
  connection = hibernateSession.connection();
  facesContext.responseComplete();
  
  HashMap parameterMap = new HashMap();
  
  JExcelApiExporter exporterXLS = new JExcelApiExporter();
  
  JasperReport jasperReport = JasperCompileManager.compileReport("C:/summaryOfEmployees.jasper");
  
  JasperPrint jasperPrint = JasperFillManager.fillReport("C:/summaryOfEmployees.jasper", parameterMap, connection);
  
  exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT,jasperPrint);
  exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE,Boolean.TRUE);
  exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE);
  exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);
  exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS,Boolean.TRUE);
  exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM,servletOutputStream);
  exporterXLS.exportReport();
  
  connection.close();
  servletOutputStream.flush();
  servletOutputStream.close();
  </code></pre>
  
  <p>I get the following exception on console and the excel file appears empty</p>
  
  <pre><code>    net.sf.jasperreports.engine.JRException: java.io.UTFDataFormatException: Invalid  byte 1 of 1-byte UTF-8 sequence....
  .................................
  Caused by: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
  at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source)
  at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
  at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
  at org.apache.xerces.impl.XMLEntityScanner.skipString(Unknown Source)
  at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
  at org.apache.commons.digester.Digester.parse(Digester.java:1745)
  at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:243)
  ... 44 more
  </code></pre>
  
  <p>The first line of my xml file as displayed in <em>iReport</em> says <em>UTF-8</em> is not the issue as follows:</p>
  
  <pre><code>   &lt;?xml version="1.0" encoding="UTF-8"?&gt;    
  </code></pre>
  
  <p>Why do i get this error? </p>
  
  <p>I'm desperate to be helped out.</p>