gpt4 book ai didi

java - 无法识别 OLE 流

转载 作者:行者123 更新时间:2023-11-30 09:04:50 33 4
gpt4 key购买 nike

我想读取xml 文件,我使用jxl。但是我收到错误 jxl.read.biff.BiffException: Unable to recognize OLE stream

我在网上搜索时,大家都说你应该保存为 Excel 97-2003 工作簿。但是我的 excel 文件是 Excel 97-2003。我该如何解决这个问题?

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();
}

}

最佳答案

点击“另存为”并选择“Excel 97-2003 工作簿”再次保存。它对我有用....

关于java - 无法识别 OLE 流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25055715/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com