gpt4 book ai didi

c# - linux wine Word 互操作 application.Documents.Open 在 word 中打开文档但不将文档返回给客户端

转载 作者:太空狗 更新时间:2023-10-29 11:19:33 26 4
gpt4 key购买 nike

由于一些可怕到无法提及的原因,我希望能够在 Wine 下执行 MS Office 自动化。然而,下面的noddy程序无法从WinWord实例中获取文档对象,尽管该文档已被运行在wine下的WinWord成功打开。

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Word;

// This code is lifted from http://www.dotnetperls.com/word

namespace WordTest
{
class Program
{
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("Usage WordTest word.doc");
return;
}
String docname = args[0];
try
{
Application application = new Application();
Document document = application.Documents.Open(docname);

// Loop through all words in the document. (We get an exception here)
int count = document.Words.Count;
for (int i = 1; i <= count; i++)
{
// Write the word.
string text = document.Words[i].Text;
Console.WriteLine("Word {0} = {1}", i, text);
}
// Close word.
application.Quit();
}
catch (Exception e)
{
Console.WriteLine("Exception {0}\nStacktrace\n{1}", e.Message, e.StackTrace);

}
}
}
}

我尝试使用这些东西(不是上面的简单代码)的事情不能使用 OpenOffice 或 Apache POI 等来完成。

有什么想法吗?

这可能是相关的:

此应用程序构建的 .NET 版本是 2

WinWord 版本为 2007

wine的版本是wine-1.5.6

linux 的发行版是 openSUSE 12.2

Linux 版本 3.4.47-2.38-desktop #1 SMP PREEMPT Fri May 31 20:17:40 UTC 2013 (3961086) x86_64 x86_64 x86_64 GNU/Linux

CPU Intel(R) Core(TM)2 Duo CPU T9400 @ 2.53GHz

最佳答案

这是 Wine 中的一个已知错误。

您可以在此处阅读更多信息:http://osdir.com/ml/wine-bugs/2013-07/msg01794.html

关于c# - linux wine Word 互操作 application.Documents.Open 在 word 中打开文档但不将文档返回给客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18531764/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com