如何使用 OpenOffice.org API 导入 CSV 文件?我想使用与使用“CVS 文本”过滤器打开同一文件时提供的相同功能来执行此操作。
kovica
问问题
2018 次
2 回答
1
这是使用 OO.org 宏语言的解决方案,但它应该是一个很好的起点:http ://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=12835
于 2009-01-03T15:44:25.700 回答
1
这是真正有效的解决方案:
XComponentContext xLocalContext = Bootstrap.bootstrap();
XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
Object desktop = xLocalServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", xLocalContext);
XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop);
PropertyValue[] mypv = new PropertyValue[3];
mypv[0] = new PropertyValue();
mypv[0].Name = new String("FilterName");
mypv[0].Value = new String("Text - txt - csv (StarCalc)");
mypv[1] = new PropertyValue();
mypv[1].Name = "Hidden";
mypv[1].Value = new Boolean(false);
mypv[1] = new PropertyValue();
mypv[1].Name = "CharacterSet";
mypv[1].Value = "UTF-8";
mypv[2] = new PropertyValue();
mypv[2].Name = "FilterOptions";
mypv[2].Value = "59,34,0,1,1/1/2/1/3/5";
String internalFile = ExternalUriReferenceTranslator.create(xLocalContext).translateToInternal("file://" + csvFile.getAbsolutePath());
XComponent comp = xComponentLoader.loadComponentFromURL(internalFile, "_parent", 0, mypv);
于 2009-01-13T14:24:17.377 回答