欢迎访问!
(一)在从Datawindow到EXCEL过程中
1.报表表头怎样导入到EXCEL中
2.DETAIL中的数据怎样导入到EXCEL中
3.当head中字段该为中文以后还可以对数据窗口进行select,update,insert吗?
//////////看怎么修改,才能实现一面的功能
string ls_filename,ls_filepath
GetFileSaveName("请选择保存路径",ls_filepath,ls_filename,"xls","Excel Files (*.xls),*.xls")
long numcols , numrows , c, r
OLEObject xlapp , xlsub
int ret
numcols = long(dw_1.Object.DataWindow.Column.Count)
numrows = dw_1.RowCount()
xlApp = Create OLEObject
ret = xlApp.ConnectToNewObject( "Excel.Sheet" )
if ret < 0 then
MessageBox("Connect to Excel Failed !",string(ret))
return
end if
try
xlsub = xlApp.Application.Workbooks.Add()
xlsub = xlapp.Application.ActiveWorkbook.Worksheets[1]
xlApp.Application.Visible = true
string ls_name
for c=1 to numcols //写标题
ls_name = dw_1.describe( "#" + string(c) + ".name" )
xlsub.cells[1,c] = ls_name
next
for r = 1 to numrows//写数据
for c = 1 to numcols
xlsub.cells[r+1,c] = dw_1.object.data[r,c]
next
next
xlsub.saveas(ls_filepath)
xlApp.Application.Workbooks.close()
catch ( runtimeerror re )
MessageBox ( string(re.number), re.getmessage())
end try
xlApp.DisConnectObject()
Destroy xlapp
(二)怎么把EXCEL中的数据导入到DATAWINDOW中(下面的实现不了的)
string str_savename,named,s_grxh
int excelok,li_net
long li_count,i
oleobject excelserver
excelserver=create oleobject
excelok=excelserver.connecttonewobject("excel.application")
//检查返回值,以确保已成功地连接到了Excel
if excelok <> 0 then
messagebox("信息提示","连接EXCEL失败,请检查计算机中是否安装了EXCEL!")
return -1
end if
li_net = GetFileOpenName("选择文件", str_savename,named,"xls","Excel文件(*.xls),*.xls")
if li_net > 0 then
if str_savename = "" then return -1
dw.settransobject(sqlca)
dw.reset()
excelserver.workbooks.open(str_savename)
excelserver.activesheet.cells.copy
li_count = dw.importclipboard(2) //导入数据
clipboard("")
excelserver.quit()
excelserver.disconnectobject()
destroy excelserver
return 1
else
messagebox('信息提示','没有指定导入文件!')
return -1
end if