FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Harbour TOleAuto():New() 1 will read as 1.00
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: 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

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: 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
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: Mon Apr 14, 2008 01: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

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: Mon Apr 14, 2008 02: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
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: Mon Apr 14, 2008 03: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

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: 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

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: 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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: Mon Apr 14, 2008 03:47 PM

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

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: Mon Apr 14, 2008 03: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: Mon Apr 14, 2008 03:57 PM

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

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: Mon Apr 14, 2008 03:58 PM

Yes. that is the right forum. not this

Regards



G. N. Rao.

Hyderabad, India
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Harbour TOleAuto():New() 1 will read as 1.00
Posted: 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

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651

Continue the discussion