加载中…
正文 字体大小:

JXLS分组求和折叠合并模板设置

(2013-12-08 01:36:27)
标签:

jxls分组

折叠合并

模板设置

分类: JAVA

JXLS分组求和折叠合并模板设置

JXLS分组求和折叠合并模板设置

JXLS分组求和折叠合并模板设置

JXLS分组求和折叠合并模板设置

JXLS分组求和折叠合并模板设置

JXLS分组求和折叠合并模板设置

JXLS分组求和折叠合并模板设置

JXLS分组求和折叠合并模板设置

JXLS分组求和折叠合并模板设置

JXLS分组求和折叠合并模板设置

JXLS分组求和折叠合并模板设置

Excel的VBA宏:
Sub MyMerge()
    Dim I%
    Application.DisplayAlerts = False

    For I = [A65536].End(3).Row To 3 Step -1
        If Cells(I, 1) = Cells(I - 1, 1) Then
            Range("A" & I & ":A" & I - 1).Merge
            Range("A" & I & ":A" & I - 1).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter
            Range("A" & I & ":A" & I - 1).VerticalAlignment = Excel.XlVAlign.xlVAlignCenter
        End If
    Next

    Application.DisplayAlerts = True
End Sub

 

数据填充:
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.jxls.exception.ParsePropertyException;
import net.sf.jxls.transformer.XLSTransformer;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
public class JxlsGroup
{
    public static void main(String args[]) throws ParsePropertyException, InvalidFormatException, IOException
    {
        List department = new ArrayList();
        HashMap employee;
        employee = new HashMap();
        employee.put("age", "01组");
        employee.put("name", "张三");
        employee.put("payment", 1111);
        employee.put("bonus", "通用");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "01组");
        employee.put("name", "李四");
        employee.put("payment", 222);
        employee.put("bonus", "同于");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "02组");
        employee.put("name", "张三");
        employee.put("payment", 1111);
        employee.put("bonus", "通用");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "02组");
        employee.put("name", "李四");
        employee.put("payment", 222);
        employee.put("bonus", "同于");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "02组");
        employee.put("name", "王五");
        employee.put("payment", 1111);
        employee.put("bonus", "通用");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "02组");
        employee.put("name", "马六");
        employee.put("payment", 222);
        employee.put("bonus", "同于");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "03组");
        employee.put("name", "张三");
        employee.put("payment", 1111);
        employee.put("bonus", "通用");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "04组");
        employee.put("name", "张三");
        employee.put("payment", 1111);
        employee.put("bonus", "通用");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "04组");
        employee.put("name", "李四");
        employee.put("payment", 222);
        employee.put("bonus", "同于");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "04组");
        employee.put("name", "王五");
        employee.put("payment", 1111);
        employee.put("bonus", "通用");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "04组");
        employee.put("name", "马六");
        employee.put("payment", 222);
        employee.put("bonus", "同于");
        department.add(employee);

        employee = new HashMap();
        employee.put("age", "04组");
        employee.put("name", "赵启");
        employee.put("payment", 222);
        employee.put("bonus", "同于");
        department.add(employee);

        Map beans = new HashMap();
        beans.put("employees", department);

        String destFileName = "C:/C/待退人员花名册1.xls";

        String templateFileName = "";
         templateFileName = "C:/C/00分组求和折叠.xls";
         templateFileName = "C:/C/01分组求和.xls";
         templateFileName = "C:/C/02分组求和.xls";
         templateFileName = "C:/C/11分组求和.xls";
        templateFileName = "C:/C/12分组求和合并.xls";

        XLSTransformer transformer = new XLSTransformer();
        transformer.transformXLS(templateFileName, beans, destFileName);
    }

}

0

阅读 评论 收藏 转载 喜欢 打印举报/Report
  • 评论加载中,请稍候...
发评论

    发评论

    以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

      

    新浪BLOG意见反馈留言板 电话:4006900000 提示音后按1键(按当地市话标准计费) 欢迎批评指正

    新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 会员注册 | 产品答疑

    新浪公司 版权所有