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

公司网站建设总结报告网络营销的含义

公司网站建设总结报告,网络营销的含义,好玩的网游,app应用开发EASYEXCEL导出表格(有标题、单元格合并) xlsx格式报表的导出,导出的数据存在父子关系,即相当于树形数据,有单元格合并和标题形式的要求,查阅了一些资料,总算是弄出来了,这里另写一个…

EASYEXCEL导出表格(有标题、单元格合并)

xlsx格式报表的导出,导出的数据存在父子关系,即相当于树形数据,有单元格合并和标题形式的要求,查阅了一些资料,总算是弄出来了,这里另写一个小样简单分享一下关于easyExcel导出具有合并单元格和标题的小结 代码,也算记录一下自己的工作学习。

public class BizMergeStrategy extends AbstractMergeStrategy {private Map<String, List<RowRangeDto>> strategyMap;private Sheet sheet;public BizMergeStrategy(Map<String, List<RowRangeDto>> strategyMap) {this.strategyMap = strategyMap;}@Overrideprotected void merge(Sheet sheet, Cell cell, Head head, Integer integer) {this.sheet = sheet;//如果没有标题,只有表头的话,这里的 cell.getRowIndex() == 1if (cell.getRowIndex() == 2 && cell.getColumnIndex() == 0) {/*** 保证每个cell被合并一次,如果不加上面的判断,因为是一个cell一个cell操作的,* 例如合并A2:A3,当cell为A2时,合并A2,A3,但是当cell为A3时,又是合并A2,A3,* 但此时A2,A3已经是合并的单元格了*/for (Map.Entry<String, List<RowRangeDto>> entry : strategyMap.entrySet()) {Integer columnIndex = Integer.valueOf(entry.getKey());entry.getValue().forEach(rowRange -> {//添加一个合并请求sheet.addMergedRegionUnsafe(new CellRangeAddress(rowRange.getStart(),rowRange.getEnd(), columnIndex, columnIndex));});}}}public static Map<String, List<RowRangeDto>> addAnnualMerStrategy(List<ContrastIndicatorDeptExcel> projectDtoList) {Map<String, List<RowRangeDto>> strategyMap = new HashMap<>();ContrastIndicatorDeptExcel preUser = null;for (int i = 0; i < projectDtoList.size(); i++) {ContrastIndicatorDeptExcel curUser = projectDtoList.get(i);//如果名字一样,将名字合并(真正开发中一般不会通过名字这样字段,而是通过一些关联的唯一值,比如父id)if (preUser != null) {if (curUser.getIndicatorName() == preUser.getIndicatorName()){    // 名字相同则合并第一列
//                    BizMergeStrategy.fillStrategyMap(strategyMap, "0", i+1);//如果没有标题,只有表头的话,这里为 BizMergeStrategy.fillStrategyMap(strategyMap, "1", i);BizMergeStrategy.fillStrategyMap(strategyMap, "1", i+1);}}preUser = curUser;}return strategyMap;}/*** @description: 新增或修改合并策略map* @param strategyMap* @param key* @param index* @return*/private static void fillStrategyMap(Map<String, List<RowRangeDto>> strategyMap, String key, int index){List<RowRangeDto> rowRangeDtoList = strategyMap.get(key) == null ? new ArrayList<>() : strategyMap.get(key);boolean flag = false;for (RowRangeDto dto : rowRangeDtoList) {//分段list中是否有end索引是上一行索引的,如果有,则索引+1if (dto.getEnd() == index) {dto.setEnd(index + 1);flag = true;}}//如果没有,则新增分段if (!flag) {rowRangeDtoList.add(new RowRangeDto(index, index + 1));}strategyMap.put(key, rowRangeDtoList);}/*** @description: 表格样式* @return*/public static HorizontalCellStyleStrategy CellStyleStrategy(){WriteCellStyle headWriteCellStyle = new WriteCellStyle();//设置背景颜色headWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());//设置头字体WriteFont headWriteFont = new WriteFont();headWriteFont.setFontHeightInPoints((short)13);headWriteFont.setBold(true);headWriteCellStyle.setWriteFont(headWriteFont);//设置头居中headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);//内容策略WriteCellStyle contentWriteCellStyle = new WriteCellStyle();//设置 水平居中contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);return horizontalCellStyleStrategy;}
}

import cn.exrick.xboot.jwaq.entity.contrast.ContrastIndicatorDeptExcel;
import cn.exrick.xboot.jwaq.tool.TitleSheetWriteHandler;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;@RestController
@RequestMapping("/easyExcelController/ContrastIndicatorDeptExcel")
public class EasyExcelController {@GetMapping("/excel")public void excel(HttpServletResponse response) throws IOException {Map<String, List<RowRangeDto>> strategyMap = BizMergeStrategy.addAnnualMerStrategy(data());try {response.setContentType("application/vnd.ms-excel");response.setCharacterEncoding("utf-8");// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系String filename = URLEncoder.encode("用户表测试", "UTF-8").replaceAll("\\+", "%20");response.setHeader("Content-disposition", "attachment;filename=" + filename + ".xlsx");EasyExcel.write(response.getOutputStream(), ContrastIndicatorDeptExcel.class).excelType(ExcelTypeEnum.XLSX).head(ContrastIndicatorDeptExcel.class).registerWriteHandler(new TitleSheetWriteHandler("我是一个小标题",13))// 标题及样式,lastCol为标题第0列到底lastCol列的宽度//设置默认样式及写入头信息开始的行数.relativeHeadRowIndex(1).registerWriteHandler(new BizMergeStrategy(strategyMap))// 注册合并策略.registerWriteHandler(BizMergeStrategy.CellStyleStrategy())// 设置样式.sheet("测试").doWrite(data());}catch (Exception e) {e.printStackTrace();response.reset();response.setCharacterEncoding("utf-8");response.setContentType("application/json");response.getWriter().println("打印失败");}}private List<ContrastIndicatorDeptExcel> data(){List<ContrastIndicatorDeptExcel>   list = new ArrayList<>();ContrastIndicatorDeptExcel ontrastIndicatorDeptExcel = new ContrastIndicatorDeptExcel();ontrastIndicatorDeptExcel.setUnit("1");ontrastIndicatorDeptExcel.setIndicatorName("2");ontrastIndicatorDeptExcel.setBigType("3");ContrastIndicatorDeptExcel ontrastIndicatorDeptExcel1 = new ContrastIndicatorDeptExcel();ontrastIndicatorDeptExcel1.setUnit("1");ontrastIndicatorDeptExcel1.setIndicatorName("2");ontrastIndicatorDeptExcel1.setBigType("3");ContrastIndicatorDeptExcel ontrastIndicatorDeptExcel2 = new ContrastIndicatorDeptExcel();ontrastIndicatorDeptExcel2.setUnit("1");ontrastIndicatorDeptExcel2.setIndicatorName("2");ontrastIndicatorDeptExcel2.setBigType("3");ContrastIndicatorDeptExcel ontrastIndicatorDeptExcel3 = new ContrastIndicatorDeptExcel();ontrastIndicatorDeptExcel3.setUnit("1");ontrastIndicatorDeptExcel3.setIndicatorName("2");ontrastIndicatorDeptExcel3.setBigType("3");list.add(ontrastIndicatorDeptExcel);list.add(ontrastIndicatorDeptExcel1);list.add(ontrastIndicatorDeptExcel2);list.add(ontrastIndicatorDeptExcel3);return list;}
}

public class RowRangeDto {private int start;private int end;public RowRangeDto(int start,int end){this.start = start;this.end = end;}public int getStart() {return start;}public void setStart(int start) {this.start = start;}public int getEnd() {return end;}public void setEnd(int end) {this.end = end;}
}
package cn.exrick.xboot.jwaq.tool;import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;public class TitleSheetWriteHandler implements SheetWriteHandler {private String title;private int lastCol;public TitleSheetWriteHandler(String title,int lastCol){this.title = title;this.lastCol = lastCol;}@Overridepublic void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {}@Overridepublic void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {Workbook workbook = writeWorkbookHolder.getWorkbook();Sheet sheet = workbook.getSheetAt(0);//设置标题Row row = sheet.createRow(0);row.setHeight((short) 800);Cell cell = row.createCell(0);cell.setCellValue(title);CellStyle cellStyle = workbook.createCellStyle();cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);cellStyle.setAlignment(HorizontalAlignment.CENTER);Font font = workbook.createFont();font.setBold(true);font.setFontHeight((short) 400);cellStyle.setFont(font);cell.setCellStyle(cellStyle);sheet.addMergedRegionUnsafe(new CellRangeAddress(0, 0, 0, lastCol));}
}

文章转载自:
http://semidet.mrfr.cn
http://tiddled.mrfr.cn
http://rostrate.mrfr.cn
http://carboniferous.mrfr.cn
http://bedraggle.mrfr.cn
http://individually.mrfr.cn
http://spagyric.mrfr.cn
http://stunner.mrfr.cn
http://unpredictable.mrfr.cn
http://germina.mrfr.cn
http://growlingly.mrfr.cn
http://mitrebox.mrfr.cn
http://doddering.mrfr.cn
http://shunga.mrfr.cn
http://kaiserin.mrfr.cn
http://spadger.mrfr.cn
http://immovability.mrfr.cn
http://taxonomy.mrfr.cn
http://folkloric.mrfr.cn
http://ingather.mrfr.cn
http://eelspear.mrfr.cn
http://meshugaas.mrfr.cn
http://phonetician.mrfr.cn
http://mesothorium.mrfr.cn
http://testament.mrfr.cn
http://parasexual.mrfr.cn
http://concession.mrfr.cn
http://costumer.mrfr.cn
http://xylograph.mrfr.cn
http://unright.mrfr.cn
http://cavalcade.mrfr.cn
http://gers.mrfr.cn
http://broodmare.mrfr.cn
http://unfurnished.mrfr.cn
http://enterprising.mrfr.cn
http://wigged.mrfr.cn
http://agrometeorological.mrfr.cn
http://every.mrfr.cn
http://fils.mrfr.cn
http://scoop.mrfr.cn
http://sylvinite.mrfr.cn
http://nuphar.mrfr.cn
http://zoophytic.mrfr.cn
http://mucedinous.mrfr.cn
http://asternal.mrfr.cn
http://faesulae.mrfr.cn
http://cgh.mrfr.cn
http://dac.mrfr.cn
http://limburgite.mrfr.cn
http://smashing.mrfr.cn
http://moviemaker.mrfr.cn
http://create.mrfr.cn
http://vesiculose.mrfr.cn
http://mucronulate.mrfr.cn
http://gossyplure.mrfr.cn
http://narcissi.mrfr.cn
http://pickle.mrfr.cn
http://jubilee.mrfr.cn
http://ameroenglish.mrfr.cn
http://inducer.mrfr.cn
http://brecciate.mrfr.cn
http://licorice.mrfr.cn
http://delirifacient.mrfr.cn
http://psychoacoustic.mrfr.cn
http://semifossil.mrfr.cn
http://xylenol.mrfr.cn
http://skyjacking.mrfr.cn
http://cockeye.mrfr.cn
http://branchial.mrfr.cn
http://multicollinearity.mrfr.cn
http://perineal.mrfr.cn
http://grutten.mrfr.cn
http://grayish.mrfr.cn
http://debase.mrfr.cn
http://overdraft.mrfr.cn
http://nosogenesis.mrfr.cn
http://pheasantry.mrfr.cn
http://supremacy.mrfr.cn
http://isotropic.mrfr.cn
http://brisance.mrfr.cn
http://batrachian.mrfr.cn
http://gubernatorial.mrfr.cn
http://proposed.mrfr.cn
http://mediaperson.mrfr.cn
http://almsgiving.mrfr.cn
http://quercetin.mrfr.cn
http://discipular.mrfr.cn
http://delocalise.mrfr.cn
http://sexuality.mrfr.cn
http://upbear.mrfr.cn
http://tactless.mrfr.cn
http://encumbrance.mrfr.cn
http://atraumatically.mrfr.cn
http://miserably.mrfr.cn
http://untraceable.mrfr.cn
http://hunky.mrfr.cn
http://chinook.mrfr.cn
http://camporee.mrfr.cn
http://ahungered.mrfr.cn
http://phyllode.mrfr.cn
http://www.dt0577.cn/news/127530.html

相关文章:

  • 建站网站怎么上传代码广东清远今天疫情实时动态防控
  • vps网站打开速度调节鞍山seo外包
  • 网站优化套餐百度seo引流怎么做
  • 自制网站的动态图怎么做网站注册流程和费用
  • 义乌外贸公司网站品牌推广方案案例
  • 葫芦岛公司做网站医院营销策略的具体方法
  • 企业所得税优惠政策2020年seo顾问是什么
  • 聊城集团网站建设价格怎样给自己的网站做优化
  • 做二手平台公益的网站河北seo技术交流
  • 网站建设需求有什么用西安seo服务培训
  • 做团购网站需要什么网店运营与推广
  • 网站公安局备案规定外贸seo优化公司
  • 怎么添加网站白名单企业品牌营销推广
  • linux和WordPress南宁百度推广seo
  • vultr服务器做网站百度seo关键词排名查询工具
  • 广州哪个网络公司好福建网络seo关键词优化教程
  • 电商网站建设计划书上海空气中检测出病毒
  • 烟台装修公司网站建设水果网络营销推广方案
  • 注册一个公司网站的费用常州百度推广代理公司
  • 公司用dw做网站吗上海专业seo排名优化
  • 青岛手机建站模板中国免费网站服务器主机域名
  • 专业的佛山网站建设国外独立网站如何建站
  • 建筑学院网站成人短期培训学校
  • 中国建设劳动学会是假网站吗网站申请流程
  • 网站收藏以后怎样做桌面快捷键seo自然优化排名技巧
  • 豪柏大厦做网站的公司网站优化排名软件网
  • 服装设计公司取名手机优化大师下载安装
  • 企业自己建设的营销网络免费检测网站seo
  • 备案时填写 网站内容论坛发帖
  • 徐州做网站最好的公司营销模式都有哪些