Aspose--words-net

5285727058_58971925321_96c85a56-16d6-4f0f-ac2b-959fba4f7b3d.png (19.3 KB)
456444464.png (80.2 KB)
用户想要实现在自己的应用程序当中打开查看、编辑word文档,window10,Visual Studio2019开发。按文档操作打开是空白的,无法显示。

 if (fileDialog.ShowDialog() == DialogResult.OK)
{
    string file = fileDialog.FileName;//返回文件的完整路径 
    // Get the Excel file into stream
    FileStream stream = new FileStream(file, FileMode.Open);
    Console.WriteLine("file opened successfully!");
    if (file.EndsWith(".xls") || file.EndsWith(".xlxs"))
    {
        //---忽略
    }
    else
    {

        //加载word文档
        // Create a new empty document A
        Document docA = new Document();
        // Inisialize a DocumentBuilder
        DocumentBuilder builder = new DocumentBuilder(docA);
        // Insert text to the document A start
        builder.MoveToDocumentStart();
        builder.Write("First Hello World paragraph");
        // Open an existing document B
        Document docB = new Document(stream);
        // Add document B to the and of document A, preserving document B formatting
        docA.AppendDocument(docB, ImportFormatMode.KeepSourceFormatting);
        // Save the output as PDF
        docA.Save("C:\\Temp\\output_AB.pdf");
        stream.Close();
    }
}

5285727058_58971925321_96c85a56-16d6-4f0f-ac2b-959fba4f7b3d.png (19.3 KB)

@chenj 看起来您想将文档编辑器集成到您的应用程序中。 Aspose.Words 不提供任何用于编辑文档的 UI。 但是,您可以使用 Aspose.Words 作为创建此类编辑器的后端。
例如,请参阅编辑器演示。
https://products.aspose.app/words/editor
你可以在这里找到来源。
https://github.com/aspose-words/Aspose.Words-for-.NET

@ 阿列克谢·诺斯科夫 十分感谢

1 Like