• 写入excel


    package test.com.ict.testcountry;
    
    import org.apache.commons.io.FileUtils;
    import org.apache.commons.io.comparator.DirectoryFileComparator;
    import org.apache.commons.lang3.time.DateFormatUtils;
    import org.apache.poi.ss.usermodel.Workbook;
    import org.jeecgframework.poi.excel.ExcelExportUtil;
    import org.jeecgframework.poi.excel.entity.TemplateExportParams;
    import org.junit.Test;
    
    import com.alibaba.fastjson.JSON;
    import com.alibaba.fastjson.JSONObject;
    import com.ict.compent.fastdfs.common.NameValuePair;
    import com.ict.compent.fastdfs.task.SynSingleFileUploadWorker;
    import com.ict.entity.report.ReportOrdertotal;
    
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.*;
    
    /**
     * Created by WangYa on 2016/6/27.
     */
    public class TestGetInsertSql {
        public static void main(String[] args) throws IOException {
            String jsonObjectData="[{"code":"d1608041321q","currencyDic":"1","orderTime":1470288166000,"pay":200,"realPay":200,"salesmanIdShow":"超级管理员","salesmanIdShowCode":"0001","statusDic":"60"},{"code":"a19465213","currencyDic":"1","orderTime":1470298813000,"pay":200,"realPay":200,"salesmanIdShow":"超级管理员","salesmanIdShowCode":"0001","statusDic":"60"},{"code":"b987654321","currencyDic":"1","orderTime":1470301278000,"pay":1200,"realPay":1200,"salesmanIdShow":"张1","salesmanIdShowCode":"0055","statusDic":"30"},{"code":"e65416841","currencyDic":"1","orderTime":1470301472000,"pay":400,"realPay":400,"salesmanIdShow":"超级管理员","salesmanIdShowCode":"0001","statusDic":"30"},{"code":"d200001","currencyDic":"1","orderTime":1470311415000,"pay":400,"realPay":400,"salesmanIdShow":"超级管理员","salesmanIdShowCode":"0001","statusDic":"40"},{"code":"5664","currencyDic":"1","orderTime":1470454938000,"pay":190,"realPay":190,"salesmanIdShow":"郝1","salesmanIdShowCode":"0047","statusDic":"40"},{"code":"d45a","currencyDic":"1","orderTime":1470466167000,"pay":150,"realPay":150,"salesmanIdShow":"郝1","salesmanIdShowCode":"0047","statusDic":"30"}]";  
            List<ReportOrdertotal> jsonObject = JSONObject.parseArray(jsonObjectData, ReportOrdertotal.class);  
            //导出
            TemplateExportParams params = new TemplateExportParams("E://tpl_ordertotal.xls");
            Map<String, Object> map = new HashMap<>();
            map.put("date", DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
            map.put("maplist", jsonObject);
            Workbook workbook = ExcelExportUtil.exportExcel(params, map);
            File file = new File("E://123.xls");
            //写入到临时文件
            OutputStream out = new FileOutputStream(file);
            workbook.write(out);
            out.flush();
            InputStream in = new FileInputStream(file);
            byte b[] = new byte[in.available()];
            in.read(b);
            in.close();
            out.close();
        }
    }
  • 相关阅读:
    TcIC(Teamcenter集成CatiaV5)的安装
    centos7上使用bind解析子域名
    Windows10 家庭版(1903/1909)中用RDPWrapper-v1.6.2和autoupdate补丁开启远程桌面功能
    修改SQL Server Express 2019 sa用户密码的方法
    微星B450主板安装64G内存的一个小招数
    缩小xfs文件系统的CentOS/RedHat虚拟机硬盘的迂回方法
    MQL命令的打开方式
    台电TBook二合一本全新安装Windows10
    django_auth_ldap
    开始认真学计算机网络----computer network学习笔记(一)
  • 原文地址:https://www.cnblogs.com/go4mi/p/5744701.html
Copyright © 2020-2023  润新知