日期:2014-05-20 浏览次数:20868 次
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(new File("D:\\workbook.xls")));
FileOutputStream fos = new FileOutputStream(new File("D:\\test.txt"));
HSSFSheet sheet = workbook.getSheetAt(0);
int rows = sheet.getLastRowNum();
for(int i = 0 ;i <= rows ; i++){
HSSFRow row = sheet.getRow(i);
int cells = row.getLastCellNum();
for(int j = 0 ; j < cells ; j++){
HSSFCell cell = row.getCell(j);
String str = cell.getStringCellValue();
fos.write(str.getBytes());
fos.write(" ".getBytes());
}
fos.write("\r\n".getBytes());
}
fos.close();