我不知道这样的工作是否有任何 Spring 功能。
我会做的是:
1)使用Apache POI lib,让我们轻松处理Excel文件。
2)读取Excel文件中的每个值(如果我理解你所说的话,那应该是一个新值)
3)用新值更新数据库值
下面是使用 Apache POI 可以完成的代码示例:您在 src/test/resources/Excel 文件夹中获取一个 Excel 文件(例如)并将其存储在“工作簿”对象中。
@Test
public void FindExistingExcelFileTest() {
System.out.println("\n----- FindExistingExcelFile -----");
String pathExcel = "src/test/resources/Excel/";
String fileName = "yourExcelFileHere.xlsx";
File fileExcel = new File(pathExcel + fileName);
try {
InputStream inp = new FileInputStream(fileExcel);
Workbook wb = WorkbookFactory.create(inp);
Sheet sheet1 = wb.getSheetAt(0);
System.out.println("Sheet name = " + sheet1.getSheetName());
Assert.assertNotNull(sheet1);
wb.close();
} catch (IOException | InvalidFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
然后,您可以使用“行”或“单元格”对象处理您的数据。
试试这个,然后回到这里了解更多细节。