excel - 带有Applescript的Excel货币字符串值
问题描述
这是我的情况:我有一个 InDesign 文件,需要读取一个包含项目描述、数量和价格的 Excel 电子表格。描述是文本,数量是数字,价格是货币。我将从世界各地获取这些文件,因此价格列采用具有各种货币符号的货币格式。
我能够找到一个 Applescript,它将整个工作表转换为一个文本数组以供 InDesign 读取,但价格单元格只给了我值,而不是格式化的值。
所以当我的行看起来像这样时:
Item A | 4 | 3.00 €
Item B | 7 | $4.50
...
我运行这个脚本:
tell application "Microsoft Excel"
open file "excelFilePath"
set theWorkbook to active workbook
set theSheet to sheet 1 of theWorkbook
set theMatrix to 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
然后我得到这个:
Item A,4,3,
Item B,7,4.5,
...
但我需要这个:
Item A,4,3.00 €,
Item B,7,$4.50,
...
如何获取货币的字符串值?
解决方案
您需要使用字符串 value而不仅仅是value。
set theMatrix to string value of used range of theSheet
干杯! Funtom
推荐阅读
- sql-server - 如何在 SQL Server 2017 中循环将多个表导出到平面文件 (csv)?
- jquery - Jquery如何只找到第一次出现
- c# - 在正则表达式替换中投射 1 美元
- ios - 性能方面,这是对类、结构、枚举等进行分组的更好方法
- apache - 与 Atlas HiveMetastoreBridge 代码相关的几个问题
- python - 获取一个基类的所有子类作为基类的类属性
- github - Travis CI 修改同一分支
- scala - 比较两个数据框中列的值
- c# - 如何将数据从 List 导出到具有不同 CSV 格式的 CSV 文件
- java - Java - 如果条件检查整数数组列表是否包含大于特定值的元素