views:

111

answers:

0

Hi,

I'm getting:

java.io.IOException: Invalid header signature; read 0x000201060000FFFE, expected 0xE11AB1A1E011CFD0

when trying to add some custom properties to an excel document using apache POI HPSF.

I'm completely sure the file is excel OLE2 (not HTML, XML or something else that excel doesn't complain about).

This is a relevant part of my code:

try {
     final POIFSFileSystem poifs = new POIFSFileSystem(event.getStream());
     final DirectoryEntry dir = poifs.getRoot();
     final DocumentEntry dsiEntry = (DocumentEntry)
             dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);

     final DocumentInputStream dis = new DocumentInputStream(dsiEntry);
     final PropertySet props = new PropertySet(dis);
     dis.close();
     dsi = new DocumentSummaryInformation(props);
    }
    catch (Exception ex) {
        throw new RuntimeException
            ("Cannot create POI SummaryInformation for event: " + event +
              ", path:" + event.getPath() + 
              ", name:" + event.getPath() +
              ", cause:" + ex);
    }

I get the same error when trying with word and power point files (also OLE2).

I'm completely out of ideas so any help/pointers are greatly appreciated :)