NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to print an html report?

In a Test UUT's execution, the process model generates and saves a html report. How can add steps to the process model to print the report each time? I'm thinking maybe somehow using an ActiveX call to open IE and then print (1 step or 2?), but I'm a newbie to ActiveX and don't know what server/class/method to use.
==============================================

0 Kudos
Message 1 of 7
(4,831 Views)
Hello!
You have two problems
1, Change the process model to generate report results each time to the report, for that there is an example in teststand catalog "OnTheFlyReports". Look in that to change the process model.
2, Print the report on the screen.
I started to create a activex container in LW and printed the report in it but i didn't manage to scroll down the window to the last printed step.
So I enable the "Launch Report Viewer" button in the operator interface. That means that teststand opens your IE and shows the report so far.

If you need any more help or examples code let me know.
Andreas
0 Kudos
Message 2 of 7
(4,831 Views)
Actually, I wound up answering my own question last night. What I did was after the process model saves the UUT report, I open up MS Word (Word can automatically read/convert the html file), load the file, background print and then quit Word. The Set_Appplication.Visible property of the Word ActiveX call is set to false so the operator never sees Word open up. The sequence I developed is attached for anyone interested. Use it as a sequence callback in the process model and call it sometime AFTER the process model saves the report. The sequence call should pass the parameter "Parameters.TestSocket.ReportFilePath" to the sequence callback parameter "ReportFilePath".

For anyone interested in the LabView solution, that's attached as well.
==============================================

Download All
0 Kudos
Message 3 of 7
(4,831 Views)
Using Microsoft Word could be a good solution if you actually have it installed in the computer. In some cases, you may not want to have that application installed in the production floor for any reason (licenses, memory space...).
I am attaching an example that shows how to print the report automatically after testing a UUT using ActiveX to communicate with Internet Explorer. It is more likely that any machine would have this application installed since it occupies a lot less memory space and it ships with any Windows OS. Furthermore, there are just 3 steps that do the trick!
The attached zip file contains a modified sequential model. The entry points ("Single Step" and “Test UUTs”) have one new step that calls the "Print Report" sequence (also added to the sequential model). This new sequence has ActiveX steps that call two methods of the “Internet Explorer (IwebBrowser2)”object class exported by the “Microsoft Internet Controls” automation server. These two methods are:
1) Navigate. Allows you to select the html file to load.
2) ExecWB with the first parameter (cmdid) set to "OLECMDID_PRINT" (prints the loaded file) and the second parameter (cmdexecopt) set to OLECMDEXECOPT_DONTPROMPTUSER" (don’t show the print dialog).
(For more information about these methods, please refer to the MSDN Library)

The example will print the report after each UUT is tested. The "Print Report" step is set to run just if the Report Generation is not disabled (see its preconditions).

This is what you need to do to run the example:
1) Copy the contents of the zip file to: \Components\User\Models\TestStandModels
2) Make sure that the “User Components Directoty” is checked in the Search Directories.
3) Run any sequence using Single Pass or Test UUTs.

WARNING: There is a known issue when using the printing capabilities of the Internet Explorer. This is what is explained in the MSDN library:
"... Internet Explorer prints in the background. This means that the print processing is actually completed asynchronously in a separate thread.Upon return from ExecWB, the print processing may continue for several seconds or even up to a minute or two based on various factors such as the size of the content and how busy your system is currently. The problem is that if you start a print job and then destroy the WebBrowser or close your application before the background thread finishes processing, the thread will abandon its work and the page may not be completely printed..."

There are 2 approaches to work around this problem:
1) Use a delay before destroying the WebBrowser reference (which is done in the cleanup step group of the "Print Report" sequence in the example). This is the approached used in the example. The third step in the “Print Report” sequence is a Wait step. The step is currently set to wait for 3 seconds which has worked for me for almost any report sizes.

2)In Internet Explorer 5 you can work around this problem by sinking the OnAfterPrint event. If you have started a print job, then you should wait to release the WebBrowser until after this event has been received. If you choose this approach you could use the ActiveX events capabilities of Labview or Visual Basic to create a small program detecting this event. There's a simple sample code provided in the MSDN library for VB.

Enjoy!
0 Kudos
Message 4 of 7
(4,831 Views)
Another approach is the one I took. When asked to always print the reports, I instead prefixed the UUT's serial number to the report and wrote them to a server. A simple web page that everyone bookmarks, asks for a serial number and then displays the report. The next version eliminates the report file and instead reads the database and displays the results in the same format as the html report generator. I saved a lot of trees and the time it takes to do the printing.
0 Kudos
Message 5 of 7
(4,831 Views)

Denis I like your approach here.  I'm not a developer, but I need the ability to review test data and print reports for specific serial numbers.

Was this tool home brewed or is it allready avialable?

 

-Michael

0 Kudos
Message 6 of 7
(4,104 Views)
That's a pretty old thread. Smiley Wink
 
The tool was homegrown and evolved quite a bit over time. Once I was able to integrate the TestStand database into the corporate front end, through the intranet, a database query was done and the results were formatted as html. Stopped saving the report files altogether. Even if I still worked at the same company, it was proprietary. There are some commercial solutions out there, though. One that I've seen mentioned is Arendar.
0 Kudos
Message 7 of 7
(4,094 Views)