1 Star 16 Fork 4

wanghe / FastWord

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MulanPSL-2.0

FastWord

组件介绍

1.为什么会出现fast-word?

文档的导入导出,不管是在ERP,SASS或者诸如一切的其他管理系统,都是必不可少的,而在我实际开发的过程中涉及到的Word是比较多的,我在网上查阅了很多资料,关于Word导出几乎都是模板替换的方式,在word xml中打标签无疑是一件痛苦的事情。于是fast-word应运而生,我给它起名叫“ fast-word”旨在快速,易用,高效的解决我们的问题,节省我们宝贵的时间。

2.fast-word的优势在哪里?

相对于原生poi,我们更简单,同时支持了通过数据生成图片。相对于打标签模板替换的方式,我们更高效,fast-word可以让您只关注业务,您给我们业务数据,只需要三步我们帮您实现从0到1的word生成  快速上手 ,其中包含了图表绘制,表格绘制,文本添加,导出word四大模块。

3.fast-word当前版本是什么?

fastword主程序版本:1.0.5-RELEASES,以下为最新子版本对应关系

fastword-picture fastword-annotation fastword-document
0.0.54 0.0.1.3 0.0.56

##使用示例

  1. 创建图片
private void createPictureExample() throws Exception {
     List<DefaultDataset> list = new ArrayList<>();
     DefaultDataset defaultDataSet = new DefaultDataset("测试",Arrays.asList(new Integer[]{2000, 3444, 4000}), Arrays.asList(new String[]{"清华大学", "北京大学", "山西大学"}));
     list.add(defaultDataSet);
     File file = new DrawBasicLinePicture("各大学人数排序", "学校", "人数") .addDefaultDataSet(list, new DefaultDatasetHandler()).saveAsPNG("d://aa/图片", Report.基础日报);
   }

DefaultXYDataset是适用于有x,y轴数据的图表实体(如折线,柱状),需要显式创建,默认构造如下(其他使用请参照PictureTest下示例):

 DefaultXYDataset defaultDataSet = new DefaultXYDataset("折线图", Arrays.asList(new Integer[]{2, 3, 4}), 
                Arrays.asList(new String[]{"水果", "蔬菜", "鸡蛋"}));
  1. 创建表格
private TableBeans getTableBeans() {
      List<List<String>> childBeans = new ArrayList<>();
      childBeans.add(Arrays.asList(new String[]{"张三", "男", "27", "山西大同"}));
      TableBeans bean = new TableBeans(Arrays.asList(new String[]{"姓名", "性别", "年龄", "地址"}), childBeans);
      return bean;
  }
  1. 导出word文件
String docuemntFile = writer.getDocumentFile("动态分析报告","d://aa"); // 返回值为文档所在存储完整路径

具体实现如下:

 WordFile07Writer writer = new WordFile07Writer();
 writer.addParagraphTableRows(new DefaultTableBeansHandler(this.getTableBeans()), "1、测试标题1");  //TODO 同时添加表格及文本
 writer.addParagraphRows("测试文本")  //TODO 单行文本
 writer.addPicture(new File("D:\\RailReport\\铁科院日报\\2022-05-08\\京广\\上\\2.png")  //TODO 图片及文本
 writer.addParagraphPictureRows(new File("D:\\RailReport\\铁科院日报\\2022-05-08\\京广\\上\\2.png"), "2、测试标题2"); //TODO 同时添加图片及文本

更多示例请参阅API

使用说明

该项目已发布到中央仓库

目前支持折线图,柱状图,散点图,饼图绘制,后续版本会不断优化并添加新的受支持的图表 1.构建maven

<dependency>
            <groupId>cn.fastword</groupId>
            <artifactId>fastword-document</artifactId>
            <version>0.0.33.1b-RELEASES</version>
        </dependency>
        <dependency>
            <groupId>cn.fastword</groupId>
            <artifactId>fastword-picture</artifactId>
            <version>0.0.53.1b-RELEASES</version>
        </dependency>

1.fastword-document为创建word核心jar,包含了常用word添加元素及操作

2.fastword-picture 提供了一系列创建图表的工作 可独立使用

每种都有对应的示例,在gitee源码包中test目录下,您可以在构建完成之后,直接运行即可看到效果,注意:运行临时生成文件路径在D盘

无效版本说明

fastword-document自0.0.33.1b-RELEASES,fastword-picture自0.0.53.1b-RELEASES后的版本为正式可用版本,之前为无效版本,请不要使用,谢谢

参与贡献

联系我

有任何使用问题或报错请发邮箱 1280381827@qq.com 看到后我会及时回复,开源不易,感谢支持

OSCS Status

Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. Mulan Permissive Software License,Version 2 Mulan Permissive Software License,Version 2 (Mulan PSL v2) January 2020 http://license.coscl.org.cn/MulanPSL2 Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: 0. Definition Software means the program and related documents which are licensed under this License and comprise all Contribution(s). Contribution means the copyrightable work licensed by a particular Contributor under this License. Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. Legal Entity means the entity making a Contribution and all its Affiliates. Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. 1. Grant of Copyright License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. 2. Grant of Patent License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. 3. No Trademark License No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. 4. Distribution Restriction You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. 5. Disclaimer of Warranty and Limitation of Liability THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 6. Language THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. END OF THE TERMS AND CONDITIONS How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; iii Attach the statement to the appropriate annotated syntax at the beginning of each source file. Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details.

简介

fast-word(Word快速构建导出) 无需任何模板,通过几步即可导出包含图片及表格的Word文件 展开 收起
Java 等 2 种语言
MulanPSL-2.0
取消

发行版 (2)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/wanghe199512/FastWord.git
git@gitee.com:wanghe199512/FastWord.git
wanghe199512
FastWord
FastWord
master

搜索帮助