好傢伙我已經查看了很多關於這個主題的問題,沒有答案爲我工作,我設法在這個answer的幫助下在外部存儲中創建csv文件,試圖將其轉換但它是在正確的格式從SQlite導出數據到excel
ArrayList<AttendRegisterObject> list ;
MyDBHelper db = new MyDBHelper(getApplicationContext());
list = db.ReportGetter();
File exportDir = new File(Environment.getExternalStorageDirectory(), "");
if (!exportDir.exists()) {
exportDir.mkdirs();
}
File file = new File(exportDir, "mdf.csv");
try {
file.createNewFile();
CSVWriter csvWrite = new CSVWriter(new FileWriter(file));
for (int index = 0; index < list.size();) {
String arrStr[] = {String.valueOf(list.get(0))};
csvWrite.writeNext(arrStr);
}
csvWrite.close();
} catch (IOException e) {
e.printStackTrace();
}