全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1042
推到 Plurk!
推到 Facebook!

Printing Reports to HTML

 
conundrum
尊榮會員


發表:893
回覆:1272
積分:643
註冊:2004-01-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-12-15 01:46:33 IP:218.175.xxx.xxx 未訂閱
Printing Reports to HTML http://www.techtricks.com/paradox/rpt2html.php     
   Printing Reports to HTML   
    by Lance Leonard   Posted: 9 July 2003   
       Applies to: Paradox 8 and later   
      Audience: Intermediate   
        
    Question: How do I publish reports to HTML files using ObjectPAL?
Answer: Either start the Report HTML Expert or call the ObjectPAL library that the Expert itself uses. The Expert is easier to implement and lets your users control the publication process while the library lets you control the process; however, it requires more work. This article shows how to handle both tasks.    Launching the Report HTML Expert
Starting the Report HTML Expert is fairly straightforward; simply open the report and then trigger the menu action that launches the Expert, as shown in the following code sample.    method pushButton(var eventInfo Event)
var
   rpt  Report
endVar
   rpt.open( ":work:customer" )
   rpt.menuAction( MenuWriteAsHTML )
   rpt.close()
endMethodThis launches the Report HTML Expert and lets your users control the details of the publication process, including the target filename, background color, and so on.    For more control over the process, use the mechanism the Expert uses. Specifically, call the html_PublishReport method of Paradox Internet Publishing Library (HTMLIB01.LDL).     Corel first released the Paradox Internet Publishing Library with Paradox 8.0 and they've updated it in subsequent versions. Unfortunately, they've not updated the documentation. The following section shows how to use the library in later versions of Paradox.    Using the Internet Publishing Library
This section shows how to use the Paradox Internet Publishing Library to publish reports to HTML documents, regardless of the version you're using. As with any library, some assembly is required.    To demonstrate the basic process, you'll create a script that publishes the sample Customer report provided with most versions of Paradox:    Start by changing the Paradox working directory to the one containing the Paradox sample files.    Create a newscript and then save it as HtmlDemo.ssl.    When the Run window appears, press Ctrl Space to open the Object Explorer.    Choose the Method tab and then open the Type window.    Now, declare the following record type:    type
   _HTMLReport = record
      ; Add these if you're using Paradox 8.0 or later
      strURI        String  ; URI (or output file name)
      strTitle      String  ; Document title
      iBGColor      LongInt ; Background color
      iTextColor    LongInt ; Text color
      mHeader       Memo    ; (filled) Header template
      mTemplate     Memo    ; (filled) Main template
      lStatic       Logical ; Static output? (FALSE = Dynamic)
      lMsg          Logical ; Show status line messages?          ; Add this if you're using Paradox 9, 10, or 11.
      lServlet      Logical ; Undocumented          ; Add these if you're using Paradox 10 or 11.
      lDocHyperlink Logical ; Undocumented
      strPublishAs  String  ; Undocumented
   endRecord
endTypeBe sure to declare the items appropriate for your version of Paradox. If you're using Paradox 8, don't add the lServlet, lDocHyperlink, or strPublishAs items; otherwise, you'll receive errors (described later).    Note:  This is the only step that involves version specific problems. The remaining steps apply to all versions of Paradox released since 8.0.    Next, use the Object Explorer to open the script's Uses window and then add the following prototypes:    uses ObjectPAL
   HTMLPublish_Report( var rSource Report,
                       var HTMLReport _HTMLReport ) Logical
   _LaunchBrowser( strFileName String, lWait Logical ) Logical
endUsesThese describe the routines you'll be calling from the Internet Publishing Library. Note that you need to pass an _HTMLReport variable to the HTMLPublish_Report method.    Next, create a custom method called reportPublish() and then add the following code:    method reportPublish( strRptName String, strSaveAs String ) Logical
var
   rptWebPub  Report          ; The report being published.
   _hrWebPub  _htmlReport     ; Details for the library routine.
   libWebPub  Library         ; Pointer to the publishing library.
   fbiSaveAs  fileBrowserInfo ; Information for Save As dialog.
   loRetval   Logical         ; Value returned to calling proc.
endVar    const
   ERRTITLE = "HTML Publishing Error"  ; title for error dialogs.
endConst       ; If we can't open the library, we cannot continue.
   loRetval = libWebPub.open( expertsDir()   "\\HTMLIB01" )
   If not loRetval then
      errorShow( ERRTITLE, "Reason: Unable to load publishing "  
                           "library; see details..." )
      return loRetval
   endIf       ; Open the report.
   loRetval = rptWebPub.open( strRptName )
   If not loRetval then
      errorShow( ERRTITLE, "Reason: The report failed to "  
                           "open; see details..." )
      return loRetval
   endIf
   rptWebPub.DesignModified = FALSE       ; Now, provide the required details.
   _hrWebPub.strURI       = strSaveAs
   _hrWebPub.strTitle     = rptWebPub.getTitle()
   _hrWebPub.iBGColor     = Black
   _hrWebPub.iTextColor   = White
   _hrWebPub.lStatic      = TRUE
   _hrWebPub.lMsg         = TRUE       ; Try to publish the report.
   loRetval = libWebPub.htmlPublish_Report( rptWebPub, _hrWebPub )
   If not loRetval then
      errorShow( ERRTITLE, "Reason: The publishing routine failed; "  
                           "see details." )
   else
      If msgQuestion( "Report Sucessfully Published",
                      "Your report has been published.  Would "  
                      "you like to view the final file in "  
                      "your Internet browser?" ) = "Yes" then
         If not libWebPub._launchBrowser( _hrWebPub.strURI,
                                          Yes ) then
            errorShow( "Can't Preview HTML", "Reason: The "  
                       "browser failed to launch; see "  
                       "details..." );
         endIf
      endIf
   endIf   ; Close the report and the library.
   try
      rptWebPub.close()
   onFail
      ; do nothing as the report is already closed.
   endtry       If libWebPub.isAssigned() then
      libWebPub.close()
   endIf    endMethodFinally, add the following code to your script's Run() event:    ReportPublish( ":work:customer.rsl", "c:\\report.html" )Save and run your script.    Granted, that's quite a bit of work; however, when finished, you'll have a script that can be easily modified to publish any report to an HTML document.    A sample .ZIP file for this article is available from our Download area. It contains a form that lets you browse for the report to be published. The form also contains two buttons; each illustrates one of the approaches shown above. The .ZIP file also contains a completed version of the script created above.    Troubleshooting
This section lists errors that might occur while you're setting things up and briefly explains the most common solutions.    The specified string identifer is invalid.    This is usually caused by passing an alias in the target filename, e.g. the name of your final HTML document. Use care to pass fully qualified filenames, e.g. ones containing the drive letter, pathname, and file extension.    An error occured trying to access a record structure. An unexpected field number was encountered.    This indicates a problem with your declaration of the _HTMLReport type. The declaration in HTMLIB01.LDL contains different fields and Paradox cannot determine how to handle the differences. Usually, you'll get this when using Paradox 9 or later and relying solely on the documented declaration of _HTMLReport.    To fix the error, refer to Step 5 in the previous walkthrough and correct your declaration of _HTMLReport to match the one appropriate for your version of Paradox.     What about PublishTo()?
If you searched the ObjectPAL Help files while trying to learn how to publish reports to HTML documents, you may have come across the PublishTo() method of the Report class. While the documentation suggests you can use this to publish reports to HTML files, we have not yet found a version of Paradox that supports this.    While the Help topic provides sample code that compiles (e.g. it doesn't raise a syntax error), it simply doesn't work in any version of Paradox we've tested.    This appears to be a bug and the previous approaches are the only known workarounds that do not involve other software applications. (You can, for example, use a word processor to extract data from your Paradox tables and then use that product's publishing features to create HTML documents. In some cases, this may be more desireable.)
 
 
系統時間:2024-06-02 11:47:05
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!