Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.io.IOException:头签名无效;阅读1688935826934608,预期为222671756974174256_Java - Fatal编程技术网

java.io.IOException:头签名无效;阅读1688935826934608,预期为222671756974174256

java.io.IOException:头签名无效;阅读1688935826934608,预期为222671756974174256,java,Java,我正在从excel文件中读取数据。没有错误,但我得到了异常 like Invalid header signature; read 1688935826934608, expected -2226271756974174256 is at an error in code a=or in excel file 这是我的密码: import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.hssf.

我正在从excel文件中读取数据。没有错误,但我得到了异常

 like Invalid header signature; read 1688935826934608, expected -2226271756974174256
 is at an error in code a=or in excel file
这是我的密码:

import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hssf.usermodel.HSSFCell; 
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; 
import org.apache.poi.hssf.usermodel.HSSFRow;
public class Exexel1
{
    public static void main( String [] args ) 
    { 
     try
      {  
        InputStream input = new BufferedInputStream( new FileInputStream("C:/Users/Administrator/Desktop/sample.xlsx"));
        POIFSFileSystem fs = new POIFSFileSystem( input );
        HSSFWorkbook wb = new HSSFWorkbook(fs);
        HSSFSheet sheet = wb.getSheetAt(0); 
        Iterator rows = sheet.rowIterator();
        while( rows.hasNext() ) 
        {
            HSSFRow row = (HSSFRow) rows.next();
            System.out.println("\n");
            Iterator cells = row.cellIterator();
            while( cells.hasNext() ) 
            {
                HSSFCell cell = (HSSFCell) cells.next();
                if(HSSFCell.CELL_TYPE_NUMERIC==cell.getCellType()) 
                    System.out.print( cell.getNumericCellValue()+" " );
                else if(HSSFCell.CELL_TYPE_STRING==cell.getCellType())
                    System.out.print( cell.getStringCellValue()+" " ); 
                else if(HSSFCell.CELL_TYPE_BOOLEAN==cell.getCellType())
                    System.out.print( cell.getBooleanCellValue()+" " );
                else if(HSSFCell.CELL_TYPE_BLANK==cell.getCellType()) 
                    System.out.print( "BLANK " ); 
                else System.out.print("Unknown cell type");
            }
        }
    } catch ( IOException ex )
       {
        ex.printStackTrace();
        }
 }
}

你能发布完整的堆栈跟踪吗?请给我们更多的堆栈跟踪信息。最好创建一个运行的示例来重现您的问题。您知道Excel文件是JAR文件,对吗?因此,需要打开JAR来访问其中的单个成员。