我正在创建您需要的 .csv 文件,当您保存或创建时,请立即打开。
这是我的代码,但它不起作用。
public void generateCsvFile(String file, ArrayList<Row> list) {
try {
OutputStreamWriter writer = new OutputStreamWriter(openFileOutput(file, Activity.MODE_PRIVATE));
writer.append("Matricula");
writer.append(',');
writer.append("Fecha Entrada");
writer.append(',');
writer.append("Fecha Salida");
writer.append('\n');
for (int i = 0; i < list.size(); i++) {
Row r = list.get(i);
writer.append(r.getMatricula());
writer.append(',');
writer.append(r.getFechain() + " " + r.getHorain());
writer.append(',');
writer.append(r.getFechaout() + " " + r.getHoraout());
writer.append('\n');
}
writer.flush();
writer.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
任何想法?
问候 亚历