Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Better way to code Excel automation?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01313820
Message ID:
01314033
Views:
18
Hi Albert,

depends on the version of Excel. If you can safely assume that Office XP or later is used, I would avoid automation completely. Excel XP, Excel 2003 and Excel 2007 allow to save spreadsheets in XML files. It's way simpler than automation to merely open the XLS file given by your client, save it as an XML spread sheet and replace all cell values with textmerge expressions. Then use something like TEXTMERGE(FILETOSTR()) to generate the entire spreadsheet in a single line. To view it in Excel, you can use a line like this:
	Local loExcel, lcFile
	lcFile = FullPath("Test.xml")
	StrToFile( m.lcXML, m.lcFile)
	loExcel = CreateObject("Excel.Application")
	loExcel.Visible = .T.
	Try 
		loExcel.Workbooks.Add(m.lcFile)
	Catch
	EndTry 
--
Christof
Previous
Reply
Map
View

Click here to load this message in the networking platform