我的解决方案是在第一步将sqlite数据库转换为csv然后在第二步将csv文件转换为xls并且它对我来说工作正常,你将需要2个库(opencsv-1.7.jar; poi-3.8-20120326.罐)
public class ExportDatabaseCSVTask extends AsyncTask
{
private final ProgressDialog dialog = new ProgressDialog(DatabaseExampleActivity.this);
@Override
protected void onPreExecute()
{
this.dialog.setMessage("Exporting database...");
this.dialog.show();
}
protected Boolean doInBackground(final String... args)
{
File dbFile=getDatabasePath("database_name");
//AABDatabaseManager dbhelper = new AABDatabaseManager(getApplicationContext());
AABDatabaseManager dbhelper = new AABDatabaseManager(DatabaseExampleActivity.this) ;
System.out.println(dbFile); // displays the data base path in your logcat
File exportDir = new File(Environment.getExternalStorageDirectory(), "");
if (!exportDir.exists())
{
exportDir.mkdirs();
}
File file = new File(exportDir, "excerDB.csv");
try
{
if (file.createNewFile()){
System.out.println("File is created!");
System.out.println("myfile.csv "+