Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting to Excel

Status
Not open for further replies.

ChrisAgius

Programmer
Sep 27, 2000
51
MT
I have an application which exports the data to an excel sheet. I want to transform the cells into a Text Format. Can anyone tell how to set the Format of the excel cells from Foxpro.

Thanks a Lot.
 
You can also do it by how you send the data to Excel. Rather than
oCell.value = nInt you can use
oCell.value = STR(nInt)

Otherwise check out the help file VBAXL9.CHM it has the compete map of the Excel object.
-Pete
 
Where can I find this file ?

The Problem is that the Data I am Passing over are string.
But some of the Strings are numeric like "232323233" but the Excel have the Format General and this String is recognised as a numeric Value and is aligned Right and with the Exponent if the Number is large, unlike the text format.

Thanks
 
Chris (and Excel),
The VBAXL9.CHM file is optionally installed with Office 2000, for other versions of Office the name would be different.
Pete's suggestion will work if you are using object automation to export the data, but if you are using the COPY TO or EXPORT TO commands, the interpretation of the field types is based on Excel's "best guess".

Rick
 
on my machine VBAXL9.CHM is at
C:\program files\Micosoft Office\Office\1033

Just run File Find from the start menu. If it was installed you'll find it.
-Pete
 
"The Problem is that the Data I am Passing over are string. But some of the Strings are numeric like "232323233" but the Excel have the Format General and this String is recognised as a numeric Value and is aligned Right and with the Exponent if the Number is large, unlike the text format."

if you format your cells BEFORE you copy over the data, your data will appear correctly.

ie
select the range you require....
then format>cells>number>text>ok
then copy your data




Pete Bloomfield
Down Under
 
Here is an example of some Excel object code to format a cell... oCL is an Excel Cell object

cNumberFormat1 = "0.00"
cNumberFormat2 = "$#,##0"
oCL.NumberFormat = cNumberFormat2
oCL.Value = nGLab + nGEqp + nGMat + nGOth
oCL.Font.Bold = True
oCL.Font.Italic = True
-Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top