public class Main {
public static void main(String args[]) throws IOException{
File file = new File("C:/Users/Administrator/Desktop/java文档单词.xlsx");
FileInputStream input = new FileInputStream(file);
XSSFWorkbook workbook = new XSSFWorkbook(input);
Sheet sheet = workbook.getSheetAt(0);
for(int i=0; i<=sheet.getLastRowNum(); i++) {
Row row = sheet.getRow(i);
Cell columnA = row.getCell(0);
Cell columnB = row.getCell(1);
columnB.setCellValue(columnB.getStringCellValue()+"\n");
System.out.println((i+1)+": "+columnA.getStringCellValue()+",,"+columnB.getStringCellValue());
}
FileOutputStream output = new FileOutputStream(file);
workbook.write(output);
workbook.close();
input.close();
output.close();
System.out.println("Ending ! !");
}
}
使用Apache POI读写xlsx文件内容
最新推荐文章于 2023-11-08 10:48:51 发布