Unable to recognize OLE stream

13,801

Just go and save again by clicking on Save As and choose Excel 97-2003 WorkBook. it work for me....

Share:
13,801
Semih
Author by

Semih

Updated on June 30, 2022

Comments

  • Semih
    Semih almost 2 years

    I want to read xml file and I use jxl. But I get error jxl.read.biff.BiffException: Unable to recognize OLE stream.

    When I search the internet , Everbody say that You should save as Excel 97-2003 Workbook.But My excel file is Excel 97-2003 .How can I solve this ?

    import java.io.File; 
    import java.io.IOException; 
    
    import jxl.Cell; 
    import jxl.CellType; 
    import jxl.Sheet; 
    import jxl.Workbook; 
    import jxl.read.biff.BiffException; 
    
    public class deneme { 
    
      private String inputFile; 
    
      public void setInputFile(String inputFile) { 
        this.inputFile = inputFile; 
      } 
    
      public void read() throws IOException  { 
        File inputWorkbook = new File(inputFile); 
        Workbook w; 
        try { 
          w = Workbook.getWorkbook(inputWorkbook); 
          // Get the first sheet 
          Sheet sheet = w.getSheet(0); 
          // Loop over first 10 column and lines 
    
          for (int j = 0; j < sheet.getColumns(); j++) { 
            for (int i = 0; i < sheet.getRows(); i++) { 
              Cell cell = sheet.getCell(j, i); 
              CellType type = cell.getType(); 
              if (type == CellType.LABEL) { 
                System.out.println("I got a label " 
                    + cell.getContents()); 
              } 
    
              if (type == CellType.NUMBER) { 
                System.out.println("I got a number " 
                    + cell.getContents()); 
              } 
    
            } 
          } 
        } catch (BiffException e) { 
          e.printStackTrace(); 
        } 
      } 
    
      public static void main(String[] args) throws IOException { 
          deneme test = new deneme(); 
          test.setInputFile("c:/data.xls"); 
          test.read(); 
      } 
    
    }