Android如何读取Excel并输出到sqlite数据库中?哪位大佬能发个示例程序DEMO?
万分感激
Android没操作过,Java可以用poi或者jxl进行操作excel的导入。
excel用JXl读取数据。
public static JSONArray getGoods(String fileName) {
JSONArray ja = new JSONArray();
File file = new File(fileName);
Workbook workbook = null;
try {
workbook = Workbook.getWorkbook(file);
} catch (BiffException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Sheet sheet = workbook.getSheet(0);
// j为行数,getCell("列号","行号")
int j = sheet.getRows();
int y = sheet.getColumns();
System.out.println("rows = [" + j + "], columns = [" + y + "]");
for (int i = 1; i < j; i++) {
JSONObject o = new JSONObject();
ja.put(o);
}
return ja;
}