You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AppleScript读取Excel货币格式单元格带符号文本导入InDesign

解决方法

问题原因

你当前脚本调用的是Excel单元格的value属性,该属性仅返回单元格存储的原始数值,不会携带任何格式配置,因此货币符号、固定小数位等展示信息都会被丢弃。

修复方案

将读取单元格范围的属性从value替换为string value即可,该属性会返回Excel界面上实际展示的完整格式化文本,包含不同货币符号、小数位数等格式内容。

修改后的完整脚本

tell application "Microsoft Excel"
   open file "excelFilePath"
   set theWorkbook to active workbook
   set theSheet to sheet 1 of theWorkbook
   -- 核心修改:将value替换为string value,读取带格式的显示文本
   set theMatrix to string value of used range of theSheet
   set theRowCount to count theMatrix
   set str to ""
   set oldDelimiters to AppleScript's text item delimiters
   repeat with countRows from 1 to theRowCount
       set theRow to item countRows of theMatrix
       set AppleScript's text item delimiters to ","
       set str to str & (theRow as string) & "|"
   end repeat
   set AppleScript's text item delimiters to oldDelimiters
   close theWorkbook saving no
end tell
tell application id "com.adobe.InDesign"
   tell script args
       set value name "excelData" value str
   end tell
end tell

补充说明

  • 如果你需要部分列保留原始数值、部分列取格式化文本,可以按列分别读取属性,比如数量列读取value、价格列读取string value,适配更灵活的场景
  • 脚本中原本的分隔符是;,已按照你期望的输出改成了,,如果需要自定义分隔符可以自行调整AppleScript's text item delimiters的取值

内容的提问来源于stack exchange,提问作者ts_antares

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.03 17:06:04