V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
supuwoerc
V2EX  ›  问与答

前端大佬们请进~。~

  •  
  •   supuwoerc · Mar 12, 2021 · 1402 views
    This topic created in 1882 days ago, the information mentioned may be changed or developed.

    请教大家两个问题:

    • 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 replies    2021-03-15 19:31:27 +08:00
    murmur
        1
    murmur  
       Mar 12, 2021   ❤️ 1
    excel 导出都是手写样式,一个单元格一个调,dom 转 excel 玩具都不算

    我们是买了第三方报表工具实现的这个功能
    toesbieya
        2
    toesbieya  
       Mar 12, 2021   ❤️ 1
    1. [exceljs]( https://github.com/exceljs/exceljs)

    2. render
    putaozhenhaochi
        3
    putaozhenhaochi  
       Mar 12, 2021   ❤️ 1
    推给后端 /逃
    supuwoerc
        4
    supuwoerc  
    OP
       Mar 12, 2021
    @toesbieya 感谢! 太长时间没有 render,都快忘记还能这样了,一直在钻用插槽的牛角尖~~
    supuwoerc
        5
    supuwoerc  
    OP
       Mar 12, 2021
    @toesbieya
    大佬你好,请问 render 具体咋实现呢?我自己实现了一下,报错了。 =。=||
    之前没太使用过这种场景,如果方便的话能回答下嘛? =。=||
    supuwoerc
        6
    supuwoerc  
    OP
       Mar 15, 2021
    @toesbieya 打扰了,小弟今天重新读了 render 相关的文档,问题已经解决了! 十分感谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   972 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 19:13 · PVG 03:13 · LAX 12:13 · JFK 15:13
    ♥ Do have faith in what you're doing.