Hi All, I am trying to speed up a bit a new widget I created for wxPython, which uses heavily the COM interface between Python and Excel (it only reads Excel data, no writing).
One of the main issues I have found is related to the extraction of the "Text" property from a range of cells. Let's suppose I have a very simple Excel file (I attach a dummy sample of it). This file contains cells with some value in them, other cells are empty. When I run the following script: import os from win32com.client import Dispatch xlApp = Dispatch('Excel.Application') filename, sheetname = os.path.join(os.getcwd(), "Book1.xls"), "Book1" xlBook = xlApp.Workbooks.Open(filename) xlSheet = xlBook.Worksheets(sheetname) print "Values:" print xlSheet.Range("A1:K11").Value print "\n\n" print "Texts:" print xlSheet.Range("A1:K11").Text I get a 2D nested tuple of values for the "Value" property, but I only get a single "None" for the "Text" property (i.e., no tuple, just "None"). The solution I came up with is to iterate on every cell in the spreadsheet and get its "Text" property if it is not "None", but this is expensive compared to the "vectorized" approach you can get with Range(). Does anyone have a suggestion on how to improve my current approach (or how to fix my flawed code above)? Thank you in advance for your help. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/
Book1.xls
Description: MS-Excel spreadsheet
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32