java 无法识别 OLE 流
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25055715/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to recognize OLE stream
提问by Semih
I want to read xml
file and I use jxl
. But I get error jxl.read.biff.BiffException: Unable to recognize OLE stream
.
我想读取xml
文件,我使用jxl
. 但我得到错误 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 ?
当我在网上搜索时,有人说您应该另存为 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();
}
}
回答by Rohit Sinha
Just go and save again by clicking on Save As and choose Excel 97-2003 WorkBook. it work for me....
只需单击“另存为”并选择“Excel 97-2003 工作簿”即可再次保存。它对我有用....
回答by Kripa Jayakumar
Just renaming it to .xls file does not work.
仅将其重命名为 .xls 文件是行不通的。
You will have to manually go to Save as -> Excel 97-2003 Workbook and save it.
您必须手动转到另存为 -> Excel 97-2003 工作簿并保存。