GoJava - A comunidade java de Goiás
 
Enviado por diogobastos em qui, 06/17/2010 - 14:13.

Bom dia pessoal,

Estou enfrentando dificuldades na utilização da biblioteca do Apache, o POI.

Tenho um arquivo do tipo .xls e estou tentando instanciar a classe POIFSFileSystem usando o código abaixo:


private void obterArquivo() {
POIFSFileSystem poifsFileSystem = null;
try {
log = new BufferedWriter(new FileWriter(arquive));

poifsFileSystem = new POIFSFileSystem(new BufferedInputStream(new FileInputStream(arquive.getAbsoluteFile())));

sheet = new HSSFWorkbook(poifsFileSystem).getSheetAt(0);
} catch (final FileNotFoundException e) {
e.printStackTrace();
System.exit(0);
} catch (final IOException e) {
e.printStackTrace();
}
rowIterator.next();
}

Mas está sempre dando este erro:


java.io.IOException: Unable to read entire header; 0 bytes read; expected 512 bytes
at org.apache.poi.poifs.storage.HeaderBlockReader.alertShortRead(HeaderBlockReader.java:149)
at org.apache.poi.poifs.storage.HeaderBlockReader.(HeaderBlockReader.java:85)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.(POIFSFileSystem.java:151)
at br.gov.anp.aplicativo.mce.apresentacao.action.MantemTmceInformacoesSecexAction.obterArquivo(MantemTmceInformacoesSecexAction.java:192)
at br.gov.anp.aplicativo.mce.apresentacao.action.MantemTmceInformacoesSecexAction.moveArquivo(MantemTmceInformacoesSecexAction.java:152)

»

Comentários recentes

Divulgar

Conteúdo sindicalizado