Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export sqlite database file into XML and then into Excel spreadsheet

I am trying to do this task from the past 12 hour, but still am not able to do this...Now I have an sqlite database file named "testDatabase.db" into the sd card as a backup file..Now I want to open the database into the spreadsheet format so that the end user can access the database and store this spreadsheet database into his system and then further for printout and for other purpose..

I studied some of the tutorials in which It was written that u can firstly convert ur database file into XML and then export this file to excel format..

But am not able to do export my databse file into XML format...As according to my requirement I want on button click my database file should be converted into xml format so that the end user can use it.

Thanks..

like image 923
Kanika Avatar asked Dec 26 '11 10:12

Kanika


2 Answers

I know this might be a little late but in case someone else searches for this and see's this question the best answer would be to export the database as a CSV (comma delimited) file.

sqlite3 has a function just for this called "quote". You can read more about it here:

http://www.sqlite.org/lang_corefunc.html#quote

example:

create table t1 (c1 char, c2 int);

insert into t1 values ('a hi', 1);

insert into t1 values ('b hello', 2);

select quote(a) || ',' || b from t1;

this would return: 'a hi',1 'b hello',2

There are other ways to use the quote function but it really depends on your data and how you want to use it.

like image 76
ouch Avatar answered Oct 04 '22 01:10

ouch


Does the transform have to happen on the Android device?

If you're more flexible about how it's done, you can give the user the sqlite database file and they can import the data via the sqlite ODBC driver: http://www.ch-werner.de/sqliteodbc/

like image 38
Corey Cole Avatar answered Oct 04 '22 02:10

Corey Cole