>>Hi, I am using the IMPORT FROM command to read in an Office 2007 MS-Excel file, so field names are A, B, ....Z, AA, AB, ...AZ, BA, BB, etc..
>>
>>I have to handle files defined as:
>> Columns A - M: standard information
>> Columns N - R: information about charge 1
>> Columns S - W: information about charge 2
>> Columns X - AB: information about charge 3
>> etc.
>>
>>In other words, past column M, information is in groups of 5 columns.
>>
>>NOOOO problem, i thought. I have code that calculates the column name.
>>
>>BUT lo and behold! what column follows DU??? NO, NOT DV, but DW!
>>
>>What is going on here? any ideas? this is def. breaking my code.
>>
>>Any input is appreciated.
>>
>>Guess i have to change the code to using AFields()?
>
>The first question to ask is, does the Excel file you're IMPORTing have more than 254 columns?
No. the specific file i'm dealing with has 132 columns.
>
>If not, maybe there is something funky with the Excel file. Here's some code that creates a VFP cursor with 150 columns, writes it out to an Excel file, then IMPORTs it back in, and BROWSEs the resultant table. Those columns go up to "ET" (coincidence :)) but you can see they go DU, DV, DW etc. as expected.
>
>LOCAL ;
> lcString1 ;
> , lcString2 ;
> , lcString3 ;
> , lnIx
>
>CLOSE DATABASES ALL
>
>STORE "" TO lcString1, lcString2, lcString3
>
>FOR lnIx = 1 TO 150
> lcString1 = lcString1 ;
> + "c" + PADL( LTRIM( STR( lnIx ) ), 3, "0" ) ;
> + " C(4),"
>
>*!* lcString2 = lcString2 ;
>*!* + "c" + PADL( LTRIM( STR( lnIx ) ), 3, "0" ) ;
>*!* + ","
>
>*!* lcString3 = lcString3 ;
>*!* + ["] ;
>*!* + "c" + PADL( LTRIM( STR( lnIx ) ), 3, "0" ) ;
>*!* + [",]
>
>ENDFOR
>
>* Trim trailing commas:
>lcString1 = LEFT( lcString1, LEN( lcString1 ) - 1 )
>*!* lcString2 = LEFT( lcString2, LEN( lcString2 ) - 1 )
>*!* lcString3 = LEFT( lcString3, LEN( lcString3 ) - 1 )
>
>CREATE CURSOR Test ;
> ( &lcString1 )
>
>*!* INSERT INTO Test ;
>*!* ( &lcString2 ) ;
>*!* VALUES ;
>*!* ( &lcString3 )
>
>* Create an XLS file from the cursor:
>SELECT Test
>EXPORT TO ExcelColTest.xls TYPE XLS
>* Created XLS file has one row, with column names
>
>USE IN Test
>
>* IMPORT the XLS file (table created has the same name as the stem of the file chosen to IMPORT):
>IMPORT FROM ExcelColTest.xls TYPE XL8
>SELECT ExcelColTest
>BROWSE NOWAIT
>
>If you're trying to diagnose Excel file funkiness:
>
>- Try deleting the top row of the Excel file, and import
>- Look in the vicinity of column DU for things like null characters, tab characters, high ASCII, unexpected apostrophes (e.g. a name like O'Hara) etc.
Thanks Al