当前位置: 代码迷 >> VFP >> EXCEL转VFP表列解决方法
  详细解决方案

EXCEL转VFP表列解决方法

热度:2392   发布时间:2013-02-26 00:00:00.0
EXCEL转VFP表列
请高手帮忙将EXCEL行转列
EXCEL:
款号 EY9003 EY9004 EY9005
数量 100 23.5 78.2


转VFP表:

款号 数量
EY9003 100
EY9004 23.5
EY9005 78.2

谢谢!

------解决方案--------------------------------------------------------
为什么不先在EXCEL中转一下?直接可以利用EXCEL的特殊粘贴中的转置。
------解决方案--------------------------------------------------------
测试通过 
public mypath 
mypath="" 
mypath=getfile("xls") 
if empty(mypath) 
wait clear 
return 
endif
_ole_excel = CreateObject("Excel.Application") 
_ole_excel.VISIBLE=.T.
_ole_excel.DisplayAlerts = .F.
_ole_excel.AskToUpdateLinks = .F.
_ole_excel.WorkBooks.Open(mypath) && 要打开的工作表名(xls)必须是全路径 
_ole_excel.WorkSheets(2).Activate &&激活指定的工作簿 
_ole_excel.WorkSheets(2).Range("A1:D2").Select
_ole_excel.Selection.Copy
_ole_excel.WorkSheets(1).Activate
_ole_excel.WorkSheets(1).Range("A1").Select
_ole_excel.Selection.PasteSpecial(-4104,-4142,.F.,.t.)
_ole_excel.ActiveWorkbook.saveas("R:\TEMP\aa1.dbf",11,.f.) 
_ole_excel.ActiveWorkbook.saved = .T.
_ole_excel.DisplayAlerts = .F.
_ole_excel.quit
RELEASE _ole_excel
  相关解决方案