Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 与.Net Core 2.0一起使用时,Xceed DocX库会创建空白的.DocX文件_C#_.net_.net Core_Docx_Xceed - Fatal编程技术网

C# 与.Net Core 2.0一起使用时,Xceed DocX库会创建空白的.DocX文件

C# 与.Net Core 2.0一起使用时,Xceed DocX库会创建空白的.DocX文件,c#,.net,.net-core,docx,xceed,C#,.net,.net Core,Docx,Xceed,我在UbuntuLinux(16.04)上使用.NETCore2.1,并使用.Net的XceedDocx库。我知道DocX库的目标是.NETFramework4.0/4.6,因此可能存在兼容性问题,但是它至少可以部分工作,所以我认为我遗漏了一些东西 我可以创建一个.docx文件(见下面的代码),但是无论我插入多少内容,doc这个词总是生成为空的 保存文档后,当我使用控制台输出检查文档文本内容时,它显示内容在那里 我想我写文件的方式一定有问题,但是从Xceed代码源代码或者从关于.Net的大量搜索

我在UbuntuLinux(16.04)上使用.NETCore2.1,并使用.Net的XceedDocx库。我知道DocX库的目标是.NETFramework4.0/4.6,因此可能存在兼容性问题,但是它至少可以部分工作,所以我认为我遗漏了一些东西

我可以创建一个.docx文件(见下面的代码),但是无论我插入多少内容,doc这个词总是生成为空的

保存文档后,当我使用控制台输出检查文档文本内容时,它显示内容在那里

我想我写文件的方式一定有问题,但是从Xceed代码源代码或者从关于.Net的大量搜索中根本不清楚应该如何做

如何编写文档内容

类似的问题没有多大帮助:


问题在于该库与dotnetcore不兼容。我在.Net framework项目和.Net核心中运行了您的代码。在框架版本中,它工作正常,在核心部分,我得到了与您相同的结果。谢谢@Magnetron,我可以停止用我的头撞这堵墙了。
using System;
using System.IO;
using Xceed.Words.NET;

namespace docx_generator
{
    class Program
    {
        static void Main(string[] args)
        {
            var filename = "../../Documents/Test.docx";

            using(DocX doc = DocX.Create(filename))
            {
                var p = doc.InsertParagraph("A very basic title");
                doc.Save();

                Console.Write(doc.Text);
                // > A very basic title
            }
        }
    }
}