プラグインフォルダへのインポート用データファイルの追加について

背景・実現したいこと

 帳票のレイアウトが書かれているExcelファイルに対して、レコードの詳細情報を書きこむという処理をプラグインにて行いたいです。プラグインのsrcフォルダ配下に「excel」というフォルダを用意して、その中にExcelファイルを置いたのですが、パッケージング後にフォルダごと消失してしまいました。

エラー情報 (開発者ツールのコンソール)

Uncaught Error: Cannot access file test.xlsx

利用したソースコード

jQuery.noConflict();

(function($, PLUGIN_ID) {
  'use strict';
  
  kintone.events.on('app.record.detail.show', function() {
    // メニューの上側の空白部分にボタンを設置
    const myIndexButton = document.createElement('button');
    myIndexButton.id = 'excel_button';
    myIndexButton.innerText = '帳票出力';
    myIndexButton.onclick = () => {
      // テスト:excelファイル読取
      const book = XLSX.readFile("../excel/test.xlsx");
      const cell = '';
      if(book) {
        const sheet = book.Sheets["Sheet1"];
        if(sheet) {
          cell = sheet['A1'];
        }
      }
      // レコードのIDを取得
      let customerName = '';
      const recordData = kintone.app.record.get();
      if(recordData) {
        customerName = recordData.record.customer_name.value;
      }
      var ws = XLSX.utils.json_to_sheet([{h1: customerName, h2: 'test3'}, {h2: customerName, h3: 'test4'}], {header: ['h1','h2','h3']});
      var ws2 = XLSX.utils.json_to_sheet([{h2: 'test1', h3: 'test2'}, {h1: 'test3', h2: 'test4'}], {header: ['h1','h2','h3']});
      var wb = XLSX.utils.book_new();
      XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
      XLSX.utils.book_append_sheet(wb, ws2, 'Sheet2');
      XLSX.writeFile(wb, "test.xlsx");
    };
    kintone.app.record.getHeaderMenuSpaceElement().appendChild(myIndexButton);
  });
})(jQuery, kintone.$PLUGIN_ID);

webpackとかでバンドルしようとしていたんでしょうか?
プラグインのフォルダは以下の構成なので。。。excelファイルはたぶん無理かと。。。

https://cybozudev.zendesk.com/hc/ja/articles/203455680

プラグインにエクセルを埋め込むとしたら、Base64化してコードに埋め込むとか?

 

このトピックはベストアンサーに選ばれた返信から 3 日が経過したので自動的にクローズされました。新たに返信することはできません。