Jason.Yuan

[My Blog,My Repository,My Communication,My Friends,My Success]

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

利用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来打印
posted on 2005-01-27 11:52  Jason's Blog  阅读(1279)  评论(1)    收藏  举报