jsreport html-到-excel 选项

jsreport html-to-excel options

我正在使用 excellent jsreport 解决方案,使用 'html-to-excel' 配方将 html 转换为 excel。
此食谱是否有任何选项来控制工作sheet 选项?
比如从右到左显示 sheet,设置 sheet 的名称,显示网格线等

  1. html-to-excel配方使用html-to-xlsx under the hood. According to the document,如果要显示网格线,可以使用css样式控制网格线:
    td {
        border-style: solid;
    }

您也可以使用 text-align。但是只支持很少的功能。

  1. 默认 html-to-xlsx (legacy) 不支持自定义 sheet 名称。然而,如果你查看 unit test,你会发现有更好的 html-to-better-xlsx:
      template: {
        content: `
        <table name="Data">
          <tr>
              <td data-cell-type="number">1</td>
          </tr>
        </table>
        `,
        recipe: 'html-to-better-xlsx',
        engine: 'none',
        baseXlsxTemplate: {
          content: xlsxTemplateBuf.toString('base64')
        },
        htmlToXlsx: {
          insertToXlsxTemplate: true
        }
      }

这意味着将 [name] 属性添加到 table 并将配方设置为 html-to-better-xlsx 应该可行。

  1. Xlsx recipe allows us to control over the Excel completely. For example, to custom the sheet name, see https://playground.jsreport.net/w/anon/BJa5OBWD-2
{{#xlsxMerge "xl/workbook.xml" "workbook.sheets[0].sheet[0]"}}
   <sheet name="My Sheet Name"/>
{{/xlsxMerge}}

{{{xlsxPrint}}}