public class TestUtil {
/**
* 动态头,实时生成头写入
*
* 思路是这样子的,先创建List头格式的sheet仅仅写入头,然后通过table 不写入头的方式 去写入数据
*
*
* 1. 创建excel对应的实体对象 参照{@link }
*
* 2. 然后写入table即可
*/
public static void main(String[] args) throws FileNotFoundException {
String fileName = "C:/Users/HANYUN/Desktop/" + () + ".xlsx";
File file = new File(fileName);
FileOutputStream out = new FileOutputStream(file);
(out)
// 这里放入动态头
.head(head()).sheet("模板")
// 这里数据用 List<List<String>> 去传入
.doWrite(data());
}
private static List<List<String>> head() {
List<List<String>> list = new ArrayList<List<String>>();
for (int i = 0; i < 10; i++) {
List<String> head0 = new ArrayList<String>();
("表头" + i);
(head0);
}
return list;
}
private static List<List<String>> data() {
List<List<String>> list1 = new ArrayList<List<String>>();
for (int j = 0; j < 10; j++) {
List<String> list = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
(i + "ss");
}
(list);
}
return list1;
}
}
瞎写点东西
select
coalesce((case when CONCAT(vsc.run_date,‘’) = ‘2021-07-01’ then max(vsc.electric_control_max) END),0) as ‘2021-07-01’ ,
(case when CONCAT(vsc.run_date,‘’) = ‘2021-07-02’ then max(vsc.electric_control_max) END) as ‘2021-07-02’ ,
(case when CONCAT(vsc.run_date,‘’) = ‘2021-07-03’ then max(vsc.electric_control_max) END) as ‘2021-07-03’ ,
(case when CONCAT(vsc.run_date,‘’) = ‘2021-07-04’ then max(vsc.electric_control_max) END) as ‘2021-07-04’ ,
coalesce((case when CONCAT(vsc.run_date,‘’) = ‘2021-07-21’ then max(vsc.electric_control_max) END),0) as ‘2021-07-21’