我有一个const Excel = require('exceljs');
async function copyExcel() {
let targetWorkbook = new Excel.Workbook();
targetWorkbook = await targetWorkbook.xlsx.readFile('target.xlsx');
const targetWorksheet = targetWorkbook.getWorksheet('target'); // you can add new sheet as well.
let sourceWorkbook = new Excel.Workbook();
sourceWorkbook = await sourceWorkbook.xlsx.readFile('source.xlsx');
const sourceWorksheet = sourceWorkbook.getWorksheet('source');
sourceWorksheet.eachRow({ includeEmpty: false }, (row, rowNumber) => {
var targetRow = targetWorksheet.getRow(rowNumber);
row.eachCell({ includeEmpty: false }, (cell, cellNumber) => {
targetRow.getCell(cellNumber).value = cell.value;
});
row.commit();
});
await targetWorkbook.xlsx.writeFile('target.xlsx');
}
copyExcel();
食谱,该食谱使用称为java/recipes/windows
的方法,但由于win_friendly_path
尚未定义,因此无法使用。
win_friendly_path
中, win_friendly_path
的定义如下:
../windows/libraries/windows_helper.rb
我已经在module Windows
module Helper
def win_friendly_path(path)
path.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\\') if path
end
食谱中设置了berksfile
和metadata.rb
,以取决于java (./)
食谱。
我不确定如何包含此模块,所以现在我正试图在windows
食谱中使用include WindowsHelper
并收到此错误:
java/cookbook/windows
我尝试了几种方法,现在觉得我花了太多时间对问题进行故障排除,因此能获得任何帮助。
更新:将此行uninitialized constant #<Class:#<Chef::Recipe:0x00000000029a2188>>::WindowsHelper
插入我的::Chef::Resource.send(:include, Windows::Helper)
食谱会给我以下错误:
java/recipes/windows
答案 0 :(得分:1)
尝试一下
include Windows::Helper
答案 1 :(得分:-1)
插入以下行为我解决了此问题:
::Chef::Recipe.send(:include, Windows::Helper)
这使我可以使用Windows食谱中以下模块中的变量:
module Windows
module Helper
...
{Variable}
{Other_variable}
...