我试图从我的.csv文件中获取单元格数据,但它收到错误:jxl.read.biff.BiffException:无法识别OLE流
我不明白如何解决这个问题,请给我一些解决方案,这段代码是针对jxl api的,是对.csv的api支持吗?
代码:
public void read() throws IOException, BiffException {
File inputWorkbook = new File(inputFile);
try
{
w = Workbook.getWorkbook(inputWorkbook.getAbsoluteFile());
// Get the first sheet
Sheet sheet = w.getSheet(0);
// Loop over first 10 column and lines
for (row = 1; row < sheet.getRows(); row++)
{
ReadExcelLotSizeEntity readExcelLotSizeEntity =new ReadExcelLotSizeEntity();
cell = sheet.getCell(1,row);
type= cell.getType();
if (cell.getType() == CellType.LABEL)
{
symbol=cell.getContents();
System.out.println(":::::::::::::::::"+symbol);
readExcelLotSizeEntity.setSymbol(symbol);
}
int col=2;
cell = sheet.getCell(col,row);
while(!cell.getContents().equals("")||cell.getContents()!=null)
{
System.out.println("||||||||||||||||"+cell.getContents());
cell=sheet.getCell(col,row);
col++;
}
lotSize= new Double(cell.getContents());
readExcelLotSizeEntity.setLotSize(lotSize);
readExcelLotSizeEntity.setCreateUserId(1L);
readExcelLotSizeEntity.setCreateDtTm(new Date());
readExcelLotSizeHome.persist(readExcelLotSizeEntity);
}
} catch (BiffException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
Vin*_*han 48
我之前也遇到过这个问题.我用Google搜索并阅读了这篇文章以及许多其他要求解决此问题的帖子BiffException.我没有确切的解决方案,但是当我解决了我的问题时,你也可以这样做.
我试图从MS Office 2010中保存的Excel文件中读取数据,我收到此错误.我将文件保存为Excel 2003-7,然后没有任何问题地阅读它.可能是Office 10中出现此问题但Office 2003-7中不出现此问题.
我希望这对你的情况有用.
小智 9
JXL库不支持 .csv和.xslx格式化,这是Excel-2010使用的格式.因此,使用.xls由JXL库支持的Excel 97-2003 .或者如果你想使用excel-2010,请使用APACHE POI(XSSFWorkbooks)而不是JXL.要使用.csv格式,请使用google for CSVReader库.
| 归档时间: |
|
| 查看次数: |
76922 次 |
| 最近记录: |