V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
supuwoerc
V2EX  ›  问与答

前端大佬们请进~。~

  •  
  •   supuwoerc · 2021-03-12 16:20:29 +08:00 · 972 次点击
    这是一个创建于 1134 天前的主题,其中的信息可能已经有所发展或是发生改变。

    请教大家两个问题:

    • 1.最近的一个导出 Excel 需求,找了一些诸如 xlsx 和 xlsx-style 的插件,但是不太适用我的场景,直接将 dom 转为 excel 倒是行得通,但是缺少了表格上的背景色,文字居中,换行的样式,不知道有没有大佬有思路或者能实现的方法。

    ps:表格全部是动态数据。

    • 2.Element-ui 下递归创建多级表头,如何使用插槽渲染?貌似实现不了? 具体代码如下,想要动态的渲染表格内容,但是自己封装了之后就没法使用官方的插槽了,十分苦恼。
    <template>
    <el-table-column :prop="'persons_'+cols.remark" :label="cols.title" :width="cols.width?cols.width:150" align="center">
        <template v-if="cols.children">
            <loop-column v-for="(item, index) in cols.children" :key="index" :cols="item">
            </loop-column>
        </template>
    </el-table-column>
    </template>
    <script>
    export default {
        name: "loopColumn",
        props: {
            cols: {
                type: Object,
                default: () => {
                    return {}
                }
            }
    
        }
    }
    <script>
    
    6 条回复    2021-03-15 19:31:27 +08:00
    murmur
        1
    murmur  
       2021-03-12 16:35:49 +08:00   ❤️ 1
    excel 导出都是手写样式,一个单元格一个调,dom 转 excel 玩具都不算

    我们是买了第三方报表工具实现的这个功能
    toesbieya
        2
    toesbieya  
       2021-03-12 16:42:32 +08:00   ❤️ 1
    1. [exceljs]( https://github.com/exceljs/exceljs)

    2. render
    putaozhenhaochi
        3
    putaozhenhaochi  
       2021-03-12 16:48:57 +08:00   ❤️ 1
    推给后端 /逃
    supuwoerc
        4
    supuwoerc  
    OP
       2021-03-12 16:56:27 +08:00
    @toesbieya 感谢! 太长时间没有 render,都快忘记还能这样了,一直在钻用插槽的牛角尖~~
    supuwoerc
        5
    supuwoerc  
    OP
       2021-03-12 18:22:55 +08:00
    @toesbieya
    大佬你好,请问 render 具体咋实现呢?我自己实现了一下,报错了。 =。=||
    之前没太使用过这种场景,如果方便的话能回答下嘛? =。=||
    supuwoerc
        6
    supuwoerc  
    OP
       2021-03-15 19:31:27 +08:00
    @toesbieya 打扰了,小弟今天重新读了 render 相关的文档,问题已经解决了! 十分感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2719 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:31 · PVG 13:31 · LAX 22:31 · JFK 01:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.