4

rooや Spreadsheet など、Microsoft Excelファイルを読み取るための Ruby オープンソース ライブラリがいくつかあります。Apple Numbers ドキュメントはどうですか? 利用可能なものはありますか?

4

1 に答える 1

3

そのようなライブラリは明らかに存在しません (まだ?)。現時点での適切な回避策は、AppleScript を使用して CSV への変換を自動化し、Numbers ファイルを直接読み取る代わりに、この結果を読み取ることです。ただし、これはすべての人のニーズに合わないかもしれませんが、私にとっては完璧に機能します。

アップルスクリプトは次のとおりです。

# -------------------------------------------------------------------------------
# Command-line tool to convert an iWork '09 Numbers
# document to CSV.
#
# Parameters:
# - input: Numbers input file
# - output: CSV output file
#
# Attik System, Philippe Lang
#
# Creation date: 31 mai 2012
# Modification date: 
# -------------------------------------------------------------------------------
on run argv
    # We retreive the path of the script
    set myPath to (path to me)
    tell application "Finder" to set myFolder to folder of myPath

    # We get the command line parameters
    set input_file to item 1 of argv
    set output_file to item 2 of argv

    # We retreive the extension of the file
    set theInfo to (info for (input_file))
    set extname to name extension of (theInfo)

    # Paths
    set input_file_path to (myFolder as text) & input_file
    set output_file_path to (myFolder as text) & output_file

    if extname is equal to "numbers" then
        tell application "Numbers"
            open input_file_path
            save document 1 as "LSDocumentTypeCSV" in output_file_path
            close every window saving no
        end tell
    end if
end run

次のように使用します。

osascript convert_to_csv.scpt input_file.numbers output_file.csv
于 2012-06-01T06:16:24.453 に答える