Coder Social home page Coder Social logo

zzexcelcreator's Introduction

ZzExcelCreator

Excel表格生成工具

项目地址:https://github.com/zhouzhuo810/ZzExcelCreator (欢迎star!)

效果图:

excel1.jpg excel2.jpg excel3.jpg

最近做项目用到jxl.jar来生成Excel表格;

但是发现jxl源码都没有注释的,方法也没有说明, 虽然最后在网上找到了对应的方法。

不过这不是我的style,果断自己封装一下,添加注释。

下面介绍一下用法:

Gradle:

compile 'me.zhouzhuo.zzexcelcreator:zz-excel-creator:1.0.0'

创建Excel文件和工作表

                    ZzExcelCreator
                            .getInstance()
                            .createExcel(PATH, params[0])  //生成excel文件
                            .createSheet(params[1])        //生成sheet工作表
                            .close();

打开Excel文件和工作表

                            ZzExcelCreator
                                    .getInstance()
                                    .openExcel(new File(PATH + fileName + ".xls"))  //打开Excel文件
                                    .openSheet(0)                                   //打开Sheet工作表
                                    ... ...
                                    .close();

设置单元格内容格式:

                            //设置单元格内容格式
                            WritableCellFormat format = ZzFormatCreator
                                    .getInstance()
                                    .createCellFont(WritableFont.ARIAL)  //设置字体
                                    .setAlignment(Alignment.CENTRE, VerticalAlignment.CENTRE)  //设置对齐方式(水平和垂直)
                                    .setFontSize(14)                    //设置字体大小
                                    .setFontColor(Colour.ROSE)          //设置字体颜色
                                    .getCellFormat();

设置行高、列宽和写入字符串或数字

                            ZzExcelCreator
                                    .getInstance()
                                    .openExcel(new File(PATH + fileName + ".xls"))  
                                    .openSheet(0)
                                    .setColumnWidth(Integer.parseInt(col), 25)   //设置列宽
                                    .setRowHeight(Integer.parseInt(row), 400)    //设置行高
                                    .fillContent(Integer.parseInt(col), Integer.parseInt(row), str, format)  //填入字符串
                                    .fillNumber(Integer.parseInt(col), Integer.parseInt(row), Double.parseDouble(str), format)  //填入数字
                                    .close();

最后就是,这些操作最好在子线程操作。

zzexcelcreator's People

Watchers

 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.