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

深圳疫情开放时间淘宝优化关键词的步骤

深圳疫情开放时间,淘宝优化关键词的步骤,利用网盘做视频网站,建设网站费1、System.getProperty(user.dir) 获取的是启动项目的容器位置 2、 Files.copy(sourceFile.toPath(), destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING); StandardCopyOption.REPLACE_EXISTING 来忽略文件已经存在的异常,如果存在就去覆盖掉它Sta…

1、System.getProperty(user.dir) 获取的是启动项目的容器位置

2、 Files.copy(sourceFile.toPath(), destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING);

  • StandardCopyOption.REPLACE_EXISTING 来忽略文件已经存在的异常,如果存在就去覆盖掉它
  • StandardCopyOption.COPY_ATTRIBUTES copy文件的属性,最近修改时间,最近访问时间等信息,不仅copy文件的内容,连文件附带的属性一并复制
     

    //获得要下载的excel的模板、其中mb.xlsx是模板String sourceFilePath = System.getProperty("user.dir") + File.separator + "mb.xlsx";//获得用户的当前工作目录String currentPath = System.getProperty("user.dir");//创建要生成的excel的路径String fileName1 = "mb" + System.currentTimeMillis();String destinationFilePath = currentPath + File.separator + fileName1 + ".xlsx";// 创建源文件和目标文件对象File sourceFile = new File(sourceFilePath);File destinationFile = new File(destinationFilePath);try {// 复制文件Files.copy(sourceFile.toPath(), destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING);System.out.println("文件复制成功!");} catch (IOException e) {e.printStackTrace();}//填充数据exportRawData(list, 1, destinationFilePath);String fileName = "分析-" + s + "月.xlsx";File file = new File(destinationFilePath); if (file.exists()) {String mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";response.setContentType(mimeType);response.setContentLength((int) file.length());response.setCharacterEncoding("UTF-8");response.setHeader("content-Type", "application/vnd.ms-excel");response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));try (BufferedInputStream inStream = new BufferedInputStream(new FileInputStream(file));BufferedOutputStream outStream = new BufferedOutputStream(response.getOutputStream())) {byte[] buffer = new byte[4096];int bytesRead;while ((bytesRead = inStream.read(buffer)) != -1) {outStream.write(buffer, 0, bytesRead);}}} else {response.sendError(HttpServletResponse.SC_NOT_FOUND);}Files.delete(Paths.get(destinationFilePath));
}

 填充数据的代码:

    boolean exportRawData(List<ImpactIndexTable> list, Integer type, String filePath) {String sheetName ="原始数据";// 要填充数据的起始行数int rowNum = 4;// 要填充数据的起始列数int colNum = 0;int rowTotal = 18;try (FileInputStream fis = new FileInputStream(filePath);Workbook workbook = new XSSFWorkbook(fis)) {Sheet sheet = workbook.getSheet(sheetName);if (sheet == null) {// 如果指定的工作表不存在,可以在这里进行处理log.info("指定的工作表不存在!");}for (int i = 0; i < list.size(); i++) {// 创建并设置单元格样式CellStyle style = workbook.createCellStyle();style.setAlignment(HorizontalAlignment.CENTER);style.setVerticalAlignment(VerticalAlignment.CENTER);SXSSFWorkbook wb = new SXSSFWorkbook(-1);// 获取要填充的行Row row = sheet.getRow(rowNum + i);if (row == null) {row = sheet.createRow(rowNum + i);}for (int n = 0; n < rowTotal; n++) {Cell cell = row.createCell(colNum + n);switch (n) {case 0:cell.setCellValue(list.get(i).getProjectName());cell.setCellStyle(style);break;case 1:cell.setCellValue(list.get(i).getHw());cell.setCellStyle(style);break;//后续按照需要填充数据default:}}}// 保存修改后的Excel文件try (FileOutputStream fos = new FileOutputStream(filePath)) {workbook.write(fos);log.info("数据导出成功:{}", type);return true;}} catch (Exception e) {log.error("导出错误:{}", e);}return false;}

http://www.dt0577.cn/news/21500.html

相关文章:

  • 电玩网站开发重庆关键词优化软件
  • 深圳 做网站青岛爱城市网app官方网站
  • 网站开发专员招聘视频优化是什么意思
  • 世代网络网站建设设计链接下载
  • 互联网销售公司快速提高网站关键词排名优化
  • 莞城仿做网站建网站公司
  • 做网站电脑配置seo知名公司
  • 网站制作结构郑州seo博客
  • 广州制作网页设计铁岭网站seo
  • php网站设计毕业论文中国唯一没有疫情的地方
  • 我的网站为什么推广平台 赚佣金
  • 去掉自豪的使用wordpress百度整站优化
  • 企业网站制作怎么做推广资源seo
  • 网站建设中翻译app推广软文范文
  • pc网站做成移动网站视频剪辑培训机构
  • 网站站长指南开网店3个月来亏了10万
  • 怎样设计网站建设百度推广官网登录
  • 新站如何让百度快速收录整合营销方案怎么写
  • 制作app需要先做网站青岛关键词优化seo
  • 做网站的IT行业山东关键词快速排名
  • 站长seo计费系统百度账号找回
  • 建设银行员工网站seo交流
  • b2b网站大全黄页麻豆b站推广网站入口2023是什么
  • 天津个人专业做网站360推广助手
  • python做项目的网站石家庄关键词优化软件
  • 江苏专业网站建设烘焙甜点培训学校
  • ps怎么做网站首页图安徽网站seo公司
  • 网站系统升级seo排名优化收费
  • c 做网站实例网站设计公司建设网站
  • 网站app简单做手机免费建站app