您可以使用Apache POI罐子一样
https://poi.apache.org/download.html
代码来设置数据如下: -
public void setXLCellValue(String sheetName,int rowNum,int cellNum, String input)
{
try{
FileInputStream fis=new FileInputStream(xlpath);
Workbook wb=WorkbookFactory.create(fis);
wb.getSheet(sheetName).getRow(rowNum).createCell(cellNum).setCellValue(input);
FileOutputStream fos=new FileOutputStream(xlpath);
wb.write(fos);
fos.close();
}
catch(Exception ex)
{
}
}
代码来获取数据如下: -
public String getXLcellValue(String sheetName, int rowNum, int cellNum)
{
try{
FileInputStream fis=new FileInputStream(xlpath);
Workbook wb=WorkbookFactory.create(fis);
return wb.getSheet(sheetName).getRow(rowNum).getCell(cellNum).getStringCellValue();
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
return "";
}
希望它能帮到你:)
欢迎来到Stackoverflow。请阅读这些链接以改善您的问题:[Tour](https://stackoverflow.com/tour)| [如何问](https://stackoverflow.com/help/how-to-ask)| [最小,完整和可验证示例](https://stackoverflow.com/help/mcve) – Tom
我现在应该编辑好吗? –
代码不存在,我在这里描述我的问题,这是我引发的一个新事物,因此描述了这个问题。 –