Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Formatting in Excel from FoxPro
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01519316
Message ID:
01519330
Views:
33
fwiw, I always prepend a single quote when the field is character type


>That is exactly what I used to do in Excel when I needed to put in numbers and didn't want the leading zeroes to be wiped out. Here's the code and it works just ifne.
>Thanks,
>Cecil
>
>
>		WITH oRange
>			* Print the columns/fields to the page. This runs left to right on the default row.
>			.Columns[1].Value = GrpName			&& Group Name
>			.Columns[2].Value = GrpID			&& Group ID
>			* Need to compensate for Employer ID beginning with a 0 which is removed in EXCEL.
>			* For example, an Employer ID of "0003" for GrpID="ABP" becomes "3" in Excel, because all
>			* leading zeroes are removed by Excel, unless the column type is set as Text beforehand,
>			* or a single quote is pre-pended to the Employer ID string, as follows:
>			* Cell.Value = "'" + EMP_ID
>			IF LEFT(EMP_ID, 1) = "0"
>				.Columns[3].Value = "'" + Emp_ID
>			ELSE
>				.Columns[3].Value = Emp_ID		&& Employer's ID
>			ENDIF
>			*.Columns[3].Value = Emp_ID			&& Employer's ID
>			.Columns[4].Value = Benefit			&& Benefit Name.
>			.Columns[5].Value = Billed			&& Monthly Billed Amount By GrpID, Employer.
>			.Columns[6].Value = Collected		&& Monthly Collected amount by GrpID, Employer.
>			.Columns[7].Value = Annualized		&& Annualized Premium.
>			.Columns[8].Value = Lives			&& # of Primary Insured.
>			* Move down one row for each time through the loop.
>			*oRange = oRange.Offset(1,0)
>			*lnRowOffSet = lnRowOffSet + 2
>			lnRow = lnRow + 1	&& Since there is a New Carrier Name (New group),
>								&& we need to move things down.
>		ENDWITH
>
>Cecil
>
>>>I noticed that an Employer ID of 0003 became 3 in my EXCEL Automation output. I know that I can go to Format / Format Cells and pick TEXT for the style of the Cell, but how do I ensure that a set of numbers stays as characters from within Visual FoxPro when writing to an EXCEL file?
>
>>Prepend a single quote to the value
>
> cell.Value = "'" + '00003'
>
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform