从使用AppleScript Excel中保存清洁CSV文件 [英] Save Clean CSV file from Excel using Applescript
问题描述
我需要从Web下载一个Excel US preadsheet,使用Excel的Mac 2008中打开它,将其保存为csv文件,然后使用PHP解析它的过程。手工工艺工作正常,并保存一个干净的CSV文件。我想自动使用AppleScript这一部分,它的排序工作,但是,CSV文件生成,包含了一些怪异的人物。
I have a process that requires downloading an Excel Spreadsheet from the Web, opening it using Excel Mac 2008, saving it as a csv file, and then parsing it using php. The manual process works fine and saves a clean CSV file. I am trying to automate this part using Applescript, and it sort of works, however, the CSV file generated contains a bunch of weird characters.
这里是我工作的AppleScript的:
Here is the Applescript I am working on:
tell application id "com.microsoft.Excel" to open "~/Documents/input.xls"
tell application id "com.microsoft.Excel" to tell active sheet to save in ("output.csv") as "CSV file format"
我曾尝试过各种CSV选项(在Mac,Windows,MSDOS),他们不会产生不同的结果。
I have tried various CSV options (Mac, Windows, MSDos) and they do not produce substantially different results.
推荐答案
试试这个...
set theDoc to (path to desktop as text) & "test.xlsx"
set outPath to (path to desktop as text) & "test.csv"
tell application "Microsoft Excel"
open file theDoc
tell workbook 1
tell sheet 1
save in outPath as CSV file format
end tell
close without saving
end tell
end tell
这篇关于从使用AppleScript Excel中保存清洁CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!