Too many number of excel processes are shown in the process

Discussion in 'Ruby' started by Ruhul Amin, Mar 28, 2007.

  1. Ruhul Amin

    Ruhul Amin Guest

    hi guys,
    I want to read some data from each of the files from a directory
    and save it to database.In the time of read operation each excel file is
    open but not close after read from the file. After processing of all
    files the excel is closed.
    here is the code..
    code

    count=100
    i=0
    while i<count
    i=i+1
    begin
    excel = WIN32OLE::new('excel.Application') # create winole Object
    workbook = excel.Workbooks.Open("#{path}") # Open the Excel file
    worksheet = workbook.Worksheets(1) #get hold of the first worksheet
    worksheet.Select # select the worksheet
    title = worksheet.Range('h3')['Value'] #get value of title
    excel.ActiveWorkbook.Close(0) # close the workbook
    excel.Quit() # close Excel file
    rescue
    excel.Quit()
    ensure
    excel.Quit() unless excel.nil?
    end
    end

    code end

    For 50/100 or more files, too many number of excel processes are shown
    in the process list of Test manager.The cpu utility becomes 100% and
    memory(RAM) becomes full and computer becomes very slow, almost hung.

    Please review the code where I made mistake.

    please help me.

    --
    Posted via http://www.ruby-forum.com/.
     
    Ruhul Amin, Mar 28, 2007
    #1
    1. Advertising

  2. Ruhul Amin

    eden li Guest

    You might try calling excel.ole_free after you call excel.Quit()...

    On Mar 28, 4:26 pm, Ruhul Amin <> wrote:
    > hi guys,
    > I want to read some data from each of the files from a directory
    > and save it to database.In the time of read operation each excel file is
    > open but not close after read from the file. After processing of all
    > files the excel is closed.
    > here is the code..
    > code
    >
    > count=100
    > i=0
    > while i<count
    > i=i+1
    > begin
    > excel = WIN32OLE::new('excel.Application') # create winole Object
    > workbook = excel.Workbooks.Open("#{path}") # Open the Excel file
    > worksheet = workbook.Worksheets(1) #get hold of the first worksheet
    > worksheet.Select # select the worksheet
    > title = worksheet.Range('h3')['Value'] #get value of title
    > excel.ActiveWorkbook.Close(0) # close the workbook
    > excel.Quit() # close Excel file
    > rescue
    > excel.Quit()
    > ensure
    > excel.Quit() unless excel.nil?
    > end
    > end
    >
    > code end
    >
    > For 50/100 or more files, too many number of excel processes are shown
    > in the process list of Test manager.The cpu utility becomes 100% and
    > memory(RAM) becomes full and computer becomes very slow, almost hung.
    >
    > Please review the code where I made mistake.
    >
    > please help me.
    >
    > --
    > Posted viahttp://www.ruby-forum.com/.
     
    eden li, Mar 28, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. peelman

    How many threads is too many?

    peelman, Jan 13, 2005, in forum: Java
    Replies:
    12
    Views:
    878
    Esmond Pitt
    Jan 15, 2005
  2. Rhino
    Replies:
    33
    Views:
    1,356
    Oliver Wong
    Dec 22, 2005
  3. rbt
    Replies:
    1
    Views:
    383
  4. Mete Akalýn
    Replies:
    1
    Views:
    438
    Mete Akalýn
    Jul 25, 2003
  5. Dag Sunde
    Replies:
    4
    Views:
    381
Loading...

Share This Page