使用 Excel 2010 和 Visual FOXPRO

Using Excel 2010 with Visual FOXPRO

有人要求我通过Excel 2010 和Visual FOXPRO 创建一种翻译器,但我不会Visual FP,有人可以解释一下如何连接它们吗? 我用的是WIN10,Office 2010.

您的问题并没有真正解释您的需求。

如果您不知道VFP,您会如何使用VFP 进行连接?你还在要求示例代码连接到 Excel 并做一些事情吗?如果是这样,您不仅需要了解 VFP,还需要了解 Excel VBA。 Excel 使用 VBA 进行自己的处理。下面是一个非常简单的 VFP 代码。检查注释以了解它的作用(with ... endwith 块中的代码是 Excel VBA)。

* Select sample data and copy to clipboard as TAB delimited
Select * From (_Samples+'data\customer') ;
    Into Cursor crsMyData ;
    nofilter
Local lcTemp
lcTemp = ForcePath(Sys(2015)+'.tmp', Sys(2023))
Copy To (m.lcTemp) Type Delimited With "" With Tab
_Cliptext = Filetostr(m.lcTemp)
Erase (m.lcTemp)
* Select sample data and copy to clipboard as TAB delimited


* Create Excel Workbook
* and paste the data copied above
* starting at A3
* and autofit columns
oExcel = Createobject('Excel.Application')
With oExcel
  .Workbooks.Add()
  .Activeworkbook.Activesheet.Range('A3').PasteSpecial()
  .Selection.Name = 'myData'
  .Range('A1').Activate()
  .Range('myData').Columns.Autofit()
  .Visible = .T.
Endwith