It's not a secret anymore!*
The moose likes Java in General and the fly likes How to read cell content from '*.rtf' file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to read cell content from Watch "How to read cell content from New topic
Author

How to read cell content from '*.rtf' file?

vasiliy pankratov
Greenhorn

Joined: Apr 15, 2009
Posts: 4
Hello.

I need to read cell content from '*.rtf' file.
How can i get it in java?

Thanks in advanced.
Ryan Beckett
Ranch Hand

Joined: Feb 22, 2009
Posts: 192
Sun tutorials: I/O
vasiliy pankratov
Greenhorn

Joined: Apr 15, 2009
Posts: 4
Thanks, but it's not difficult to read '*.rtf' file - difficult to parse it.
I need to get cell content.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41083
    
  43
Welcome to JavaRanch.

I can think of two approaches. Either use OpenOffice in server mode to open the file, and get at the cell contents using its Java API.

Or write an RTF grammar for a lexer or parser. It wouldn't need to cover all of RTF, just the parts you're interested in. (The JavaCC parser actually has two RTF grammars available already, so that may be a good start.)


Ping & DNS - my free Android networking tools app
vasiliy pankratov
Greenhorn

Joined: Apr 15, 2009
Posts: 4
Thanks a lot.
I'll write a small rtf parser.
So strange that pure java have no libraries for reading '.rtf'.
Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
hmmm... but there is a small work-around available.

You can convert your RTF to XML, and then do your parsing. Check out this link for more details.

http://www.theserverside.com/discussions/thread.tss?thread_id=21582
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37945
    
  22
Too difficult a question for us "beginners." Moving thread.
vasiliy pankratov
Greenhorn

Joined: Apr 15, 2009
Posts: 4
I wrote my small parser of ".rtf" file for my small task.
May be it will be bigger.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to read cell content from '*.rtf' file?
 
Similar Threads
RTF to PDF transformation
How to update an RTF template file in java?
Read RTF File from Java
rtf to html conversion
Append two rtf files into one rtf document using io stream