Giter Site home page Giter Site logo

openxmlwordcreater's Introduction

OpenXmlWordCreater

說明

將設定書籤的 Word (*.docx) 範本透過 .NET Core OpenXml 套件將書籤帶入對應的文字內容

套件 DocumentFormat.OpenXml

本範例程式碼使用 .NET Standard 2.1 執行

如何操作

變更範本 (*.docx) 檔案與書籤位置,並給予合適的命名

建立新的範本資料物件 (class) 並修改範本物件與書籤對應方法

... ToKeyValues(object item) ...

在 Word 檔案設定書籤

注意事項

在不調整原始程式碼的情況下,會有下列限制

請使用 "_" 字元標記要替換的書籤 (bookmark)

例: "UserName_"

書籤需設定在「表格」的儲存格中

不然文字的定位可能會錯誤

預設字型會設定如下

中文:標楷體 非中文:Times New Roman

後紀

若直接使用 XML Replace 嘗試取代 OpenXml 的數值的話,可能會因為標籤過於複雜無法取代成功

參考資料

https://stackoverflow.com/questions/21104210/reading-word-bookmarks-using-open-xml-and-c-sharp

https://docs.microsoft.com/zh-tw/office/open-xml/open-xml-sdk

openxmlwordcreater's People

Contributors

txstudio avatar

Stargazers

Horace avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.