葡京网投哪个正规 > 首页 > 企业应用,java怎么导入Excel

原标题:企业应用,java怎么导入Excel

浏览次数:102 时间:2019-11-02

java 读取excel 文件 Unable to recognize OLE stream 错误,unablerecognize

使用 Java 代码读取 excel 文件代码时报错如下:

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:268)
    at jxl.Workbook.getWorkbook(Workbook.java:253)
    at test1.main(test1.java:25)

 

原因:不支出读取 excel 2007 文件(.xlsx)。只支持 excel 2003 (*.xls)。*

读取excel 文件 Unable to recognize OLE stream 错误,unablerecognize 使用Java代码读取 excel 文件代码时报错如下: jxl.read.biff.BiffException: Unable to r...

  1. 需要下载jxl.jar包

java读取Excel
代码:

java怎么导入Excel 2016?
我使用jxl包的
出现了jxl.read.biff.BiffException: Unable to recognize OLE stream
根据网上说的把xlsx改成xls后 还是一样啊
这怎么解决啊

   自己研究了一下,代码如下

import java.io.*;
import java.util.*;
import jxl.*;
import jxl.read.biff.BiffException;

   

public class ReadExcel{

package file;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public static void main(String[] args) {
try {
Workbook book = Workbook.getWorkbook(new File;
Sheet sheet = book.getSheet;
System.out.println("请输入要读取的单元格");
Scanner in = new Scanner(System.in);
int x = in.nextInt();
in = new Scanner(System.in);
int y = in.nextInt();

import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.*;
import jxl.Sheet;
import jxl.Cell;
import jxl.Workbook;

Cell cell1 = sheet.getCell;
if (cell1.getType() == CellType.NUMBER) {
NumberCell nc = (NumberCell) cell1;
System.out.println("value : " + nc.getValue;
System.out.println("type : " + cell1.getType;
System.out.println("Format : " + cell1.getCellFormat;
System.out.println("NumberFormat: " + nc.getNumberFormat;
System.out.println("Font" + cell1.getCellFeatures;
System.out.println("Colum "+ cell1.getColumn;
System.out.println("Class "+ nc.getClass;
System.out.println;
}

public class excel {

else {
System.out.println("Cell" + " value : " + cell1.getContents()

/**
* @param args
* @throws IOException
* @throws BiffException
*/
public static void main(String[] args) throws BiffException, IOException {
// TODO Auto-generated method stub
Workbook book = Workbook.getWorkbook(new File("F://Center20130902update.xls"));
Sheet sheet=book.getSheet(0);

  • "; type : " + cell1.getType()+"Format"+cell1.getCellFormat;

    }

    book.close();
    } catch (BiffException e) {
    // TODO 自动生成 catch 块
    System.out.println;
    } catch (IOException e) {
    // TODO 自动生成 catch 块
    System.out.println;;
    }

    }
    }

ArrayList list = new ArrayList();

输出:

for(int k=2;k<96;k++){
Map rowData = new HashMap();
for(int j=2;j<5;j++){
Cell cell = sheet.getCell(j,k);//列,行
Cell keycell = sheet.getCell(j,1);
String key = keycell.getContents();
String Content = cell.getContents();
rowData.put(key, Content);
}
list.add(rowData);
}

请输入要读取的单元格
3
3
value : 67.0
type : Number
Format : jxl.biff.XFRecord@1ac33c92
NumberFormat: java.text.DecimalFormat@7d1f1
Fontnull
Colum 3
Class class jxl.read.biff.NumberValue

System.out.println(list);

问题:

book.close();

为什么Format : jxl.biff.XFRecord@1ac33c92
NumberFormat: java.text.DecimalFormat@7d1f1
这两个输出这些啊?是什么?

}

}

本文由葡京网投哪个正规发布于首页,转载请注明出处:企业应用,java怎么导入Excel

关键词:

上一篇:NFS服务器搭建葡京网投哪个正规:

下一篇:没有了