小编dea*_*ght的帖子

将 Bootstrap 表导出到 Excel 或 pdf

我正在使用 bootstrap vue table,并且我想将 bootstrap table 导出到 excel 或 pdf。它就像表中的表,我发现如何导出它以供下载为 excel 或 pdf 很困难,因为我遇到的其他解决方案都只涉及提供 json 数据,它可以工作,但不能'找不到关于我的问题的任何解决方案。

Codesandbox演示

<template>
  <div id="app">
    <b-button @click="exportTable" class="mb-3">Export</b-button>
    <b-table-simple outlined id="htmltable">
      <b-thead class="b-table__head">
        <b-tr>
          <b-th class="small-tab">Goods</b-th>
          <b-th>Units</b-th>
          <b-th>Price Per Unit</b-th>
          <b-th>Total Price</b-th>
        </b-tr>
      </b-thead>
      <b-tbody v-for="(service, index) in goodsGroupedByCategory" :key="index">
        <b-tr class="category-line">
          <b-th class="small-tab cs-textstyle-paragraph-small-bold">{{
            index
          }}</b-th>
          <b-td></b-td>
          <b-td></b-td>
          <b-th class="cs-textstyle-paragraph-small-bold">{{
            service.reduce(function (prev, curr) {
              return prev + curr.total_units * curr.price_per_unit;
            }, 0)
          }}</b-th>
        </b-tr>
        <b-tr
          v-for="serviceItem in service"
          :key="serviceItem.id"
          class="item-line"
        >
          <b-td class="big-tab cs-textstyle-paragraph-small">{{ …
Run Code Online (Sandbox Code Playgroud)

vue.js vuejs2 bootstrap-vue

5
推荐指数
1
解决办法
7445
查看次数

标签 统计

bootstrap-vue ×1

vue.js ×1

vuejs2 ×1