aspose file tools*
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
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: 42613
    
  65
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: 39834
    
  28
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.
 
Consider Paul's rocket mass heater.
 
subject: How to read cell content from '*.rtf' file?