[Tutor] Traversing Excel Columns
Chris Hengge
pyro9219 at gmail.com
Tue Sep 12 07:46:59 CEST 2006
I don't suppose that anyone has a fix for me eh? I've tried about all I
can think of and I'd like to be able to give this program a trial
tomorrow when I get back to work.. sure would save me some time :]
On Mon, 2006-09-11 at 17:48 -0700, Chris Hengge wrote:
> Hmm... ok... after some thought... this is what I'm looking for
>
> #some great line that gives me an int for the number of not null cells
> intLastUsedRow = xlSht.Cells.LastValue #Made this up, but basically
> what I need.
>
> I need to iterate through a range() because I dont know another good
> way to tell it not to use the column headings and other junk over the
> data I want to collect.
>
> try: #Loop through rows
> for row in range(5,intLastUsedRow):
> #Write each row, incriment 1+row in column 5
> file.write(xlSht.Cells(1+row,5).Value)
>
>
> On 9/11/06, Alan Gauld <alan.gauld at btinternet.com> wrote:
> I'm no expert in Excel programming but I assum,e you tried
> the obvious:
>
> > I'm looking for something more like
> > try:#Loop until rows are null
> > while row in xlwksht != null
> > #Write each row, incriment 1+row in column 5
> > print >> file, "'" + %s + "',", %
> > ( xlSht.Cells(1+row,5).Value)
>
> for row in xlSht.Cells:
> print >> file, row.Value
>
> I know you can do something similar in VBScript, I'm not sure
> if the Python bindinghs to the COM objects are gtthat clever
> however.
>
> But might be worth some experimenting at the >>> prompt.
>
> Alan G.
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list