启动OpenOffice的钙和开放的csv文件

我有一个函数在我的.NET C#应用程序从出口数据DataGridViewCSV文件,并打开包含文件Excel

有没有办法做到这一点使用OpenOffice Calc呢? 即我怎样才能启动Calc从我的代码的应用程序,并指向CSV文件,我已经?

--------------解决方案-------------

我发现了一篇文章给你

http://www.opendocument4all.com/download/OpenOffice.net.pdf

此代码为您提供了一个想法;

XStorable2 xs = (XStorable2)mxDocument;

xs.storeToURL("file:///C:/oo.xls", new unoidl.com.sun.star.beans.PropertyValue[0]);

我也发现了这个链接,你

创建与C#OpenOffice的Writer文档

创建与C#OpenOffice的Calc文档

C#中的OpenOffice Calc中

编辑:

using System;
using unoidl.com.sun.star.lang;
using unoidl.com.sun.star.uno;
using unoidl.com.sun.star.bridge;
using unoidl.com.sun.star.frame;
using unoidl.com.sun.star.text;
using unoidl.com.sun.star.beans;

XComponentContext oStrap = uno.util.Bootstrap.bootstrap();

XMultiServiceFactory oServMan = (XmultiServiceFactory) oStrap.getServiceManager();

XComponentLoader oDesk = (XComponentLoader) oServMan.createInstance("com.sun.star.frame.Desktop" );

string url = @"private:factory/swriter";
PropertyValue[] propVals = new PropertyValue[0];
XComponent oDoc = oDesk.loadComponentFromURL(url, "_blank", 0, propVals);

string docText = "This will be my first paragraph.\n\r";
docText += "This will be my second paragraph.\n\r";

And then this is written to the body of the document:
((XTextDocument)oDoc).getText().setString(docText);

string fileName = @"C:\Reports\test.odt";
fileName = "file:///" + fileName.Replace(@"\", "/");

And then the file is saved to disk:
((XStorable)oDoc).storeAsURL(fileName, propVals);

((Xcomponent)oDoc).dispose();

Soner格尼尔解释你如何导出为CSV

要打开OpenOffice的Calc的文件刚刚拿到的OpenOffice Calc的可执行文件的路径,并在参数文件路径启动它

Process.Start("pathToYourOpenOfficeCalc.exe","pathToYourCSVFile");

就这样。

分类:C# 时间:2015-03-15 人气:0
分享到:

相关文章

Copyright (C) 55228885.com, All Rights Reserved.

55228885 版权所有 京ICP备15002868号

processed in 1.655 (s). 10 q(s)