Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Too many number of excel processes are shown in the process

Reply
Thread Tools

Too many number of excel processes are shown in the process

 
 
Ruhul Amin
Guest
Posts: n/a
 
      03-28-2007
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/.

 
Reply With Quote
 
 
 
 
eden li
Guest
Posts: n/a
 
      03-28-2007
You might try calling excel.ole_free after you call excel.Quit()...

On Mar 28, 4:26 pm, Ruhul Amin <tuhin_cs...@yahoo.com> 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/.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Too Many Processes Rob Computer Information 6 05-15-2006 06:35 AM
Operating Processes(too many of them) jb Computer Support 36 01-30-2006 01:35 PM
Win32::Process - Limiting the number of processes launched from within a script Patrick Paquet Perl Misc 3 01-29-2004 10:11 AM
Too many Processes running in background Kookaburra NZ Computing 11 09-24-2003 09:08 AM
NOT SHOWN. The page is not shown until refresh it ! Mete Akalın ASP General 1 07-25-2003 11:28 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57