Advertisement

05.13.2008 at 12:22PM PDT, ID: 23399098
[x]
Attachment Details

Read data from Microsoft Excel via PowerBuilder

Asked by pemurray in PowerBuilder Programming Language

Tags: Sybase, PowerBuilder, 11.1

Greetings,

I am trying to implement some code I found on this site and I am getting an error.  When I run the code the messagebox displays the contents of the first cell where i=1 and j=1 (This is a merged cell that runs across the top of the page).  But on the next instance where we read the next cell, I get an error as follows:

"Cannot convert oleobject to Any variable to string at line 17 in clicked event..."

Can someone please point me in the right direction?

Also, am I correct in thinking that 'i' is column and 'j' is row?

Thank you,

Paul


Start Free Trial
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:
string pathtospreadsheet
pathtospreadsheet = sle_1.text
 
integer result, i , j
string ls_read
 
 
OLEObject myoleobject
myoleobject = CREATE OLEObject
result = myoleobject.ConnectToObject(pathtospreadsheet)
 
myoleobject.Worksheets(1).Activate 
 
IF result = 0 THEN
//      For i = 1 to 1
	i = 1
            for j = 4 to 10
                  ls_read =  myoleobject.application.workbooks(1).worksheets(1).cells(i,j).value
                  messagebox('Spreadsheet Value for Column ' + string(i) + ' and Row ' + string(j),ls_read)
            next
//      next
//    myoleobject.application.workbooks(1).save()
END IF
 
DESTROY myoleobject
[+][-]05.13.2008 at 02:47PM PDT, ID: 21559599

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 11:34PM PDT, ID: 21561677

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PowerBuilder Programming Language
Tags: Sybase, PowerBuilder, 11.1
Sign Up Now!
Solution Provided By: diasroshan
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628