Do not use on any
shared computer
August 29, 2008 09:09pm pdt
 
[x]
Attachment Details

Powerbuilder - reading Excel File

Tags: Sybase, PowerBuilder, PB11, Powerbuilder - reading Excel File
I have created a small script to read Excel. It works fine, thye problem happens when The excel file is big, because it read cell by cell and its quite slow. Here the code:

integer result, i , j
long rownumber,colnumber
string ls_read,firstcell,lastcell
any data_instructions


OLEObject myoleobject
myoleobject = CREATE OLEObject
result = myoleobject.ConnectToObject( "C:\Documents and Settings\dmazzini\Desktop\myexcelfile.xls")
myoleobject.Application.Visible = true


rownumber=myoleobject.Activesheet.UsedRange.rows.count
colnumber=myoleobject.Activesheet.UsedRange.column.count

firstcell="A1"
lastcell="IV" + string( rownumber)
myoleobject.Worksheets(1).Activate


IF result = 0 THEN
For i = 1 to rownumber
for j = 1 to colnumber
ls_read = string(myoleobject.application.workbooks(1).worksheets(1).cells(i,j).value)
//messagebox('',string(ls_read) )
next
next
myoleobject.application.workbooks(1).save()
END IF

MessageBox("done!",string( data_instructions))


DESTROY myoleobject


----------------------------------------------------------------------------------------------------
So,
I would like to be able to save all data from worksheet in one arrayof arrays. I have done it in other languages. and then iterate over it

E g
data_instructions =myoleobject.Activesheet.Range(firstcell,lastcell).value

Now, how can I iterate over "data_instructions" and get values

Pseudocode:

foreach row  (data_instructions) {
          foreach column (data_instructions) {
                       value = value (row n) (column n)
                       value(2)(2) = = value (row 2) (column 2)
         }
}


Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: dmazzini
Question Asked On: 04.24.2008
Participating Experts: 1
Points: 125
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by sandeep_patel

Rank: Guru

Expert Comment by sandeep_patel:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by dmazzini
Author Comment by dmazzini:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628