Import data from Excel
tim.golden at viacom-outdoor.co.uk
Tue May 9 11:06:42 CEST 2006
| from win32com.client import GetObject, constants
| def GetExcelData(self, strFilePath):
| """ Extract the data from the Excel sheet.
| Returns tuple of tuples representing the rows and cells."""
| # The following line extracts
| # all the data from sheet 1 of the spreadsheet
| return GetObject(strFilePath).Sheets(1).UsedRange.Value
Amazing! I never knew you could do that -- GetObject against
a registered file path, I mean. Certainly beats my trying to
remember whether you call .Open on an Excel Application, Workbook,
Worksheet or something else altogether.
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
More information about the Python-list