Update
This commit is contained in:
1 parent
6b89500e72
commit
ceaa1f2f86
2 files changed
+7
-7
No files matched your search
Binary file not shown.
@@ -29,10 +29,10 @@ public class DataInput {
|
|||||||
System.out.println("3、返回主菜单");
|
System.out.println("3、返回主菜单");
|
||||||
System.out.print("请选择(1-3):");
|
System.out.print("请选择(1-3):");
|
||||||
int choice = sc.nextInt();
|
int choice = sc.nextInt();
|
||||||
int cnt = 0;
|
int count;
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 1:
|
case 1:
|
||||||
cnt = 0;
|
count = 0;
|
||||||
Workbook workbook = Workbook.getWorkbook(new File("商品信息.xls"));
|
Workbook workbook = Workbook.getWorkbook(new File("商品信息.xls"));
|
||||||
Sheet sheet = workbook.getSheet(0);
|
Sheet sheet = workbook.getSheet(0);
|
||||||
for (int i = 0; i < sheet.getRows(); i++) {
|
for (int i = 0; i < sheet.getRows(); i++) {
|
||||||
@@ -49,14 +49,14 @@ public class DataInput {
|
|||||||
pstmt.setDouble(3, Double.parseDouble(cells[2].getContents()));
|
pstmt.setDouble(3, Double.parseDouble(cells[2].getContents()));
|
||||||
pstmt.setString(4, cells[3].getContents());
|
pstmt.setString(4, cells[3].getContents());
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
cnt++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("成功从excel文件导入" + cnt + "条商品数据");
|
System.out.println("成功从excel文件导入" + count + "条商品数据");
|
||||||
workbook.close();
|
workbook.close();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
cnt = 0;
|
count = 0;
|
||||||
BufferedReader reader = new BufferedReader(new FileReader("商品信息.txt"));
|
BufferedReader reader = new BufferedReader(new FileReader("商品信息.txt"));
|
||||||
reader.readLine();
|
reader.readLine();
|
||||||
String line;
|
String line;
|
||||||
@@ -74,11 +74,11 @@ public class DataInput {
|
|||||||
pstmt.setDouble(3, Double.parseDouble(data[2]));
|
pstmt.setDouble(3, Double.parseDouble(data[2]));
|
||||||
pstmt.setString(4, data[3]);
|
pstmt.setString(4, data[3]);
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
cnt++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
System.out.println("成功从文本文件导入" + cnt + "条商品数据");
|
System.out.println("成功从文本文件导入" + count + "条商品数据");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in new issue
Block a user