Java.io.IOException: Invalid header signature; read

Hi,

Today I was creating a Java Program to read a Excel files (created by importing text log files)  using  POI HSSF and faced the following errors:

java.io.IOException: Invalid header signature; read 8751655596022002505, expected -2226271756974174256 .

 After a analysis i found that the excel file I am using is not an Excel binary file. It's a text file with a .xls extension s.t. Excel can quietly convert it and display as a spreadsheet. HSSF deals with files written in Excel format only.

 I used the Save As… command to save that file as Excel . And now the problem is Solved :).

This entry was posted in Java, Troubleshoot. Bookmark the permalink.

17 Responses to Java.io.IOException: Invalid header signature; read

  1. Mauricio says:

    Excel-lent, I was just looking for that solution, great, thanks!!

  2. sridhar says:

    Hi Mauricio,

    I too face same problem, but finally I resolved this issue.But thing is that when I m reading excel file its throwing

    [Servlet Error]-[java/nio/BufferUnderflowException]: java.lang.NoClassDefFoundError: java/nio/BufferUnderflowException
    at org.apache.poi.poifs.property.Property.(Property.java:100)
    at org.apache.poi.poifs.property.DirectoryProperty.(DirectoryProperty.java:53)
    at org.apache.poi.poifs.property.RootProperty.(RootProperty.java:45)
    at org.apache.poi.poifs.property.PropertyTable.(PropertyTable.java:57)
    at org.apache.poi.poifs.filesystem.POIFSFileSystem.(POIFSFileSystem.java:107)
    at org.apache.poi.poifs.filesystem.POIFSFileSystem.(POIFSFileSystem.java:144)
    at org.apache.jsp._BulkUploadArtworkController._jspService(_BulkUploadArtworkController.java:255)
    at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:357)
    at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:675)
    at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:773)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
    at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
    at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
    at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
    at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
    at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
    at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
    at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)

    Please suggest me to resolve my issue. You can send your suggestions at sridharkumar.ch@gmail.com

    Thanks and Regards,
    Sridhar Kumar Chinchili

  3. preetha says:

    Thanks i was lokking for a solution for the same exception

  4. Scott says:

    Did you find the solution to your NoClassDefFoundError for java/nio/BufferUnderflowException; I am having that same problem and am looking for a solution.

  5. santhosh says:

    Thanku Thanku so much buddy

  6. Jérémy says:

    Merci 😉

  7. Samay says:

    Thanks for the post and it was really helpful.

  8. Wasi says:

    How to overcom this becouse excel is coming from backend.is der any way to save as excel from java side?

  9. magesh says:

    java.io.IOException: Invalid header signature; read 0x464A1000E0FFD8FF, expected 0xE11AB1A1E011CFD0
    i am trying to write image to the MS-WordDocument ,when i run above exception is
    thrown ,What i do, i m using jdk1.6 and POI libraries, program writen in netbeans
    ,you have any hints solve this problem.

  10. Abhishek Kumar says:

    I am using Docx in place of Excel i tried the same but still i am stuck wid the invalid signature header problem.
    java.io.IOException: Invalid header signature; read 0x4353414E2023233C, expected 0xE11AB1A1E011CFD0
    at org.apache.poi.poifs.storage.HeaderBlock.(HeaderBlock.java:140)
    at org.apache.poi.poifs.storage.HeaderBlock.(HeaderBlock.java:104)
    at org.apache.poi.poifs.filesystem.POIFSFileSystem.(POIFSFileSystem.java:138)
    at org.apache.poi.hwpf.HWPFDocumentCore.verifyAndBuildPOIFS(HWPFDocumentCore.java:107)
    at org.apache.poi.hwpf.HWPFDocument.(HWPFDocument.java:179)
    at Word2XML.main(Word2XML.java:196)

  11. Amrita says:

    Thanks…It was really helpful..!

  12. priya says:

    Thankyou so much.. 🙂 really helpfull

  13. boonya says:

    I meet the same problem , but by this way I’m not resolved it!My file is opned by WPS which like MS Excel ,and I used to work with it ,although change the file as MS Excel it doesn’t work ,what should I do?

  14. boonya says:

    I new a MS Excel and import my data ,but it always happend exception:
    2013-08-13 10:42:49 [ http-bio-8080-exec-2:46594 ] – [ ERROR ] Invalid header signature; read 0x005301AD65231462, expected 0xE11AB1A1E011CFD0

  15. boonya says:

    Info colleagues know, the original file is encrypted…..thanks anyway!

  16. Ram says:

    Thanks it works

  17. CNNG says:

    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */
    package change.the.world.by.program.cnng;

    import java.io.File;
    import java.io.IOException;

    import jxl.Cell;
    import jxl.Sheet;
    import jxl.Workbook;
    import jxl.read.biff.BiffException;

    /**
    *
    * @author malixiao
    */
    public class FileOpreation {

    /**
    * 16 * @param args 17
    * @param args
    */
    public static void main(String[] args) {
    File f = new File(“a.xls”);
    try {
    Workbook book = Workbook.getWorkbook(f);//
    Sheet sheet = book.getSheet(0); // 获得第一个工作表对象
    System.out.print(sheet.getRows() + ” “);
    for (int i = 0; i < sheet.getRows(); i++) {
    for (int j = 0; j < sheet.getColumns(); j++) {
    Cell cell = sheet.getCell(j, i); // 获得单元格
    System.out.print(cell.getContents() + " ");
    //得到单元格的类型
    //System.out.println(cell.getType());
    }
    System.out.print("\n");
    }
    }
    catch (BiffException | IOException e) {
    System.out.print("123\n");
    }
    // TODO Auto-generated catch block

    }

    }

Leave a Reply

Your email address will not be published. Required fields are marked *