Do you want to create a formatted Excel file, or automate a pre-existing one?
If your creating one, HTML is faster. See FAQ184-4704 for sample code.
If pre-existing, you can specify ranges and apply formats using via automation. See the code at the bottom of the FAQ and within the Excel automation add code like:
If you are sending data to the spreadsheet, and it has consistent format, open a blank spreadsheet and format it so it fits your nees (colunms, rows, datatypes, etc.) and then save it as a template.
Open this template, whether using VFP or another method, and send the data to it rather than a blank spreadsheet.
Remember, all documents are created in a template - even the standard document.
Writing an HTML file (even with formatting) is going to beat the pants off of sending (just) data to Excel.
Try my FAQ vs. sending the data to Excel via automation on a few thousand records and you'll see what I mean. And note the FAQ is demonsrating how to apply conditional formatting too.
The one performance hit is when Excel is opening and interpreting the HTML. In the files I create this way I've automated the open-and-save-as-Excel before .visible=.t.
And of course, Excel 2000 + is required to read load the resultant HTML files...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.