利用OWC空间做Web报表以及打印
这里只说打印
sub printexcel()
on error resume next
parent.parent.BodyFrame.Form1.excelData.Export "c:\tempreport.htm", 0, 2
set xlApp = CreateObject("EXCEL.Application")
xlApp.Workbooks.Open("c:\tempreport.htm")
str = parent.parent.BodyFrame.Form1.printset.value
str = split(str,"|")
for t = lbound(str) to ubound(str)
j = InStr(str(t),"=")
attr = left(str(t),j-1)
aval = right(str(t),len(str(t))-j)
if (aval <> "") then
if (attr = "PagerSize") then
xlApp.ActiveSheet.PageSetup.PaperSize = aval
elseif (attr = "Orientation") then
xlApp.ActiveSheet.PageSetup.Orientation = aval
elseif (attr = "LeftMargin") then
xlApp.ActiveSheet.PageSetup.LeftMargin = aval/0.035
elseif (attr = "RightMargin") then
xlApp.ActiveSheet.PageSetup.RightMargin = aval/0.035
elseif (attr = "TopMargin") then
xlApp.ActiveSheet.PageSetup.TopMargin = aval/0.035
elseif (attr = "BottomMargin") then
xlApp.ActiveSheet.PageSetup.BottomMargin = aval/0.035
elseif (attr = "HeaderMargin") then
xlApp.ActiveSheet.PageSetup.HeaderMargin = aval/0.035
elseif (attr = "FooterMargin") then
xlApp.ActiveSheet.PageSetup.FooterMargin = aval/0.035
end if
end if
Next
xlApp.Workbooks(1).Save
if (pv=1) then
xlApp.Visible = true
xlApp.Range(parent.parent.BodyFrame.Form1.excelData.ActiveWindow.ViewableRange).PrintPreview
else
xlApp.Range(parent.parent.BodyFrame.Form1.excelData.ActiveWindow.ViewableRange).PrintOut
end if
xlApp.Quit
'Set fs = CreateObject("Scripting.FileSystemObject")
'if fs.FileExists("c:\tempreport.htm") then
' fs.DeleteFile "c:\tempreport.htm",True
'end if
end sub
sub printpreview()
pv=1
call printexcel()
end sub
sub printout()
pv=0
call printexcel()
end sub
意思还是利用Excel来打印
sub printexcel()
on error resume next
parent.parent.BodyFrame.Form1.excelData.Export "c:\tempreport.htm", 0, 2
set xlApp = CreateObject("EXCEL.Application")
xlApp.Workbooks.Open("c:\tempreport.htm")
str = parent.parent.BodyFrame.Form1.printset.value
str = split(str,"|")
for t = lbound(str) to ubound(str)
j = InStr(str(t),"=")
attr = left(str(t),j-1)
aval = right(str(t),len(str(t))-j)
if (aval <> "") then
if (attr = "PagerSize") then
xlApp.ActiveSheet.PageSetup.PaperSize = aval
elseif (attr = "Orientation") then
xlApp.ActiveSheet.PageSetup.Orientation = aval
elseif (attr = "LeftMargin") then
xlApp.ActiveSheet.PageSetup.LeftMargin = aval/0.035
elseif (attr = "RightMargin") then
xlApp.ActiveSheet.PageSetup.RightMargin = aval/0.035
elseif (attr = "TopMargin") then
xlApp.ActiveSheet.PageSetup.TopMargin = aval/0.035
elseif (attr = "BottomMargin") then
xlApp.ActiveSheet.PageSetup.BottomMargin = aval/0.035
elseif (attr = "HeaderMargin") then
xlApp.ActiveSheet.PageSetup.HeaderMargin = aval/0.035
elseif (attr = "FooterMargin") then
xlApp.ActiveSheet.PageSetup.FooterMargin = aval/0.035
end if
end if
Next
xlApp.Workbooks(1).Save
if (pv=1) then
xlApp.Visible = true
xlApp.Range(parent.parent.BodyFrame.Form1.excelData.ActiveWindow.ViewableRange).PrintPreview
else
xlApp.Range(parent.parent.BodyFrame.Form1.excelData.ActiveWindow.ViewableRange).PrintOut
end if
xlApp.Quit
'Set fs = CreateObject("Scripting.FileSystemObject")
'if fs.FileExists("c:\tempreport.htm") then
' fs.DeleteFile "c:\tempreport.htm",True
'end if
end sub
sub printpreview()
pv=1
call printexcel()
end sub
sub printout()
pv=0
call printexcel()
end sub
意思还是利用Excel来打印

浙公网安备 33010602011771号