[pywin32-bugs] [ pywin32-Bugs-1418081 ] Reads float from Excel cell instead of int
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2006-01-29 21:04:47
|
Bugs item #1418081, was opened at 2006-01-29 15:06 Message generated for change (Comment added) made by nickjacobson You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1418081&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nick Jacobson (nickjacobson) Assigned to: Nobody/Anonymous (nobody) Summary: Reads float from Excel cell instead of int Initial Comment: When you read in an integer from an Excel cell, it is type float. And printing it will print e.g. "5.0" instead of "5". example: from win32com.client import Dispatch xlApp = Dispatch("Excel.Application") xlApp.Visible = 1 xlApp.Workbooks.Add() xlApp.ActiveSheet.Cells(1,1).Value = 5 print xlApp.ActiveSheet.Cells(1,1).Value print type(xlApp.ActiveSheet.Cells(1,1).Value) raw_input("paused") xlApp.Quit() This returns: 5.0 <type 'float'> paused I'm using Python 2.4.2 and Excel 2003 Pro. ---------------------------------------------------------------------- >Comment By: Nick Jacobson (nickjacobson) Date: 2006-01-29 16:04 Message: Logged In: YES user_id=1067650 Thanks for the info; I didn't know that about Excel. Still, shouldn't it return "5" or "5." instead of "5.0"? ---------------------------------------------------------------------- Comment By: John Machin (sjmachin) Date: 2006-01-29 15:44 Message: Logged In: YES user_id=480138 "When you read in an integer from an Excel cell": no such concept. Excel "number" format is floating point. When you assigned 5 to the cell, it was correctly stored as a floating point number. The value in the cell was then correctly retrieved as a floating point number. This is not a problem with pywin32. VBA and every other method of programmatic access to Excel or reading Excel files would (or should!) do the same thing. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1418081&group_id=78018 |