views:

44

answers:

2

I want to read a Open Office Document spreadsheet (.ods file) from my android application. I need to basically loop through the first two columns & store them in a SQLite database.

I am able to do this by reading a regular text file stored in res/raw using the following code:

    InputStream is = context.getResources().openRawResource(R.raw.my_text_file);

But no clue how to do the same for an .ods file.

I searched through SOF & found a reference to jOpenDocument . But they talk about libraries that are not part of the android SDK & I don't know what to do with these.

Any help is appreciated!

+1  A: 

If it's imperative that the file be in ODS format, which is similar to an XML format, you can parse it yourself. Check out the following link.

http://www.go4expert.com/forums/showthread.php?t=19110

Otherwise, may I suggest converting it to a CSV first? CSV means comma-separated-values. Thus It uses an even simpler syntax where each row is separated by a newline and each column in a row by a comma. For that you can use this code to get each line:

http://www.java2s.com/Code/Java/Development-Class/SimpledemoofCSVmatchingusingRegularExpressions.htm

AndrewKS
voteup @ AndrewKS: For now, I have decided to go with your advice of CSV type text file instead of ODS file. The only small alteration I did was to use the hash character (#) as the delimiter, instead of comma, since my data contains commas. I'd still like to try using an ODS file, but it's on the backburner for now. Thanks for your answer!
OceanBlue
A: 

FYI, you can import SOME external JAR libraries into your android project.

Miguel Morales
Thanks. Do you have links on how to do that?
OceanBlue
Here you go, it's fairly simple: http://stackoverflow.com/questions/1334802/how-can-i-use-external-jars-in-an-android-project
Miguel Morales