【问题标题】:Open link on file excel on Browser by code JavaScripts通过代码 JavaScript 在浏览器上打开文件 excel 上的链接
【发布时间】:2023-02-17 17:28:02
【问题描述】:

我有文件 excel 100 链接,我想在浏览器上打开链接。

我的代码:

const ExcelJS = require('exceljs');
const open = require('open');

const workbook = new ExcelJS.Workbook();
const filePath = 'D:\\3.py\\link1.xlsx';

workbook.xlsx.readFile(filePath)
    .then(() => {
    const worksheet = workbook.getWorksheet('Sheet1');
    const links = worksheet.getColumn('B').values;

    links.forEach(link => {
        open(link, { target: '_blank' });
    });
  });

但是错误: TypeError:需要一个target 在打开 (D:\3.py\node_modules\open\index.js:229:9)

你能帮助我吗?谢谢!

【问题讨论】:

    标签: javascript excel


    【解决方案1】:

    只需替换代码

    open(link.hyperlink, { target: '_blank' });
    

    用它

    【讨论】:

      猜你喜欢
      • 2020-08-22
      • 2020-01-30
      • 2014-12-09
      • 2014-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-06
      相关资源
      最近更新 更多