This is a Light weight Library to Convert SQLite Database to Excel and Convert Excel to SQLite.
The sample app in the repository is available on Google Play:
Added Pull Request from https://github.com/cleathley
- Added the ability to provide a custom formatter to the export.
- Added the ability to exclude columns from the export.
- Added
pretty
name mapping to export
- Added support to add new column from excel while importing, if the column is not exists.
- Added Functionality to Import Excel into SQLite Database.
- Added Functionality to Export Blob into Image.
- Added Functionality to Export List of tables specified.
add the following library in your app level gradle file
implementation 'com.ajts.androidmads.SQLite2Excel:library:1.0.4'
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
SqliteToExcel sqliteToExcel = new SqliteToExcel(this, "helloworld.db");
SqliteToExcel sqliteToExcel = new SqliteToExcel(this, "helloworld.db", directory_path);
sqliteToExcel.exportSingleTable("table1", "table1.xls", new SQLiteToExcel.ExportListener() {
@Override
public void onStart() {
}
@Override
public void onCompleted(String filePath) {
}
@Override
public void onError(Exception e) {
}
});
sqliteToExcel.exportSpecificTables(tablesList, "table1.xls", new SQLiteToExcel.ExportListener() {
@Override
public void onStart() {
}
@Override
public void onCompleted(String filePath) {
}
@Override
public void onError(Exception e) {
}
});
sqliteToExcel.exportAllTables("table1.xls", new SQLiteToExcel.ExportListener() {
@Override
public void onStart() {
}
@Override
public void onCompleted(String filePath) {
}
@Override
public void onError(Exception e) {
}
});
This code snippet shows how to exclude columns from the export (the resulting export file may not be able to be imported)
ArrayList<String> columnsToExclude = new ArrayList<String>();
columnsToExclude.add("income_id");
sqliteToExcel.setExcludeColumns(columnsToExclude);
...
sqliteToExcel.export...
This code snippet shows how to pretty
names (either sheet names or column names (the resulting export file may not be able to be imported)
HashMap<String, String> prettyNameMapping = new HashMap<String, String>();
prettyNameMapping.put("income_date", "Date");
sqliteToExcel.setPrettyNameMapping(prettyNameMapping);
...
sqliteToExcel.export...
This code snippet shows how to format the value for a column on export (if you want to convert ID's or whatnot to be better displayed)
sqliteToExcel.setCustomFormatter(new SQLiteToExcel.ExportCustomFormatter() {
@Override
public String process(String columnName, String value) {
switch(columnName) {
case "income_type_id":
int v = Integer.parseInt(value);
switch(v) {
case 10:
value = "Sale";
break;
...
default:
value = "Unknown";
break;
}
break;
}
return value;
}
});
The following snippet is used to initialize the library for Importing Excel
ExcelToSQLite excelToSQLite = new ExcelToSQLite(getApplicationContext(), "helloworld.db");
or To drop table while importing the Excel, use the following
ExcelToSQLite excelToSQLite = new ExcelToSQLite(getApplicationContext(), "helloworld.db", true);
excelToSQLite.importFromAsset("assetFileName.xls", new ExcelToSQLite.ImportListener() {
@Override
public void onStart() {
}
@Override
public void onCompleted(String dbName) {
}
@Override
public void onError(Exception e) {
}
});
excelToSQLite.importFromFile(directory_path, new ExcelToSQLite.ImportListener() {
@Override
public void onStart() {
}
@Override
public void onCompleted(String dbName) {
}
@Override
public void onError(Exception e) {
}
});
-dontwarn org.apache.poi.**
Mail me with your Google Play URL and I'll add your app to the list :)
Icon | Developed By | App |
---|---|---|
AJTechsoft | Invoicer | |
CubanApps | Facturas Rápidas |
Please visit the wiki for a complete guide on SQLite2XL.
- If you find that the exported excel is not opened, read the following issue androidmads#7
- Unable to generate signed APK when proguard is enabled, read the following issue androidmads#8
MIT License Copyright (c) 2017 AndroidMad / Mushtaq M A Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.