请注释一下下面的代码谢谢
public void update(String path){
try {
Workbook book = Workbook.getWorkbook(new File(path));
Sheet sheet = book.getSheet(0);
for(int i=1;i<sheet.getRows();i++){
String id = sheet.getCell(0, i).getContents().trim();
String word = sheet.getCell(1, i).getContents().trim();
String level = sheet.getCell(2, i).getContents().trim();
String cixing = sheet.getCell(3, i).getContents().trim();
System.out.println(id+","+word+","+level+","+cixing);
HSKWordLevel wordLevel = this.manager.getHskWordLevelById(NumberUtils.createInteger(id)+8822);
if(wordLevel != null){
wordLevel.setCixing(cixing);
this.manager.updateHskWordLevel(wordLevel);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
请注释一下,最好把用到的类说明一下,谢谢
------解决方案--------------------
public void update(String path){
try {
Workbook book = Workbook.getWorkbook(new File(path)); //打開path下的Excel文件
Sheet sheet = book.getSheet(0); //定位第一個sheet頁
for(int i=1;i <sheet.getRows();i++){ //按行數循環
String id = sheet.getCell(0, i).getContents().trim(); //取得第一行第二列内容去空格
String word = sheet.getCell(1, i).getContents().trim(); //...
String level = sheet.getCell(2, i).getContents().trim(); //...
String cixing = sheet.getCell(3, i).getContents().trim(); //...
System.out.println(id+","+word+","+level+","+cixing); //打印所取得内容
HSKWordLevel wordLevel = this.manager.getHskWordLevelById(NumberUtils.createInteger(id)+8822); //找到WordLevel為“id+8822”内容
if(wordLevel != null){
wordLevel.setCixing(cixing); //將cixing寫入此HSKWordLevel對象中
this.manager.updateHskWordLevel(wordLevel); //更新此對象
}
}
} catch (Exception e) {
e.printStackTrace();
}
}