Harbour TOleAuto():New() 1 will read as 1.00

Harbour TOleAuto():New() 1 will read as 1.00

Postby ShumingWang » Mon Apr 14, 2008 12:50 am

Hi,
excel file, cell type normal .
itemid qty
001 1
002 1
010 8

oExcel := TOleAuto():New( "Excel.Application" )
oExcel:WorkBooks:Open(ALLTRIM(cfile))
oSheet := oExcel:ActiveSheet()
? oSheet:Cells(2,1):Value
//1.00

? oSheet:Cells(2,1):Value
//2.00

? oSheet:Cells(3,1):Value
//10.00
Best regards!

Shuming Wang
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby nageswaragunupudi » Mon Apr 14, 2008 12:57 am

If the first column of the Excel is formatted as text, TOleAuto reads the values as text '001', etc
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10651
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby ShumingWang » Mon Apr 14, 2008 1:33 am

But xharbour could.
For sometimes customers do not know the changement, so get errors .
I think harbour should change this ,or there is a function could change this.
Shuming Wang
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby nageswaragunupudi » Mon Apr 14, 2008 2:23 am

XHarbour knows what excel knows. Excel itself thinks it is a number ( in canse of general format ). How can xharbour knwo what excel itself does not know ?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10651
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby ShumingWang » Mon Apr 14, 2008 3:05 am

It could read int as int type , float as float:
1 read as 1
1.00 read as 1.00

Cell 001, 1 and 1.00 in excel are different.

Shuming Wang
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby Rick Lipkin » Mon Apr 14, 2008 12:46 pm

ShumingWang

If I understand you correctly .. you are looking to 'format' a column ?? If so you can uses the following :

For alpha\numeric column :
oSheet:Range( "A:C" ):Set( "NumberFormat", '@' )

For a numeric column with 2 decimals:
oSheet:Range( "A:C" ):Set( "NumberFormat", '0.00' )

The formatting comes after you define your workbook.

Hope this helps

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Postby nageswaragunupudi » Mon Apr 14, 2008 12:51 pm

Mr Richard

That is not what he wants. Even I misunderstood him earlier. What he says is this.

He is reading from excel sheet using TOleAuto. He is reading second column. All the numbers in the second column in the excel sheet are integers.

After harbour reads these integers, Harbour shows these intergers as 1.00, 2.00, etc. but not as 1, 2, etc. He says why can not Harbour show them as 1, 2, etc.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10651
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Enrico Maria Giordano » Mon Apr 14, 2008 3:47 pm

It's only a display problem. Try using Int() function or SET DECIMAL TO 0 command.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby nageswaragunupudi » Mon Apr 14, 2008 3:54 pm

kindly see the following code:

n := 9
m := 10.00
msginfo( n ) // displays 9
msginfo( m ) // displays 10.0000

That means (x)harbour internally notes that n is integer and m is not. What Mr Richard asks is to do that when reading values by TOleAuto class.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10651
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Enrico Maria Giordano » Mon Apr 14, 2008 3:57 pm

You better ask to Ron Pinkas in comp.lang.xharbour.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby nageswaragunupudi » Mon Apr 14, 2008 3:58 pm

Yes. that is the right forum. not this
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10651
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby ShumingWang » Tue Apr 15, 2008 12:39 am

Thank you all for take interested to this!
Some time a table with a field named itemid char type might load some data from an excel sheet.

read from excel seet:

itemid qty
001 1
002 1
003 2
004 2.11
011 18.10

--->

to database table1

wanted result :
itemid(char) qty (float)
001 1.00
002 1.00
003 2.00
004 2.11
011 18.10

But actual wrong result:
itemid(char) qty (float)
1.00 1.00
2.00 1.00
3.00 2.00
4.00 2.11
11.00 18.10

Sorry ,I posted to http://lists.harbour-project.org/piperm ... /date.html , but failed.

Best regard!
Shuming Wang
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Enrico Maria Giordano, nageswaragunupudi and 77 guests