用POI解析EXCEL文件报错,高人指点.
HSSFWorkbook workbook = null;
try
{
workbook = new HSSFWorkbook(new FileInputStream( "c:\\12.xls "));
}
catch (
IOException e)
{
e.printStackTrace();
}
.....
执行下面一句时
workbook = new HSSFWorkbook(new FileInputStream( "c:\\12.xls "));
抛出异常:
java.io.IOException: Invalid header signature; read -1964499853149091405, expected -2226271756974174256
at org.apache.poi.poifs.storage.HeaderBlockReader. <init> (HeaderBlockReader.java:100)
at org.apache.poi.poifs.filesystem.POIFSFileSystem. <init> (POIFSFileSystem.java:84)
at org.apache.poi.hssf.usermodel.HSSFWorkbook. <init> (HSSFWorkbook.java:257)
at org.apache.poi.hssf.usermodel.HSSFWorkbook. <init> (HSSFWorkbook.java:238)
at com.swan.stock.StockService.parseExcelFile(StockService.java:37)
at com.swan.stock.StockMainFrameActionAdapter.fileSelect_actionPerformed(StockMainFrameActionAdapter.java:52)
at com.swan.stock.StockMainFrameActionAdapter.actionPerformed(StockMainFrameActionAdapter.java:33)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.Exception: 传入的文件不对
at com.swan.stock.StockService.parseExcelFile(StockService.java:43)
at com.swan.stock.StockMainFrameActionAdapter.fileSelect_actionPerformed(StockMainFrameActionAdapter.java:52)
at com.swan.stock.StockMainFrameActionAdapter.actionPerformed(StockMainFrameActionAdapter.java:33)