I have created a class to convert VFP to Excel. It does not need anything to be installed as it does not use Excel Automation or any OLE DB driver. It however creates Excel XML file so can only be read by Office 2003 and later.

Since it is a VFP only code, it can be subclassed and you can do things like create formatted excel workbooks. You can check out http://msdn.microsoft.com/en-us/library/aa140066.aspx for the XML definitions.

This class uses code from Alejandro Sosa ExcelListener.

LATER Updated the class so it saves the XML in chunks of 5MB to prevent "String too Long" error.

vfp2excel

8 Responses to VFP to Excel

  • Anil says:

    Nice one!. Even its in my pipeline too. But for different idea. It seems your class will be helpful me in my idea. 🙂
    Thanks for sharing with us.

    Anil

  • tushar says:

    Thanks Anil

  • Rahul says:

    Very nice!

  • Edwin says:

    do you have a class that converts Report Format into Excel?
    all the formatting, colors, images as well 🙂 thanks for the reply

  • Dan Baker says:

    Great stuff Tushar. And I think this is ultimately the most efficient way to do conversions. When I have some time, I’m going to play with creating a template or two from your example. The link to the MS Excel codes is very helpful.

    Have you used the same technique to create webpages? or Word pages?

    • Dan Baker says:

      Tushar,

      Let’s say you wanted to style the Excel document, where’s the best place to do that?

      One way I can conceive is to work directly in Excel and get the columns and headers looking as you wish and maybe label the columns: col1, col2, col3 etc.

      In other words, you work in Excel to create the template (everything except the data and actual field names, but then you use Automation to return that template back to VFP.

      I’m thinking in this way you can create a family of templates in Excel and have them available for your program to create the XML for.

      Alternatively, you could create a kind of wizard in VFP to do something similar.

      Curious what you think of this and which might be the best way to go? Cheers.

Leave a Reply

Your email address will not be published. Required fields are marked *