gpt4 book ai didi

javascript - ExtendScript 中的 For 循环 -keys().forEach 不是函数

转载 作者:行者123 更新时间:2023-11-28 18:28:58 25 4
gpt4 key购买 nike

我正在使用带有桥的 ExtendScript 将标签附加到 Excel 文档中的文档。我正在使用 js-xlsx 库解析 Excel 文档。我正在运行一个 for 循环来解析各个单元格并获取值,当我从命令行运行它时,它可以完美地工作。但是,当我在 ExtendScript 中运行它时,我收到一个异常,即 keys().forEach 不是函数。出于某种原因,ExtendScript 读取 for 循环的方式是否不同?我很难弄清楚这一点。这是给我带来麻烦的一行:

var range = {s:{c:0, r:0}, e:{c:1,r:30}};
for (var R = range.s.r; R <= range.e.r; ++R) {
for (var C = range.s.c; C <= range.e.c; ++C) {
var cell_address = xls.utils.encode_cell({c:C, r:R});

最佳答案

Extendscript 作为一种语言,停留在 ECMAScript 3 上 - 因此它本身并不了解 Object.keys(),也不了解 Array.forEach()。甚至不是 JSON

官方对此的提及可以在After Effects scripting guide中找到第 3 页,其中写着:

After Effects scripts use the Adobe ExtendScript language, which is an extended form of JavaScript used by several Adobe applications, including Photoshop, Illustrator, and InDesign. ExtendScript implements the JavaScript language according to the ECMA-262 specification. The After Effects scripting engine supports the 3rd Edition of the ECMA-262 Standard, including its notational and lexical conventions, types, objects, expressions, and statements. ExtendScript also implements the E4X ECMA-357 specification, which defines access to data in XML format.

以上内容在PS脚本指南中没有找到,也没有引用。

如果您想使用 ES5 功能,请包含垫片,或者给出 extendscriptr尝试一下。 Extendscriptr 是一个脚本社区项目(没有 Adob​​e 参与),它可以让您编写 ES5/ES6 代码,然后将其转换为 ES3。

关于javascript - ExtendScript 中的 For 循环 -keys().forEach 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38508213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com