将数据库记录导出到Excel模板

该博客介绍了一个Java程序,用于将数据导出到Excel模板。代码示例展示了如何创建一个包含多行数据的Excel表格,并提供了路径配置以加载和保存模板文件。
摘要由CSDN通过智能技术生成

public class WasteExcel {

// public static String path = “C:\Users\my\Desktop\weixin2\IMDY\upload\”;
//public static String path = “/Users/weixj/Desktop/wph/IMDY/upload”;

public static String path = "upload";

// public static String mdlpath = path+"/template/"+ “【导出】废弃物处理模板.xlsx”;
//public static String mdlpath = “/Users/weixj/Desktop/解压/vehicleCharge-1/templeteWord/隐患排查治理.xlsx”;

//在这里主函数只是用来测试调用,直接调用getXLsx
public static void main(String[] args) throws IOException {
List<List<String[]>> tabledataList = new ArrayList<>();
List<String[]> sheet1 = new ArrayList<String[]>();
for (int i = 0; i < 30; i++) {
sheet1.add(new String[] { “2020-09-09”, “餐厨垃圾”, “10桶”, “张三”, “回收单位”, “回收人员”, “备注” });
}
tabledataList.add(sheet1);
getXLsx(sheet1,“pp”,“2019-10”,133);

}

public static String getXLsx(List<String[]> table1, String mdlpath, String fileName, Integer businessId) throws IOException {
    Date now = new Date();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM");
    String currentTime = dateFormat.format( now );
    try (FileInputStream is = new FileInputStream(path+mdlpath);
         XSSFWorkbook workBook = new XSSFWorkbook(is)) {
        XSSFSheet sheet1 = workBook.getSheetAt(0);  //获取第一页

// List<String[]> table1 = tabledataList.get(0);

        if (table1.size() > 24) {
            //插入行
           Row startRow = sheet1.getRow(2);


            //Row newRow=sheet1.create
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值