Question

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!

Was it helpful?

Solution

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

OTHER TIPS

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

JODF supports Android 2.2+ and Java 1.5+. It is Java API for Open Document Format

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top