【问题标题】:Nodejs compare two different excel files and spot their differenceNodejs比较两个不同的excel文件并发现它们的区别
【发布时间】:2014-12-15 12:13:23
【问题描述】:

这是我的第一个问题。如果我错了,请纠正我。我是nodejs新蜜蜂。我正在尝试通过 nodejs 比较两个 excel 文件。我使用 excel-compare 模块来比较两个 excel 文件(确实有多个工作表)。但它的抛出类型错误。这是我的代码

var excel_compare = require("excel-compare");
excel_compare({
    file1: 'data/school.xlsx', // file1 is the main excel to compare with
    file2: 'data/all.xlsx', // file2 is the file for compare
    column_file1: {
        column: [1],
        join: ''
    },
    column_file2: {
        column: [2],
        join: '-'
    }
})

当我运行上面的代码时,我得到以下错误

TypeError: Cannot read property 'value' of undefined
    at E:\node_modules\npm\node_modules\excel-compare\index.js:17:35
    at Array.forEach (native)
    at Function._.each._.forEach (E:\node_modules\npm\node_modules\excel-compare
\node_modules\underscore\underscore.js:79:11)
    at E:\node_modules\npm\node_modules\excel-compare\index.js:15:5
    at Function._.each._.forEach (E:\node_modules\npm\node_modules\excel-compare
\node_modules\underscore\underscore.js:82:22)
    at module.exports (E:\node_modules\npm\node_modules\excel-compare\index.js:1
3:4)
    at Object.handle (E:\node_modules\npm\Excel\excelread.js:39:2)
    at next_layer (E:\node_modules\npm\node_modules\express\lib\router\route.js:
103:13)
    at Route.dispatch (E:\node_modules\npm\node_modules\express\lib\router\route
.js:107:5)
    at E:\node_modules\npm\node_modules\express\lib\router\index.js:213:24

谁能帮我解决这个问题?

【问题讨论】:

    标签: javascript node.js excel typeerror


    【解决方案1】:

    查看excel-compare Github page 上的示例,您似乎没有正确指定列。尝试使用数值。我认为您无法在不对源代码进行一些更改的情况下比较两个工作表。

    希望这会有所帮助。

    【讨论】:

    • 当我尝试使用数值时,出现以下错误 TypeError: Cannot read property '1' of undefined.
    • @user3708542:确保您使用的是数值而不是字符串值:column: [1] 而不是 column: ['1']
    • 以正确的方式尝试,我的意思是列:[1] @sholanozie
    • @user3708542:这很奇怪。 data/school.xslxdata/all.xslx 文件是否存在于您的计算机上?很抱歉这个明显的问题!
    • 哈哈它存在@sholanozie
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    • 2016-11-13
    • 2021-11-20
    • 1970-01-01
    • 2019-12-25
    相关资源
    最近更新 更多