Sign in to follow this  
Followers 0
KThorn

Excel Object Problem

4 posts in this topic

I am using the following code to extract a numeric value from and Excel spreadsheet.

The number in the cell is 1819674244 but the number returned from the .Value property is 1819674240

All of the other numbers in the column are off by small increments.

Has anyone seen this/have a solution. My only other alternative is to do a saveas to a txt file and read that.

Thanks

Kyle

CODE
$oExcel = objCreate("Excel.Application")

$oExcel.Visible = 0

$oBooks = $oExcel.Workbooks.Open($infilename)

$oSheet = $oBooks.Worksheets(1)

$oBooks.Saved = True

msgbox(0,"Debug",$oSheet.Range("C3").Value)

$oBooks.Close

$oExcel.Quit

Share this post


Link to post
Share on other sites



The number in the cell is 1819674244 but the number returned from the .Value property is 1819674240

I cannot duplicate your described behavior. I am testing w/ office xp, xp pro, with (3.2.2.0)

I rely extensively on the Excel COM object model and au3, and have never seen such behavior.

I would be intensely interested in knowing if this behavior can be duplicated, and, if so, in what configurations.

I would suggest you write a loop that writes a cell value, then reads it, and look for a variance in what you write and what you read back. Also, check your cell settings, date/time formats, currency, percentages, formulas, etc.... -- ensure that you aren't getting bitten by rounding, excel date arithmetic, or other funky behavior.

If you can still duplicate, please provide a zip file containing your code, and the spreadsheet in question.

Should your report hold up, at a minimum I'll need to write some logic to test for the conditions to ensure that none of my programs introduce data corruption.


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

OK, I'm at home now but thought I would do some more testing.

Running 3.2.0.1 with Excel 2007 but saving spreadsheets as 97-2003 xls format.

I am attaching my test script and the test spreadsheet.

Results was the same, wrong number reading from the spreadsheet and wrong number

when writing and then reading a different cell????

Kyle

New script

CODE
$oExcel = objCreate("Excel.Application")

$oExcel.Visible = 0

$oBooks = $oExcel.Workbooks.Open("c:\kyle.xls")

$oSheet = $oBooks.Worksheets(1)

$oSheet.Range("B1").Value=1819674244

msgbox(0,"A1",$oSheet.Range("A1").Value)

msgbox(0,"B1",$oSheet.Range("B1").Value)

$oBooks.Saved = True

$oBooks.Close

$oExcel.Quit

kyle.zip

Share this post


Link to post
Share on other sites

Just installed 3.2.2.0 and ran the same script and all is working now. I guess the issues was fixed in one of the releases.

Thanks for the help

Kyle

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0