在PB中实现对EXCEL的操作

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 22:57:40

在PB实现象下面的VFP 的应用,好将资料放到一个电子表格

Myexcel=createobject('EXCEL.APPLICATION')

MYEXCEL.VISIBLE=.f.

MYEXCEL.WORKBOOKS.ADD

O1=MYEXCEL.ACTIVEWORKBOOK.SHEETS(1)

O1.NAME='IN'

o1.CELLS(1,2).VALUE='abc'

又如:

excel=createobject('excel.application')

EXCEL.VISIBLE=.T.

ExcelFile="D:\MYDOCU~1\DC1999\DC_MDT.XLS"

if not file(ExcelFile)

wait wind 'no file:'+excelfile

return

endif

excel.workbooks.open(ExcelFile)

PB实现象上述VFP 的应用,代码如下:

方法一:

OLEObject ExcelServer

integer ExcelOK

ExcelServer = CREATE OLEObject

ExcelOK = ExcelServer.ConnectToNewObject( "excel.application" )

ExcelServer.Workbooks.Open("c:\book.xls")

ExcelServer.ActiveWorkBook.Sheets("Sheet2").Select

ExcelServer.ActiveSheet.Cells(1,1).value = "书名"

ExcelServer.Application.Visible = TRUE

方法二

先启动excel文件

long handle_1

handle_1 = OpenChannel("Excel", "c:\book.xls")

//建立与EXCEL的通道

setremote("r1c1","书号","excel"," c:\book.xls")

setremote("r1c2","书名","excel"," c:\book.xls")

//更改某一行或某一列的值,同时关闭通道

closechannel(handle_1,handle(parent))


Tags:

作者:佚名
分享到: 微信 更多