Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copying to a xlsx file
Message
From
01/10/2014 16:11:33
 
 
To
01/10/2014 00:59:59
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01608539
Message ID:
01608627
Views:
62
>>>>>>>>Is there any way to COPY to an XLSX file rather than XLS?
>>>>>>>>
>>>>>>>>Would this also apply to VFP 5.0?
>>>>>>>
>>>>>>>If a MS Exccel is on the comp, automation can do the job.
>>>>>>
>>>>>>Do you mean by COPYing to a DELIM and then opening the DELIM file from Excel and saving it as an XLSX?
>>>>>
>>>>>No, I mean to use VFP to control MS Excel.
>>>>>
>>>>>just enter in the command window something like
>>>>>
>>>>>loExcel = createobject('Excel.Application')
>>>>>
>>>>>for start and then start to browse the pems of loExcel.
>>>>>
>>>>>You can do anything that is possible from VBA for Application (it's called like that?) That wahta does macros in Excel.
>>>>
>>>>Using the Excel object is what I meant.
>>>>
>>>>I would think that COPYing to a DELIM file and then using automation to read in the DELIM file with the Excel object and then saving it to a XLSX would be faster than constructing each row with the Excel object, especially if we're talking a large file.
>>>>
>>>>Thanks for the suggestion.
>>>
>>>Why row by row? There are only two ways: cell by cell or range. A range could be all at once.
>>>If you use automation to create / save the file + writing the data as one selection of range and one value assignment will not be slower then creating a external file and importing it.
>>>It also gives you the posibility to export memos, and do any alteration you like.
>>>
>>>Lutz
>>
>>Turns out it is as simple as this:
>>
>>
>>LOCAL loExcel AS Excel.APPLICATION
>>
>>USE foo
>>
>>copy to xoo XL5
>>
>>loExcel = CREATEOBJECT("Excel.application")
>>loExcel.VISIBLE = .F.
>>loExcel.displayalerts = .F.
>>loExcel.AskToUpdateLinks = .F.
>>
>>lcFileName = 'xoo'
>>
>>loWorkBook = loExcel.Workbooks.OPEN(lcFileName + '.xls')
>>loWorkBook.SAVEAS(lcFileName + '.xlsx', 51)  && xlOpenXMLWorkbook = 51
>>
>>loWorkBook.CLOSE()
>>
>>loExcel.QUIT()
>>RELEASE loExcel
>>loExcel = NULL
>>
>>DELETE FILE xoo.xls
>>
>
>If you prefer it that way. Look for the problems exporting data to MS Excel as memo,.NULL., empty DATE(TIME), Strings that look like numbers etc. I wouldn't do that.
>
>I don't want you to be sad with me but it's a bit more complex. :)
>
>Just open MS Excel before you run the code and see what's happen.
>
>Lutz

Thanks, I'll look into that.
Previous
Reply
Map
View

Click here to load this message in the networking platform