홈 · 개발 참고자료

개발 참고자료

[파워빌더] dw를 보이는 그대로 excel파일로 저장하기 HTML로 저장후 변환

작성자
왕희복
작성일
2016-07-14
조회
11088
분류
파워빌더
dw를 saveas 하여 HTMLTable!로 저장한후
OLE를 이용하여 html 파일을 Excel native format 으로 저장하는 방법입니다.

// ... Init docname
// ... GetFileOpenName or any other method

if dw_1.SaveAs(docname, HTMLTable!, True) = -1 then
MessageBox("Warning", "Unable to export data. Error writing to file!", Exclamation!)
return
end if

// Convert HTML file to Excel native format
OLEObject excel
excel = CREATE OLEObject
if excel.ConnectToObject(docname) = 0 then
excel.application.DisplayAlerts = FALSE
excel.application.workbooks(1).Parent.Windows(excel.application.workbooks(1).Name).Visible = True
excel.application.workbooks(1).saveas(docname, 39)
excel.application.workbooks(1).close()
end if

DESTROY excel
// done