EasyExcel实现动态表头导出

实体类展示

@Data
@AllArgsConstructor
@NoArgsConstructor
public class GodownEntryCopyPage {
    /**
     * 客户名称
     */
    @ExcelProperty("")
    private String customName;

    /**
     * 产品型号
     */
    @ExcelProperty("")
    private String productModel;
    /**
     * 产品规格
     */
    @ExcelProperty("")
    private String productSpecifications;
    /**
     * 数量
     */
    @ExcelProperty("")
    private Double qty;

    @ExcelProperty("")
    private String particulars;

    /**
     * 颜色
     */
    @ExcelProperty("")
    private String color;

    /**
     * 盘数
     */
    @ExcelProperty("")
    private Double qtyOfDisks;


    /**
     * 盘形
     */
    @ExcelProperty("")
    private String disk;


    @ExcelProperty("")
    private String remark;

    @ExcelProperty("")
    private String groupLabel;

    /**
     * 材料
     */
    @ExcelProperty("")
    private String material;
    /**
     * 批次编号
     */
    @ExcelProperty("")
    private String batchInformation;
    /**
     * 加工类型
     */
    @ExcelProperty("")
    private String processingType;
    /**
     * 客户送货单号
     */
    @ExcelProperty("")
    private String deliveryNumber;

    /**
     * 外径
     */
    @ExcelProperty("")
    private String od;
    /**
     * 接头
     */
    @ExcelProperty("")
    private String splice;

    @ExcelProperty("")
    private String oneValue;

    @ExcelProperty("")
    private String twoValue;

    @ExcelProperty("")
    private String threeValue;

    @ExcelProperty("")
    private String fourValue;

    @ExcelProperty("")
    private String fiveValue;

    @ExcelProperty("")
    private String sixValue;

    @ExcelProperty("")
    private String sevenValue;

    @ExcelProperty("")
    private String eightValue;

    @ExcelProperty("")
    private String nineValue;

    @ExcelProperty("")
    private String tenValue;
}

业务层
public void download(HttpServletResponse response,HttpServletRequest request) throws IOException {
    // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
    response.setContentType("application/vnd.ms-excel");
    response.setCharacterEncoding("utf-8");
    // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
    String fileName = URLEncoder.encode("测试", "UTF-8");
    response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
    EasyExcel.write(response.getOutputStream(), GodownEntryCopyPage.class).head(dealWithHeads()).sheet("入库单").doWrite(data(request));
}


public List<List<String>> dealWithHeads() {
 
    List<List<String>> listParent = new ArrayList<>();
    CusInfoMaintainCopyDO cusInfoMaintainCopyDOS =cusInfoMaintainCopyMapper.selectListPage();
    listParent.add(Arrays.asList("客户名称(必填)","产品型号(必填)","产品规格(必填)","数量(必填)",
            "明细","颜色","盘数(必填)","盘形(必填)","备注","分组标签","材料(必填)","批次编号","加工类型","客户送货单号",
            "外径","接头",
         cusInfoMaintainCopyDOS.getKeyOne(),cusInfoMaintainCopyDOS.getKeyTwo(),cusInfoMaintainCopyDOS.getKeyThree(),cusInfoMaintainCopyDOS.getKeyFour(),cusInfoMaintainCopyDOS.getKeyFive(),
            cusInfoMaintainCopyDOS.getKeySix(),cusInfoMaintainCopyDOS.getKeySeven(),cusInfoMaintainCopyDOS.getKeyEight(),cusInfoMaintainCopyDOS.getKeyNine(),cusInfoMaintainCopyDOS.getKeyTen()));

    return xzHeadFields(listParent);
}

private List<GodownEntryCopyPage> data(HttpServletRequest request) {
    // 过滤选中数据
    String selections = request.getParameter("selections");
    List<GodownEntryCopyDO> GodownEntryDOList=new ArrayList<>();
    List<String> selectionList = Arrays.asList(selections.split(","));
    for (String s:selectionList){
        GodownEntryCopyDO godownEntryDO = godownEntryCopyMapper.GordonById(s);
        GodownEntryDOList.add(godownEntryDO);
    }

    List<GodownEntryCopyPage> pageList = new ArrayList<>();
    for (GodownEntryCopyDO card : GodownEntryDOList) {
        if (card!=null) {
            GodownEntryCopyPage vo = new GodownEntryCopyPage();
            BeanUtils.copyProperties(card, vo);
            List<InWarehouseCopyDO> InWarehouseDOs = godownEntryCopyMapper.getSonByParentId(card.getId());
            for (InWarehouseCopyDO inWarehouseDO:InWarehouseDOs){
                vo.setOneValue(inWarehouseDO.getOneValue());
                vo.setTwoValue(inWarehouseDO.getTwoValue());
                vo.setThreeValue(inWarehouseDO.getThreeValue());
                vo.setFourValue(inWarehouseDO.getFourValue());
                vo.setFiveValue(inWarehouseDO.getFiveValue());
                vo.setSixValue(inWarehouseDO.getSixValue());
                vo.setSevenValue(inWarehouseDO.getSevenValue());
                vo.setEightValue(inWarehouseDO.getEightValue());
                vo.setNineValue(inWarehouseDO.getNineValue());
                vo.setTenValue(inWarehouseDO.getTenValue());
            }
            pageList.add(vo);
        }
    }
    return pageList;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
three.js 是一个用于创建 3D 图形的 JavaScript 库,而 Vue 是一个流行的 JavaScript 框架。将这两个技术结合起来,可以构建出具有交互性和视觉效果的 3D 网页应用程序。 以下是一个使用 three.js 和 Vue.js 开发的简单示例: 1. 首先,安装 three.js 和 Vue.js: ``` npm install three vue ``` 2. 在 Vue 组件中引入 three.js: ```javascript import * as THREE from 'three' ``` 3. 在 Vue 组件中创建场景、相机和渲染器: ```javascript export default { data () { return { scene: null, camera: null, renderer: null } }, mounted () { this.init() }, methods: { init () { // 创建场景 this.scene = new THREE.Scene() // 创建相机 this.camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 1000 ) this.camera.position.z = 5 // 创建渲染器 this.renderer = new THREE.WebGLRenderer({ antialias: true }) this.renderer.setSize(window.innerWidth, window.innerHeight) this.renderer.setClearColor('#000000') // 将渲染器添加到页面中 this.$el.appendChild(this.renderer.domElement) // 开始渲染场景 this.renderScene() }, renderScene () { this.renderer.render(this.scene, this.camera) requestAnimationFrame(this.renderScene) } } } ``` 4. 在场景中添加物体: ```javascript const geometry = new THREE.BoxGeometry(1, 1, 1) const material = new THREE.MeshBasicMaterial({ color: '#ffffff' }) const cube = new THREE.Mesh(geometry, material) this.scene.add(cube) ``` 5. 实现交互: ```javascript this.$el.addEventListener('mousemove', event => { const mouseX = (event.clientX / window.innerWidth) * 2 - 1 const mouseY = -(event.clientY / window.innerHeight) * 2 + 1 this.camera.position.x = mouseX * 10 this.camera.position.y = mouseY * 10 this.camera.lookAt(this.scene.position) }) ``` 通过以上步骤,我们就可以创建一个简单的 three.js + Vue.js 项目了。当然,这只是一个示例,您可以根据自己的需求和要求进行更复杂的开发。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值