title: Error in Java REST client to receive and save the excel response(byte array)
body: <p>I have the Spring REST service returns the excel file(XLS) as byte array and need to write the appropriate client code to receive this response and save the file. Was able to get the byte array response but while converting it to excel workbook(HSSFWorkbook) getting the below error</p>
  
  <blockquote>
    <p>org.apache.poi.poifs.filesystem.NotOLE2FileException: Invalid header signature; read 0x0005060000100809, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document.</p>
  </blockquote>
  
  <p>I tried the following but no luck</p>
  
  <ol>
  <li>verified that the file is valid by saving it in the service before returns in response.</li>
  <li>Tried to send the InputStream instead of byte array</li>
  <li>Tried using ResponseEntity
  etc</li>
  </ol>
  
  <p>service side code</p>
  
  <pre><code>HSSFWorkbook workbook = //code to generate the workbook
  ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  workbook.write(outputStream);
  byte[] response = outputStream.toByteArray();
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>