Giter Site home page Giter Site logo

toolgood.outputword's Introduction

ToolGood.OutputWord

Word模板导出组件,采用ToolGood.Algorithm计算引擎,支持常用Excel公式,做到模板与代码分离的效果。

快速上手

Nuget 命令行

    Install-Package ToolGood.OutputWord 

后台代码

            // 获取数据
            var helper = SqlHelperFactory.OpenSqliteFile("test.db");
            var dt = helper.ExecuteDataTable("select * from Introduction");
            var tableTests = helper.Select<TableTest>("select * from TableTest");

            ToolGood.OutputWord.WordTemplate openXmlTemplate = new ToolGood.OutputWord.WordTemplate();
            // 加载数据
            openXmlTemplate.SetData(dt);
            openXmlTemplate.SetListData("list", JsonConvert.SerializeObject(tableTests));

            // 生成模板 一
            openXmlTemplate.BuildTemplate("test.docx", "openxml_2.docx");

            // 生成模板 二
            var bs = openXmlTemplate.BuildTemplate("test.docx");
            File.WriteAllBytes("openxml_1.docx", bs);

Word模板设置

a) 普通变量:{变量名}

b) 使用公式:#公式#

c) 名称简化:在文档最后添加 ###变量名:公式

word模板生成后,会自动删除###变量名:公式

d) 表格内插入多条数据:{{公式}}

例:{{list[i].Id}}

其中 list 为SetListData方法中的第一个参数,[i] 为第某行

e) 插入图片:<% 图片 %> ,注意此标签会占整个段落,先清空段落,再插入图片

相关dll文件(防止上线时漏掉)

    Antlr4.Runtime.Standard.dll
    DocumentFormat.OpenXml.dll
    ToolGood.Algorithm.dll
    ToolGood.OutputWord.dll

toolgood.outputword's People

Contributors

toolgood 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.