OpenOffice Writer 문서 및 출력 텍스트에서 모든 단락을 반복하는 방법. Java 예제가 있지만 코드를 C#으로 변환하는 방법을 모른다. 자바 예제는 여기에서 찾을 수 있습니다 : 내 C# 코드.NET을 사용하는 OpenOffice : 모든 단락을 반복하고 텍스트를 읽는 방법
http://wiki.services.openoffice.org/wiki/API/Samples/Java/Writer/TextDocumentStructure :
InitOpenOfficeEnvironment();
XMultiServiceFactory multiServiceFactory = connect();
XComponentLoader componentLoader =
XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop");
//set the property
PropertyValue[] propertyValue = new PropertyValue[1];
PropertyValue aProperty = new PropertyValue();
aProperty.Name = "Hidden";
aProperty.Value = new uno.Any(false);
propertyValue[0] = aProperty;
XComponent xComponent =
componentLoader.loadComponentFromURL(
@"file:///C:/code/test3.doc",
"_blank", 0, propertyValue);
XEnumerationAccess xEnumerationAccess = (XEnumerationAccess)xComponent;
XEnumeration xParagraphEnumeration = xEnumerationAccess.createEnumeration();
while (xParagraphEnumeration.hasMoreElements())
{
// ???
// The problem is here nextElement() returns uno.Any but
// I some how should get XTextContent????
uno.Any textElement = xParagraphEnumeration.nextElement();
// create another enumeration to get all text portions of
//the paragraph
XEnumeration xParaEnumerationAccess = textElement.createEnumeration();
//step 3 Through the Text portions Enumeration,
//get interface to each individual text portion
}
xComponent.dispose();
xComponent = null;
ODF Toolkit은 Open Document Format 만 지원하지만 대부분의 경우 이전 .doc 또는 새 .docx 형식의 단어가 필요합니다. –