zoukankan      html  css  js  c++  java
  • jxl.read.biff.BiffException: Unable to recognize OLE stream

    1、错误描述

    jxl.read.biff.BiffException: Unable to recognize OLE stream
    	at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:116)
    	at jxl.read.biff.File.<init>(File.java:127)
    	at jxl.Workbook.getWorkbook(Workbook.java:221)
    	at jxl.Workbook.getWorkbook(Workbook.java:198)
    	at com.you.print.ExcelPrint.readWriteData(ExcelPrint.java:40)
    	at com.you.print.ExcelPrint.main(ExcelPrint.java:69)

    2、错误原因

    jxl.read.biff.BiffException: Unable to recognize OLE stream
    	at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:116)
    	at jxl.read.biff.File.<init>(File.java:127)
    	at jxl.Workbook.getWorkbook(Workbook.java:221)
    	at jxl.Workbook.getWorkbook(Workbook.java:198)
    	at com.you.print.ExcelPrint.readWriteData(ExcelPrint.java:40)
    	at com.you.print.ExcelPrint.main(ExcelPrint.java:69)
    
    
    
    
    /**
     * 
     */
    package com.you.print;
    
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    
    import jxl.Workbook;
    import jxl.format.Border;
    import jxl.format.BorderLineStyle;
    import jxl.read.biff.BiffException;
    import jxl.write.Label;
    import jxl.write.WritableCellFormat;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;
    import jxl.write.WriteException;
    import jxl.write.biff.RowsExceededException;
    
    /**
     * @author Administrator
     *
     */
    public class ExcelPrint 
    {
    	public void readWriteData()
    	{
    		WritableWorkbook wwb = null;
    		WritableSheet wws=null;  
            FileOutputStream out =null;  
    		File file = new File("D:\myeclipseworkspces\Print\model\WeightBill.xlsx");
    		Label label=null;  
    		WritableCellFormat wcf=new WritableCellFormat(); 
    		try 
    		{
    			Workbook wb;
    			try 
    			{
    				wb = Workbook.getWorkbook(file);
    				out = new FileOutputStream(file);
    				wwb = Workbook.createWorkbook(out, wb);
    				wws = wwb.getSheet("过磅单");
    				wcf.setBorder(Border.ALL, BorderLineStyle.THIN);
    				label = new Label(2, 6, "20170414001", wcf);
    				wws.addCell(label);
    			} 
    			catch (BiffException e) 
    			{
    				e.printStackTrace();
    			} 
    			catch (IOException e) 
    			{
    				e.printStackTrace();
    			} 
    			
    		} 
    		catch (WriteException e) 
    		{
    			e.printStackTrace();
    		}
    	}
    	
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) 
    	{
    		new ExcelPrint().readWriteData();
    	}
    
    }
    
         由于jxl是支持excel2003版本 xsl,不支持excel2007版本 xlsx

    3、解决办法

    (1)修改文件后缀名,改为excel2003版本excel

    (2)将jxl有关的jar改为poi jar

  • 相关阅读:
    escape
    洛谷 P2158 【仪仗队】
    GIT学习----第五节:管理修改
    前端Webpack
    20 行 JS 代码,实现复制到剪贴板功能
    mysql表分区和分表的实现方式几种以及区别,什么时候用
    微信小程序----解析px、rpx、rem、vw实现页面布局
    微信小程序----相对路径图片不显示
    微信小程序----评价系统中的评星
    微信小程序----session_key失效导致的后台错误wxsp login api aesCbcUtil error info: pad block corrupted
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313888.html
Copyright © 2011-2022 走看看