2

How can I get text from Open Office document?

I use OO to convert ms word and excel files to PDF format in order to display in a web page. But in some cases, it is possible to face corrupted files, and corrupted files opens as very big xml.

To solve this problem I am going to get first row of content, and if xml tag exists suggest to user download document and try repair or open it in ms word. But I didn't find any detailed documentation and examples how to work with text.

DDave
  • 608
  • 6
  • 17

1 Answers1

0

From the tag, I assume you are looking for information using C#. There are not many examples, but have a look at Andrew Pitonyak's Macro Document section 24.1. The example inserts text into a writer document.

One way to read text is to create a cursor, select the first line, and then get the value by calling oCursor.getString(). This page shows example commands in Basic which you can adapt to C#.

Jim K
  • 12,824
  • 2
  • 22
  • 51