Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Publishing a report to htm page on a local desktop

Status
Not open for further replies.

multigroet

Technical User
May 2, 2003
1
NL
Hi Paradox developers,

Can someone give me a tip to export a report to htm-page on a desktop? When I use File- Publish As - HTML and Next - Next -, I get the button Browse. As soon as I put here a full path of directory or an Alias, then I get error message. "An error occured while trying to publish the HTML document". I prefer to export in ObjectPal.
Thanks for your help.
Adem
multigroet@hotmail.com
 
Adem,

According to the documentation, the following is supposed to work:

Code:
var
   rpt  Report
endVar

   rpt.open( ":work:customer" )
   rpt.PublishTo( "c:\\htmldemo.html", publishToHTML )
   rpt.close()

Unfortunately, this doesn't work in any version of Paradox I've tested (through v10 SP3).

There are two workarounds. Here's one:

Code:
var
   rpt  Report
endVar

   rpt.open( ":work:customer" )
   rpt.menuAction( MenuWriteAsHTML )
   rpt.close()

This launches the Report HTML Expert and forces your users to fill in the details of the conversion process. As soon as they hit the Finish button, the report gets published accordingly.

An alternate approach involves using the HTMLIB01.LDL that the Expert uses. While the PDXINET.HLP cliams to document the methods and types you'll need to use, the Help file has not been updated since Paradox 8 was released. It's out of date.

Depending on the version of Paradox you're using, you may be able to use the documentation as written or you might need to fiddle with things a bit.

In any event, I've managed to successfully use HTMLIB01 in a Paradox 10 application. Here's how I did it:

Step 1. Create a custom method called ReportPublish() that accepts the name of the report to publish and the name of the resulting HTML file. I called mine ReportPublish; here's what it looks like:

Code:
type
   _HTMLReport = record
      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 these if you're using Paradox 10
      lServlet      Logical ; Unknown (Undocumented)
      lDocHyperlink Logical ; Unknown (Undocumented)
      strPublishAs  String  ; Unknown (Undocumented)
   endRecord
endType

uses ObjectPAL
   HTMLPublish_Report( var rSource Report,
                       var HTMLReport _HTMLReport ) Logical
   _LaunchBrowser( strFileName String, lWait Logical ) Logical
endUses

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


   ; Next, we have to open the HTMLIB01.LDL library.  If that
   ; fails, 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, we need to initialize the fields of the publishing
   ; information record.
   _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

   ; Make sure the report gets closed.
   try
      rptWebPub.close()
   onFail
      ; do nothing as the report is already closed.
   endtry

   ; Make sure the library gets closed and its memory gets
   ; released.
   If libWebPub.isAssigned() then
      libWebPub.close()
   endIf

endMethod

Step 2: Call your reportPublish routine from a pushButton(), run(), or similar event. For example:

Code:
method run(var eventInfo Event)

   reportPublish( ":work:customer", 
                  "c:\\htmldemo.html" )

endMethod

Now, I'm not certain if the same code will work under Paradox 9, but I expect it'll be close.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top