Sunteți pe pagina 1din 2

1/2 www.ni.

com
1.
2.
3.
4.
5.
6.
7.
8.
Creating Professional Reports with the LabVIEW Report Generation Toolkit for Microsoft Office
Publish Date: May 17, 2007
Table of Contents
Overview
Choosing Your Report Format
Basic Report Generation Operations
Advanced Report Generation Operations
Advanced Formatting
Templates
Microsoft Graph
Designing Your Own Functions
1. Overview
Microsoft Word and Microsoft Excel are powerful standard software packages for creating reports. Because of their popularity, some LabVIEW users programmed LabVIEW ActiveX applications to
dynamically control these document packages for generating reports from LabVIEW. The complexity of the ActiveX interface of those packages, however, makes the development of custom
applications difficult. With the LabVIEW Report Generation Toolkit, you no longer have to learn the complex object models of Microsoft Word and Excel to generate a report. The toolkit offers a set
of flexible and easy-to-use functions (VIs) to control these software packages. In addition, the toolkit integrates the new Word and Excel report formats into the existing LabVIEW Report
Generation VIs. If you've used those VIs before, you already know how to use the new functionality.
We integrated the LabVIEW Report Generation Toolkit into the LabVIEW FunctionsReport Generation palette. When you install the toolkit, the installer replaces LabVIEW Report Generation VIs
with a new version that works with Microsoft Word and Excel formats as well as the standard and HTML formats. The toolkit also includes two new subpalettes that give you access to lower-level
Word and Excel-specific functionality.
The high-level VIs from the report generation palette have the same names and connector panes as the existing LabVIEW 6i report generation VIs, which means that if you have developed
applications with the LabVIEW 6i report generation VIs, you can load and run them with the report generation toolkit for Microsoft Office with no or little modifications and take advantage of the
Word and Excel report types without rewriting your application.
2. Choosing Your Report Format
With four reports types from which to choose, how do you know which report type to use?
First, you have to use a format that is compatible with the method you plan to use to publish your reports. If you want to print your reports, you can choose between standard, Word, and Excel
types. If you want to send your reports programmatically via e-mail, you must use Word or Excel. The following table summarizes the relationship between the report types and the distribution
methods.
Also, make sure that the computer you use to read the reports you generated can do so with the appropriate software installed. In addition, if you plan to distribute your report generation
application, you need to take into account the applications installed on the target machine. If the target computer does not have Internet Explorer or Microsoft Office, then you can only use the
standard report type in your distributed application.
Finally, you need to check the level of formatting that you want to apply to your report. The Standard and HTML report types do not provide nearly as many formatting options as the Word and
Excel report types do.
3. Basic Report Generation Operations
You can use all four report types to perform the following operations:
Insert text
Insert tables
Insert front panel images, control images, pictures from files
Insert hyperlink
Specify various layout parameters (margin, orientation, font, headers, footer)
Every report generation program is based on the same model. New Report.vi must be called to specify the report type (standard, HTML, Word, or Excel), and you can then populate the report with
data using the VIs from the report generation function palette. Once you have completed the report, you can print, save, or e-mail it. You must close all the references at the end of the program
with the Dispose Report VI. The following VI, for example, creates a new Word document with the New Report.vi, inserts a title, a table, a picture from a file with Append Text to Report.vi, Append
Table to Report.vi and Append Image to Report.vi, and prints the resulting report with Print Report.vi. All the references are then discarded with Dispose Report.vi.
2/2 www.ni.com
4. Advanced Report Generation Operations
The Word/Excel report format is much more advanced than standard and HTML. With it, you can also insert text, table, pictures, and links, but it offers much more formatting functionalities.
5. Advanced Formatting
With Word and Excel types, you can set a large variety of formatting attributes, such as font, paragraph indentation (Word), shading, and borders. You can also format tables, merge cells of tables
together, and control the row and column dimensions of tables. In other words, use these two types to format your report exactly the way you want and help you produce professional looking
reports.
6. Templates
Generating complex and highly formatted reports is a time-consuming process. The best way to increase productivity is to create a report template containing components that are common to all
reports and placeholders for the data. After you save this template, you can generate reports by opening the report template, inserting data into the placeholders, and displaying, printing, or saving
the resulting report.
Both Word and Excel provide ways to insert placeholders into documents and worksheets and save reusable templates. In Word, the easiest way to define placeholders is to use bookmarks. In
Excel, the easiest way to define placeholders is to use named ranges.
The VIs that can perform insertion tasks all include the Microsoft Office parameters cluster, with which you specify the bookmark or named range from which the insertion must be performed.
7. Microsoft Graph
The Word and Excel-specific VIs palettes contain subpalettes giving access to functions to insert and format Microsoft Graphs into Word and Excel reports. You need to make sure the Microsoft
Graph application is installed before you can use these functions (Microsoft Graph is on the Microsoft Office CD).
The Microsoft Graph application handles a large variety of graph types -- Bar, Column, XY, Line -- and each type is available in numerous styles.
Microsoft Graph is useful if you want to plot a relatively small amount of data. You have to be aware that when you insert a Microsoft Graph into the document, the data becomes part of the report
(each graph has a data sheet associated with it which contains the data plotted on the graph). Do not use Microsoft Graph to plot a waveform with one million sample points. If you want to plot a
large amount of data, use a LabVIEW graph to display the data on a front panel, and the Append Control Image to Report.vi to insert the graph picture into your report.
Microsoft graphs have a very large number of attributes. The toolkit does not expose all of them. If you need to format the graph in a very specific way, you can create a template, insert an empty
Microsoft Graph in the template and format the graph as needed. You can then call Word Update Graph.vi or Excel Update Graph.vi to send data into the template during the report generation
process.
8. Designing Your Own Functions
The report generation toolkit also contains functions that you can use to execute Visual Basic Applications (VBA) macros from LabVIEW. You can use this feature to customize the toolkit. If you
need to implement a functionality that is not part of the toolkit, you can write it as VBA macro and call the VBA macro from LabVIEW. You can import the code containing the macro manually in
your template, or import it dynamically into the document or spreadsheet.
Related Links:
LabVIEW Report Generation Toolkit for Microsoft Office
Creating a Report in Microsoft Excel Using the LabVIEW Report Generation Toolkit: Introduction

S-ar putea să vă placă și