Is there a way to generate word documents dynamically without having word on the machine

后端 未结 8 1883
轻奢々
轻奢々 2021-01-30 15:15

I am planning on generating a Word document on the webserver dynamically. Is there good way of doing this in c#? I know I could script Word to do this but I would prefer another

8条回答
  •  无人及你
    2021-01-30 15:29

    If want to generate Office 2007 documents check the Open XML File Formats, they're simple zipped XML files, check this links:

    • Open XML File Formats: What is it, and how can I get started?
    • Introducing the Office (2007) Open XML File Formats

    Edit: Check this project, can serve you as a good starting point:

    • DocumentMaker

    Seems very simple and customizable, look this code snippet:

    Paragraph p = new Paragraph();
    p.Runs.Add(new Run("Text can have multiple format styles, they can be "));
    p.Runs.Add(new Run("bold and italic", 
            TextFormats.Format.Bold | TextFormats.Format.Italic));
    doc.Paragraphs.Add(p);
    

提交回复
热议问题