Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Suresh Adhikari
  Where is Suresh Adhikari?
 New Delhi
 India
 Suresh Adhikari
 To: Bhushan Sahni
  Where is Bhushan Sahni?
 Jabalpur/Mumbai
 India
 Bhushan Sahni
 Tags
Subject: RE: getting excel range programatically
Thread ID: 288803 Message ID: 288842 # Views: 26 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Projects and Design
Date: Friday, December 24, 2010 1:51:51 PM         
   


> > Hello Experts,
> >
> > I need to get Microsoft excel range in for loop on reccount of my cursor.I have cursor and I have its reccount.suppose its reccount is 30 then I have given for loop on those 15 records if my recno is 1 then I should get A,if recno is 2 then I should get B,and so on .If recno is 27 then I should get AA,If recno is 28 then I should get AB and so on.
> >
> > Is there any function available in vfp SP2 or I have to write code.If I have write to code then pls tell me how to do this?Pls tell me. Thanks in advance.
> >
> >
> > Regards,
> > Vaishali
>
> Hi Vaishali,
>
> Hope this helps
>
>
>
> a=getcell(100)
> MESSAGEBOX(a)
> PROCEDURE getcell
> PARAMETERS nRecNo
> nBasicValue=FLOOR(nRecNo/26)
> nBalValue=nRecNo-(nBasicValue*26)
> RETURN IIF(nBasicValue>0,CHR(64+nBasicValue),"")+IIF(nBalValue>0,CHR(64+nBalValue),"")
> 

>
>
> Regards
> Bhushan Sahni
> Eitzen Group (IT)
> bsh@eitzen-group.com
> Visual Foxpro a dream house for developers

Tried with a loop from 1 to 100. Error on 26,52 and 78

? getcell(26) && returns A instead of Z
? getcell(52) && returns B instead of AZ
? getcell(78) && returns C instead of BZ

Corrected function is:

PROCEDURE getcell
PARAMETERS nRecNo
nBasicValue=FLOOR((nRecNo-1)/26)
nBalValue=nRecNo-(nBasicValue*26)
RETURN IIF(nBasicValue>0,CHR(64+nBasicValue),"")+IIF(nBalValue>0,CHR(64+nBalValue),"")

ENTIRE THREAD

getting excel range programatically Posted by vaishali maske @ 12/24/2010 8:37:57 AM
RE: getting excel range programatically Posted by Bhushan Sahni @ 12/24/2010 11:42:29 AM
RE: getting excel range programatically Posted by Suresh Adhikari @ 12/24/2010 1:51:51 PM
RE: getting excel range programatically Posted by Tamar Granor @ 12/24/2010 10:43:55 PM