Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/tomiacannondale/wrap_excel

WrapExcel is a wrapper library that specializes in the operation of Excel win32ole.
https://github.com/tomiacannondale/wrap_excel

Last synced: 3 months ago
JSON representation

WrapExcel is a wrapper library that specializes in the operation of Excel win32ole.

Lists

README

        

= WrapExcel

== 概要

WrapExcelはwin32oleをラップし、rubyによるExcelオペレーションを簡単にします。

== 必要なもの

* ruby 1.9.2以上 (プラットフォームはwindowsです)

== インストール

gem install wrap_excel

== 使い方
=== bookへのアクセス

ブロックを使用する場合

WrapExcel::Book.open('./sample.xls') do |book|
# do something
end

ブロックを使用しない場合

book = WrapExcel::Book.open('./sample.xls')
book.close

オプションは以下の通りです。

[read_only] boolean(default true)
[displayalerts] boolean(default false)
[visible] boolean(default false)

=== sheetへのアクセス

sheetオブジェクトへは Book#[] メソッドでアクセス出来ます。

sheet = book[0]

シート名でのアクセス

book['Sheet1']

=== 行または列へのアクセス

sheetオブジェクトはenumerableをインクルードしています。Sheet#each_column or Sheet#each_row or Sheet#each メソッドが使用できます。

sheet.each do |cell|
# do something with cell
# read every row every column
end

sheet.each_row do |row|
# do something with row_range
end

sheet.each_column do |column_range|
# do something with column_range
end

=== セルへのアクセス

sheetオブジェクトからのアクセス。

sheet[0, 0] => first cell.

rangeオブジェクトからのアクセス。

row_range[0] => first cell in row_range
column_range[1] => second cell in column_range

=== ファイルの保存

既存のファイルは保存可能です。

WrapExcel::Book.open('./sample.xls', :read_only => false) do |book|
# do something
book.save
end

もしくは

book = WrapExcel::Book.open('./sample.xls', :read_only => false)
book.save
book.close

別のファイル名を保存することができます。

WrapExcel::Book.open('./sample.xls', :read_only => false) do |book|
# do something
book.save './another_file.xls'
end

another_file.xlsに保存します。

新規ファイルの保存は出来ません。

=== Want to do more things

全てのWrapExcelオブジェクトはwin32oleインスタンスを含んでいます。もし、あなたが、WrapExcelライブラリが提供していない機能を使用したい場合、win32oleのメソッドが使用出来ます。

== サポート

問題を報告したり、機能追加の要望する場合はgithubのIssuesに登録してください。 https://github.com/tomiacannondale/wrap_excel/issues

== 共同作業

githubのpull requestをしてください。

== 開発者

tomi mailto:[email protected]

== ライセンス

MITライセンスです。詳細は LICENSE を参照してください。