我的数据以一种格式存储(向下看):[-] 表示空白单元格,右侧可能只有 10 列,在空格之后。像这样的东西:
[string0] [-] [string1] [string2] [string3] .. [string10] [-]
如何将此代码更改为:
获取完整字符串,对于每一行 fullString = [-] [string1] [string2] [string3] .. [string10] [-]。字符串生成器?或者怎么做?
//Get first sheet from the workbook HSSFSheet sheet = workbook.getSheetAt(0); //Iterate through each rows from first sheet Iterator<Row> rowIterator = sheet.iterator(); while(rowIterator.hasNext()) { Row row = rowIterator.next(); //For each row, iterate through each columns Iterator<Cell> cellIterator = row.cellIterator(); while(cellIterator.hasNext()) { Cell cell = cellIterator.next(); switch(cell.getCellType()) { case Cell.CELL_TYPE_STRING: System.out.print(cell.getStringCellValue() + "\t\t"); list1.add(cell.getStringCellValue()); break; } } System.out.println(""); } file.close(); FileOutputStream out = new FileOutputStream("C:\\Users\\student3\\"+sfilename+".xls"); workbook.write(out); out.close();