Java实现生成实现生成Excel树形表头完整代码示例树形表头完整代码示例
主要介绍了Java实现生成Excel树形表头完整代码示例,具有一定借鉴价值,需要的朋友可以参考下。
本文主要分享了Java实现生成Excel树形表头完整代码示例,没有什么好解释的,直接看看代码过程。
源数据格式:
String[] targetNames = {
"指标名称",
"单位",
"xx_yy1",
"xx_yy2_zz1",
"xx_yy2_zz2",
"2017年5月_主营业务收入_累计", "2017年5月_主营业务收入_同比",
"2017年5月_主营业务收入_本月", "2017年5月_主营业务收入_环比",
"2017年5月_利润_累计", "2017年5月_利润_同比", "2017年5月_利润_本月", "2017年5月_利润_环比",
"2017年6月_主营业务收入_累计", "2017年6月_主营业务收入_同比",
"2017年6月_主营业务收入_本月", "2017年6月_主营业务收入_环比",
"2017年6月_利润_累计", "2017年6月_利润_同比", "2017年6月_利润_本月", "2017年6月_利润_环比"
};
生成如下Excel:
第一行不属于树形表头。
代码
SplitCell:
package com.zzj.excel;
public class SplitCell {
private String key;
private String parentKey;
private String value;
private int columnIndex;
private int rowIndex;
public SplitCell() {
}
public SplitCell(String key, String value) {
this.key = key;
this.value = value;
}
public SplitCell(String key, String parentKey, String value,
int columnIndex, int rowIndex) {
this.key = key;
this.parentKey = parentKey;
this.value = value;
this.columnIndex = columnIndex;
this.rowIndex = rowIndex;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getParentKey() {
return parentKey;
}
public void setParentKey(String parentKey) {
this.parentKey = parentKey;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
评论0