Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
vasiliy pankratov
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

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

Thanks in advanced.
 
Ryan Beckett
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sun tutorials: I/O
 
vasiliy pankratov
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, but it's not difficult to read '*.rtf' file - difficult to parse it.
I need to get cell content.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
vasiliy pankratov
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for us "beginners." Moving thread.
 
vasiliy pankratov
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote my small parser of ".rtf" file for my small task.
May be it will be bigger.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic