Excel manipulation

S

Simbolla Simbolla

hi all,

Below is the code for manipualting excel data.

================================================
require 'win32ole'
excelPath = "C:\\vbscript\\sample.xls"
application = WIN32OLE.new('Excel.Application')
application.DisplayAlerts = 0
application.Workbooks.open excelPath, false, true
currentWorkSheet = application.ActiveWorkbook.Worksheets(1)
sCell = currentWorksheet.Cells
usedColumnsCount = currentWorkSheet.UsedRange.Columns.Count
usedRowsCount = currentWorkSheet.UsedRange.Rows.Count
puts "Rows= #{usedColumnsCount} cols=#{usedRowsCount}"


For this above code i get this error
======================================
Sampler.rb:7: undifined local variable or method "currentWorkSheet" for
main:Object(NameError)

I dont the reason for this error?
 
J

Jean-Julien Fleck

currentWorkSheet =3D application.ActiveWorkbook.Worksheets(1)
sCell =3D currentWorksheet.Cells

Second line should be currentWorkSheet and not currentWork*s*heet (or
rather first without capitalized S)
BTW, use rather current_worksheet for your variables (downcase and
underscores), it's more "Ruby style"

Cheers,

--=20
JJ Fleck
PCSI1 Lyc=E9e Kl=E9ber
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top