PB数据窗口图片导出函数

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

/**********************************************
* 函数名称: f_dw2excel(datawindow,tile,pic列) *
* 函数用法:datawindow为要转化的数据窗口; *
* tile为数据窗口的标题。 *
* 举例:gf_dw2excel(dw_1,"这是我们的世界") *
* 图片导出功能由乌蒙浪子(17232341)完善 ^-^2017-06-07
***********************************************/

long ll_col,ll_colcount,ll_col_visible,ll_row,ll_rowcount
int li_rtn
string ls_colname,ls_col_title,ls_range,ls_colnum

string ls_colnumd,ls_colnumd1
int ll_colcount1,ll_colcount2

OLEObject lole_excel, lole_sheet ,lole_pic

lole_excel = Create OLEObject

li_rtn = lole_excel.ConnectToNewObject("Excel.Application")
if li_rtn < 0 then
MessageBox("错误提示","您可能没有安装Excel!")
return
end if

SetPointer(HourGlass!)

ll_colcount = long(adw_data.Object.DataWindow.Column.Count)
ll_rowcount = adw_data.RowCount()

lole_excel.Application.Workbooks.add()

lole_excel.Application.Visible = true

lole_sheet = lole_excel.Application.ActiveWorkbook.Worksheets[1]

lole_excel.ActiveSheet.Rows("3:" + string(ll_rowcount + 2) ).Select
lole_excel.Selection.RowHeight = 64

ll_col_visible = 0
for ll_col = 1 to ll_colcount
//得到列标题头的名字(注意标题的命名规则:列名_t)
ls_colname = adw_data.describe('#' + string(ll_col) + ".name") + "_t"
ls_col_title = adw_data.describe(ls_colname + ".text")
if ls_col_title <> "!" then
//将数据写到EXECL
ll_col_visible ++
lole_sheet.cells[2,ll_col_visible] = ls_col_title
ls_colname = left(ls_colname,len(ls_colname) - 2)
if ls_colname = as_picCol then
lole_excel.ActiveSheet.Columns(ll_col_visible).ColumnWidth=15
end if

for ll_row = 1 to ll_rowcount
if ls_colname = as_picCol then

//判断是A、B...或AA、AB...还是BA、BB、BC...
if integer(ll_col_visible) > 26 then

ll_colcount1 = mod(ll_col_visible,26)
ll_colcount2 = ll_col_visible / 26
ls_colnumd = char(ll_colcount1 + 96)
ls_colnumd1 = char(ll_colcount2 + 96)
ls_colnum = "'" + ls_colnumd1 + ls_colnumd + "'"
else
ls_colnum = char(ll_col_visible + 96)

end if

lole_sheet.Application.Range(ls_colnum + string(ll_row + 2)).Select
lole_pic = lole_sheet.Application.ActiveSheet.Pictures.Insert( adw_data.Describe("Evaluate('LookupDisplay(" + ls_colname + ")'," + string(ll_row) + ")") )
lole_pic.Width = lo

le_sheet.Application.Range(ls_colnum + string(ll_row + 2)).Width
lole_pic.Height = lole_sheet.Application.Range(ls_colnum + string(ll_row + 2)).Height
else
lole_sheet.cells[ll_row + 2,ll_col_visible] = adw_data.Describe("Evaluate('LookupDisplay(" + ls_colname + ")'," + string(ll_row) + ")")
end if





next
end if
next

//判断是A、B...或AA、AB...还是BA、BB、BC...
if integer(ll_col_visible) > 26 then

ll_colcount1 = mod(ll_col_visible,26)
ll_colcount2 = ll_col_visible / 26
ls_colnumd = char(ll_colcount1 + 96)
ls_colnumd1 = char(ll_colcount2 + 96)
ls_colnum = "'" + ls_colnumd1 + ls_colnumd + "'"
else
ls_colnum = char(ll_col_visible + 96)
end if



// lole_sheet.Application.Range("e10").Select
// lole_pic = lole_sheet.Application.ActiveSheet.Pictures.Insert("C:\Documents and Settings\All Users\Documents\My Pictures\示例图片\Sunset.jpg")
// lole_pic.Width = lole_sheet.Application.Range("e10").Width
// lole_pic.Height = lole_sheet.Application.Range("e10").Height

lole_sheet.cells[1,1] = as_title
lole_sheet.cells[1,1].HorizontalAlignment = 3
lole_sheet.cells[1,1].VerticalAlignment = 3
lole_sheet.cells[1,1].Font.Size = 20
//合并单元格
if ll_col_visible > 1 then
lole_sheet.range("a1:" + ls_colnum + "1").Merge()
end if
//画表格线
if ll_col_visible > 1 then
ls_range = "A2:" + ls_colnum + Trim(string(ll_rowcount + 2))
lole_sheet.range(ls_range).borders(1).linestyle = 1
lole_sheet.range(ls_range).borders(2).linestyle = 1
lole_sheet.range(ls_range).borders(3).linestyle = 1
lole_sheet.range(ls_range).borders(4).linestyle = 1
end if

lole_excel.Application.ActiveWorkbook.saved = false

lole_excel.DisConnectObject()
Destroy lole_excel

SetPointer(Arrow!)

相关文档
最新文档