• 大小: 1.4MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-30
  • 语言: 其他
  • 标签: JXLS  2.4.0  excel  

资源简介

JXLS 2.4.0 直接导出Excel 官方例子,部分修改, multiSheet 操作,指定function

资源截图

代码片段和文件信息

package org.jxls.demo;

import org.jxls.area.XlsArea;
import org.jxls.command.Command;
import org.jxls.command.EachCommand;
import org.jxls.command.IfCommand;
import org.jxls.common.AreaRef;
import org.jxls.common.CellRef;
import org.jxls.common.Context;
import org.jxls.demo.model.Department;
import org.jxls.transform.Transformer;
import org.jxls.util.TransformerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

/**
 * @author Leonid Vysochyn
 *         Date: 2/16/12 5:39 PM
 */
public class AreaListenerDemo {
    static Logger logger = LoggerFactory.getLogger(AreaListenerDemo.class);
    private static String template = “each_if_demo.xls“;
    private static String output = “target/listener_demo_output.xls“;

    public static void main(String[] args) throws IOException {
        logger.info(“Running Area Listener demo“);
        execute();
    }

    public static void execute() throws IOException {
        List departments = EachIfCommandDemo.createDepartments();
        logger.info(“Opening input stream“);
        try(InputStream is = EachIfCommandDemo.class.getResourceAsStream(template)) {
            try (OutputStream os = new FileOutputStream(output)) {
                Transformer transformer = TransformerFactory.createTransformer(is os);
                System.out.println(“Creating area“);
                XlsArea xlsArea = new XlsArea(“Template!A1:G15“ transformer);
                XlsArea departmentArea = new XlsArea(“Template!A2:G12“ transformer);
                EachCommand departmentEachCommand = new EachCommand(“department“ “departments“ departmentArea);
                XlsArea employeeArea = new XlsArea(“Template!A9:F9“ transformer);
                XlsArea ifArea = new XlsArea(“Template!A18:F18“ transformer);
                XlsArea elseArea = new XlsArea(“Template!A9:F9“ transformer);
                IfCommand ifCommand = new IfCommand(“employee.payment <= 2000“
                        ifArea
                        elseArea);
                ifArea.addAreaListener(new SimpleAreaListener(ifArea));
                elseArea.addAreaListener(new SimpleAreaListener(elseArea));
                employeeArea.addCommand(new AreaRef(“Template!A9:F9“) ifCommand);
                Command employeeEachCommand = new EachCommand(“employee“ “department.staff“ employeeArea);
                departmentArea.addCommand(new AreaRef(“Template!A9:F9“) employeeEachCommand);
                xlsArea.addCommand(new AreaRef(“Template!A2:F12“) departmentEachCommand);
                Context context = new Context();
                context.putVar(“departments“ departments);
                logger.info(“Applying at cell “ + new CellRef(“Down!A1“));
                xlsArea.applyAt(new CellRef(“Down!A1“) context);
      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1226  2017-07-18 09:35  jxls_2.4.0_examples\.classpath

     文件        777  2017-07-18 09:35  jxls_2.4.0_examples\.project

     文件        243  2017-07-18 09:35  jxls_2.4.0_examples\.settings\org.eclipse.jdt.core.prefs

     文件         90  2017-07-18 09:34  jxls_2.4.0_examples\.settings\org.eclipse.m2e.core.prefs

     文件       4320  2017-03-06 20:32  jxls_2.4.0_examples\pom.xml

     文件       2988  2016-04-28 14:47  jxls_2.4.0_examples\README.md

     文件       3580  2015-08-24 18:42  jxls_2.4.0_examples\src\main\java\org\jxls\demo\AreaListenerDemo.java

     文件       1452  2015-08-24 18:42  jxls_2.4.0_examples\src\main\java\org\jxls\demo\CustomexpressionNotationDemo.java

     文件       2936  2017-07-18 17:02  jxls_2.4.0_examples\src\main\java\org\jxls\demo\DynamicColumnsDemo.java

     文件       5481  2017-07-18 10:57  jxls_2.4.0_examples\src\main\java\org\jxls\demo\EachIfCommandDemo.java

     文件       2640  2015-08-24 18:42  jxls_2.4.0_examples\src\main\java\org\jxls\demo\EachIfxmlBuilderDemo.java

     文件       1411  2015-10-15 22:49  jxls_2.4.0_examples\src\main\java\org\jxls\demo\FormulaCopyDemo.java

     文件       2009  2015-08-24 18:42  jxls_2.4.0_examples\src\main\java\org\jxls\demo\FormulaExportDemo.java

     文件       3411  2016-06-20 18:16  jxls_2.4.0_examples\src\main\java\org\jxls\demo\GridCommandDemo.java

     文件       1772  2015-07-23 21:46  jxls_2.4.0_examples\src\main\java\org\jxls\demo\GroupRowCommand.java

     文件       1287  2017-03-17 20:25  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\Employee.java

     文件       2259  2017-03-09 22:35  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\GroupingDemo.java

     文件       2594  2017-02-18 11:45  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\HighlightCellAreaListener.java

     文件       2893  2017-02-18 11:41  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\HighlightDemo.java

     文件       1976  2017-02-18 11:04  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\HighlightDemo2.java

     文件        900  2017-03-07 18:59  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\IfCommandDemo.java

     文件       1993  2015-08-24 18:20  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\NestedCommandDemo.java

     文件       3103  2015-08-24 18:33  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\NestedCommandJavaAPIDemo.java

     文件       2051  2016-01-28 23:41  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\objectCollectionByColumnsDemo.java

     文件       2007  2017-03-09 22:26  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\objectCollectionDemo.java

     文件       1317  2015-08-24 18:33  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\objectCollectionFormulasDemo.java

     文件       2637  2015-08-24 18:36  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\objectCollectionJavaAPIDemo.java

     文件       2749  2015-08-24 18:36  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\objectCollectionxmlBuilderDemo.java

     文件       2046  2015-08-24 18:36  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\ParameterizedFormulasDemo.java

     文件       1956  2017-03-12 14:41  jxls_2.4.0_examples\src\main\java\org\jxls\demo\guide\SumIfFormulaDemo.java

............此处省略297个文件信息

评论

共有 条评论