datprimaryrs.recordset.movefirst
‘datprimaryrs为data控件
if isnull(datprimaryrs.recordset!姓名) = false then
xlsheet.cells(4, 2) = datprimaryrs.recordset!姓名
end if
if isnull(datprimaryrs.recordset!性别) = false then
xlsheet.cells(4, 4) = datprimaryrs.recordset!性别
end if
if isnull(datprimaryrs.recordset!民族) = false then
xlsheet.cells(4, 6) = datprimaryrs.recordset!民族
end if
………………
四. 打印报表
生成了工作表后,就可以对excel发出打印指令了。
注意在执行打印操作之前应该对excel临时文件执行一次保存操作,以免在退出应用程序后excel还提示用户是否保存已修改的文件,让用户觉得莫名其妙。如下语句:
xlbook.save ‘保存文件
xlsheet.printout ‘执行打印
xlapp.quit ‘退出excel