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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get the formatting when I export or copy a table in Foxpro to Excel? 2

Status
Not open for further replies.

german12

Programmer
Nov 12, 2001
563
DE
My free VFP table looks like this:
Dividendenbrowse_flz8xs.png


when I transfer it to MS EXCEL by using this command:

copy TO f:/dividendeab200421 TYPE xls

I receive this in EXCEL:

Dividendenbrowse2_nxtqs9.png


I tried it also with "Export to..." but that leads to the same result, which is not satisfactory because you would then have to manually adjust the formatting in Excel every time.
How do you achieve a satisfactory layout using a VFP program?
Possible?

Thanks in advance
Klaus


Peace worldwide - it starts here...
 
Don't ever use TYPE XLS; that's Excel 2.0 format. TYPE XL5 should give you what you need.

Tamar
 
Thank you Tamar,
now the result looks better

Dividendenbrowser3_e2tlwo.png


but unfortunately the values in column C (caption = "Ergebnis") have not yet changed into a better formatting. (2 decimals each would be fine)
Do I have to live with that?

Regards
Klaus





Peace worldwide - it starts here...
 
Klaus,

You can use Excel Automation to change the format of the numbers. Something like this:

Code:
ox = CREATEOBJECT("excel.application")
ox.Workbooks.Open("c:\data\MyWorkbook.xls")  && change this as necessary
ox.Columns("C").Select
ox.Selection.NumberFormat = "0.00"
ox.ActiveWorkbook.Save
ox.Quit

I haven't tested this, but I think it should work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Bingo! Mike!
That is exactly the solution I needed.
This is the result now:

Dividendenbrowser4_afdjvd.png


With the automatic processing of Excel / WORD (and other programs probably) via VFP, a whole new great world opens up for me.
Where - or how - can I best learn more about it as a beginner?

At the beginning I would try to put the headings in columns A-C in capital letters in the table above
and in columns B + C to automatically set them right-justified (or in the middle) via VFP.
The numbers in column C should also be in "x.xxx.xx" format
- (e.g. 3,840.00 in line 4) for better readability with large numbers.


Thank you for the valuable tips that I get from you (and of course from everyone who gives advice here).
It is really a pleasure to find out new things here again and again.

Stay healthy - and as we say here at the moment:
Stay negative.

Best regards from Germany
Klaus

Peace worldwide - it starts here...
 
Klaus, you're right. Automating Word and Excel (and many other applications) can indeed open new worlds for you.

Tamar has written some useful articles that will help you get started. Go to and look for articles such as "Getting Started with Office Automation" and "Driving Word and Excel from Visual FoxPro".

And come back here when you have specific questions.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
If you need more than the beginner stuff on automating Excel that's in my articles, you might want to check out the book Della Martin and I wrote on the subject:
Della wrote the Excel and PowerPoint chapters, based on her experiences on the team that created the logistics app the US Department of Defense used for moving people and materiel (which was shown at multiple VFP conferences back in the day).

Tamar
 
thank you very much, Tamar.
Klaus

Peace worldwide - it starts here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top