[#39325] File.fnmatch の改良について — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>

はじめまして、山本です。

18 messages 2004/03/05

[#39429] trial version of Ruby/Tk — Hidetoshi NAGAI <nagai@...>

永井@知能.九工大です.

18 messages 2004/03/23
[#39454] Re: trial version of Ruby/Tk — "Shirai,Kaoru" <shirai@...> 2004/03/31

白井です。

[#39460] Re: trial version of Ruby/Tk — Hidetoshi NAGAI <nagai@...> 2004/04/01

永井@知能.九工大です.

[#39465] Re: trial version of Ruby/Tk — "Shirai,Kaoru" <shirai@...> 2004/04/01

白井です。

[#39466] Re: trial version of Ruby/Tk — Hidetoshi NAGAI <nagai@...> 2004/04/01

永井@知能.九工大です.

[#39453] Re: int/int in Ruby2? — Masaaki Sakano <mas@...>

坂野 正明です。

36 messages 2004/03/31
[#39455] Re: int/int in Ruby2? — NISHIMATSU Takeshi <t-nissie@...> 2004/03/31

西松と申します.

[#39470] Re: int/int in Ruby2? — Masaaki Sakano <mas@...> 2004/04/01

坂野 正明です。

[#39473] Re: int/int in Ruby2? — matz@... (Yukihiro Matsumoto) 2004/04/01

まつもと ゆきひろです

[#39484] Re: int/int in Ruby2? — Masaaki Sakano <mas@...> 2004/04/03

坂野 正明です。

[#39528] Re: int/int in Ruby2? — "T Akutsu" <locrian@...> 2004/04/09

あくつです。なんかわくわくしてきだぞ。(^^;)

[ruby-list:39383] Re: win32ole でexcel が終了しない

From: g-1@...5.so-net.ne.jp
Date: 2004-03-18 03:12:17 UTC
List: ruby-list #39383
中です。
返事が遅れてごめんなさい。

>雪見酒さん

ソースをベタで載せます。
いろいろと悪戦苦闘のありますが・・・

require 'win32ole'

class MakeCsv
  CITY = 2 #定数
  def initialize()
    @excel = WIN32OLE.new('Excel.Application') #OLEの初期化

    @cur_dir = Dir.pwd  #カレントディレクトリの取得
    @excel.visible = false
    @book = @excel.workbooks.open("#{@cur_dir}\\string_list_copy.xls")
    @sheet = @book.worksheets(CITY)

  end

  def exit
    @book.close
    @excel.quit()

    while WIN32OLE.ole_free(@excel) > 0 do end
  end

  def test
    range = @sheet.cells(2,5)
    print range.value,"\n"
  end

  def put
    col_key = 1 #keyの行
    col_country = 5 #国の行
    col_sig = 7 #英語表記の国名
    col_info = 3 #国名、都市名の区別用

    row = 2 #初期位置

    cell_key = @sheet.cells(row, col_key)
    cell_country = @sheet.cells(row, col_country)
    cell_sig = @sheet.cells(row, col_sig)
    cell_info = @sheet.cells(row, col_info)

    while cell_key.value
      #CSVにして吐き出す
=begin
      if( cell_info.value == '国名')
        print 
cell_key.value,',',cell_country.value,',',cell_sig.value,"\n" #テスト
      else
        print cell_key.value,',',cell_country.value,',',"nil","\n" #テス
ト
      end
=end

      print 
cell_key.value,',',cell_country.value,',',cell_sig.value,"\n" #テスト

      row += 1
      cell_key = @sheet.cells(row, col_key)
      cell_country = @sheet.cells(row, col_country)
      cell_sig = @sheet.cells(row, col_sig)
      cell_info = @sheet.cells(row, col_info)


    end

  end
end

csv = MakeCsv.new
#hmaker.test
csv.put
csv.exit
GC.start

>あおきさん、伊藤さん
同じ問題で悩んでいる人がたくさんいるのがわかりました。
Rubyばかりでなく、VBl等でOLE経由でExcelを使用している人の共通の問題みたいで
すね。
まだ検索中ですが、参照の方法によってはガベジコレクションうまく機能しないのが
根源のような感じですね。




In This Thread

Prev Next