Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Too many number of excel processes are shown in the process
Ruhul Amin
3/28/2007 8:26:00 AM
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-...
.
1 Answer
eden li
3/28/2007 1:26:00 PM
0
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 via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Too many number of excel processes are shown in the process
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password