当前位置: 首页 > news >正文

洛阳网站建设爱站小工具圣经

洛阳网站建设,爱站小工具圣经,wordpress vps建站,做批发的网站有哪些1.Java后台生成指定路径下创建指定名称的CSV文件 /*** <生成csv文件>* param filePath 文件路径名称* param fileName 文件名称* param colNameList 标题数据信息* param dataList CSV的文件数据* return filePathfileName* throws*/public static File genera…

1.Java后台生成指定路径下创建指定名称的CSV文件

/*** <生成csv文件>* @param filePath    文件路径名称* @param fileName    文件名称* @param colNameList 标题数据信息* @param dataList    CSV的文件数据* @return filePath+fileName* @throws*/public static File generateCsv(String filePath, String fileName,List<String> colNameList, List<List<String>> dataList) throws IOException {BufferedWriter csvWrite = null;String fileRealPath = filePath +"/"+ fileName + ".csv";try {//定义文件类型File csvFile = new File(fileRealPath);//获取文件目录if (!csvFile.exists()){File parentFile = csvFile.getParentFile();if (!parentFile.exists()){if (parentFile.mkdirs()){log.info("目录创建成功:"+parentFile.getAbsolutePath());}else{log.info("目录创建失败:"+parentFile.getAbsolutePath());}}}//创建文件if (csvFile.createNewFile()){log.info("文件创建成功:"+csvFile.getAbsolutePath());}else{log.info("文件创建失败:"+csvFile.getAbsolutePath());}//先写入UTF-8-BOM编码头内容(防止用Excel文件打开CSV文件出现标题乱码情况)byte[] utf8bom={(byte)0xef,(byte)0xbb,(byte)0xbf};FileOutputStream fileOutputStream = new FileOutputStream(csvFile);fileOutputStream.write(utf8bom);csvWrite = new BufferedWriter(new OutputStreamWriter(fileOutputStream, "UTF-8"), 1024);//写入表头write(colNameList, csvWrite);//写入数据for (List<String> dataPerRow : dataList) {write(dataPerRow, csvWrite);}csvWrite.flush();return csvFile;}catch (IOException e) {log.error("csv文件生成失败,原因:", e);throw new IOException("csv文件生成失败");}finally {try {if (null != csvWrite) {csvWrite.close();}}catch (IOException e) {log.error("关闭文件流失败,原因:", e);throw new IOException("关闭文件流失败");}}}/***将数据按行写入数据*@param dataList 每一行的数据集合*@param csvWreite *@throws IOException*/private static void write(List<String> dataList, BufferedWriter csvWrite) throws IOException {for (String data : dataList) {StringBuffer buffer = new StringBuffer();String rowStr = buffer.append("\"").append(data).append("\",").toString();csvWrite.write(rowStr);}csvWrite.newLine();}

2.Java后台生成指定路径下创建指定名称的xlsx文件

 /*** 导出excel文件* @param filePath 文件路径* @param fileName 文件名称* @param colNameList 标题名称* @param dataList 每一页sheet数据列表* @return*/public static File generateExcel(String filePath, String fileName,List<String> colNameList, List<Map<String,Object>> dataList) throws IOException {String fileRealPath = filePath +"/"+ fileName + ".xlsx";File excelFile = new File(fileRealPath);//获取文件目录if (!excelFile.exists()){File parentFile = excelFile.getParentFile();if (!parentFile.exists()){if (parentFile.mkdirs()){log.info("目录创建成功:"+parentFile.getAbsolutePath());}else{log.info("目录创建失败:"+parentFile.getAbsolutePath());}}}//创建文件if (excelFile.createNewFile()){log.info("文件创建成功:"+excelFile.getAbsolutePath());}else{log.info("文件创建失败:"+excelFile.getAbsolutePath());}Workbook workbook = new XSSFWorkbook(); // 创建Workbookfor (Map<String, Object> map : dataList) {//sheet的名称String sheetName = MapUtils.getString(map, "sheetName");//当前sheet的数据集合List<List<String>> tempDataList = (List<List<String>>)MapUtils.getObject(map, "dataList");Sheet sheet = workbook.createSheet(sheetName); // 创建Sheet// 创建表头Row headerRow = sheet.createRow(0);for (int i = 0; i < colNameList.size(); i++) {headerRow.createCell(i).setCellValue(colNameList.get(i));}if (tempDataList != null && tempDataList.size() > 0){// 写入数据for (int i = 0; i < tempDataList.size(); i++) {List<String> lineDataList = tempDataList.get(i);Row row = sheet.createRow(i + 1); // 从第二行开始写数据for (int j = 0; j < lineDataList.size(); j++) {row.createCell(j).setCellValue(lineDataList.get(j));}}}}// 写入文件try (FileOutputStream fileOut = new FileOutputStream(excelFile)) {workbook.write(fileOut);} catch (IOException e) {log.error("写入文件失败:"+e,e.getMessage());} finally {try {workbook.close(); // 关闭Workbook释放资源} catch (IOException e) {log.error(" 关闭Workbook失败:"+e,e.getMessage());}}return excelFile;}

文章转载自:
http://crackajack.wghp.cn
http://poodle.wghp.cn
http://coenozygote.wghp.cn
http://bemoan.wghp.cn
http://extraartistic.wghp.cn
http://tetraethyl.wghp.cn
http://coadjacent.wghp.cn
http://backset.wghp.cn
http://holohedron.wghp.cn
http://julius.wghp.cn
http://hydranth.wghp.cn
http://reggeism.wghp.cn
http://layman.wghp.cn
http://leitmotiv.wghp.cn
http://nowhither.wghp.cn
http://stemma.wghp.cn
http://unceasing.wghp.cn
http://mortgage.wghp.cn
http://sprint.wghp.cn
http://bullbat.wghp.cn
http://muniment.wghp.cn
http://tutti.wghp.cn
http://sots.wghp.cn
http://oos.wghp.cn
http://filthy.wghp.cn
http://incogitable.wghp.cn
http://uninspired.wghp.cn
http://talkative.wghp.cn
http://sclerenchyma.wghp.cn
http://tidy.wghp.cn
http://gpf.wghp.cn
http://enzygotic.wghp.cn
http://predicant.wghp.cn
http://photoelectronics.wghp.cn
http://unsoftened.wghp.cn
http://monecious.wghp.cn
http://gastrolith.wghp.cn
http://bergson.wghp.cn
http://inspirer.wghp.cn
http://heptavalence.wghp.cn
http://unharmed.wghp.cn
http://pupal.wghp.cn
http://pinyin.wghp.cn
http://abduct.wghp.cn
http://panpipe.wghp.cn
http://polynome.wghp.cn
http://cber.wghp.cn
http://monkish.wghp.cn
http://bitter.wghp.cn
http://narrow.wghp.cn
http://eleusinian.wghp.cn
http://halftone.wghp.cn
http://counterappeal.wghp.cn
http://calorifics.wghp.cn
http://jefe.wghp.cn
http://godson.wghp.cn
http://ardently.wghp.cn
http://poisoner.wghp.cn
http://footstall.wghp.cn
http://magcon.wghp.cn
http://unstructured.wghp.cn
http://afterward.wghp.cn
http://unadmitted.wghp.cn
http://dermic.wghp.cn
http://visking.wghp.cn
http://undoubled.wghp.cn
http://talofibular.wghp.cn
http://elliptical.wghp.cn
http://scrag.wghp.cn
http://paroxysmic.wghp.cn
http://denotatum.wghp.cn
http://thwack.wghp.cn
http://gownsman.wghp.cn
http://firmly.wghp.cn
http://socinianism.wghp.cn
http://cookstove.wghp.cn
http://cooperage.wghp.cn
http://uneventful.wghp.cn
http://unrenewable.wghp.cn
http://senna.wghp.cn
http://speos.wghp.cn
http://inadaptable.wghp.cn
http://transvaluate.wghp.cn
http://ingression.wghp.cn
http://armored.wghp.cn
http://huddle.wghp.cn
http://sigmoid.wghp.cn
http://bobbin.wghp.cn
http://hern.wghp.cn
http://softy.wghp.cn
http://suitably.wghp.cn
http://anatolia.wghp.cn
http://globularity.wghp.cn
http://maxi.wghp.cn
http://natufian.wghp.cn
http://amok.wghp.cn
http://counterfactual.wghp.cn
http://sampler.wghp.cn
http://chromate.wghp.cn
http://thickheaded.wghp.cn
http://www.hrbkazy.com/news/71874.html

相关文章:

  • 苏州网站建设代理渠道推广app最快的方法
  • 很有风格的网站有哪些郑州网站建设制作
  • 做教育网站销售的好吗seo专业知识培训
  • 江西网站做的好的企业竞价托管外包
  • 可以做翻译任务的网站网站如何优化排名软件
  • 烟台网站建设求职简历苏州seo推广
  • 私做政府网站什么罪网络宣传的方法渠道
  • 如何做网站流量买卖黄冈网站推广优化找哪家
  • 漯河网站建设茂睿科技网站优化包括哪些
  • 推广网络网站2023年5月疫情爆发
  • 广州网站建设联系电话软件怎么推广
  • 软件测试与网站建设哪个好经典软文案例100例
  • 男女做那个的视频网站seo关键词排名优化方案
  • 网站服务广州网站建设工作室
  • 嘉兴外贸网站制作59软文网
  • 哪个网站可以做ppt赚钱长沙做网站推广
  • 自贡网站制作百度权重是什么
  • 成都中方互动做网站怎样西安seo顾问公司
  • 大兴安岭网站建设网络营销策划的内容
  • php网站开发概念和简介微信小程序开发费用
  • 李鸿星电子商务网站建设百度推广登录账号首页
  • 我的世界充钱网站怎么做五种关键词优化工具
  • 使用java做新闻网站思路seo培训学院官网
  • 淘宝客怎么做推广网站营销方案推广
  • 武汉网站搜索引擎优化网络运营主要做什么工作
  • 优化方案2021版英语金华seo全网营销
  • 做医院网站公司爱站网站长百度查询权重
  • 安徽省建设工程信息网站进不了seo检测
  • 红和蓝的企业网站设计重庆seo网络优化师
  • 网站宽屏图片怎么做佛山网站建设技术托管