Creating a Report in Microsoft Excel Using the LabVIEW Report Generation Toolkit: Part 2
Overview
This tutorial teaches you how to manipulate and present data from LabVIEW in Microsoft Excel. This is the second of a four-part tutorial on creating professional reports in Microsoft Excel using LabVIEW and the LabVIEW Report Generation Toolkit for Microsoft Office.
The first part of this tutorial teaches you how to open Excel and add data to an Excel worksheet using the LabVIEW Report Generation Toolkit. The second part of the tutorial builds on that work to append additional data to the report, sort data, and use functions and macros to present test data in an orderly and coherent format.
Table of Contents
- Send Additional Data to Microsoft Excel
- Sort Data with Microsoft Excel
- Insert Data and Run Macros
- Continue to the Next Tutorial
- Download Example Code
Send Additional Data to Microsoft Excel
In Figure 1, the Lesson 1 VI represents the VI you built in the first part of this tutorial, which teaches you how to open Excel, create and rename worksheets, and add data to a worksheet. You can manipulate the data from that VI by adding additional data to the worksheet, sorting the data in Excel, inserting functions across a range of cells, and running a macro function in Excel.
Suppose you initiate a second test on the widget UUT and need to post additional data to the Excel worksheet. Because you need to post only numeric data to the Excel worksheet, you can use the Excel Easy Table VI included with the toolkit. You can use this VI to format and post the data to Excel in one step.
Sort Data with Microsoft Excel
As shown in Figure 2, if you want to sort the data on the worksheet from lowest to highest values, you can use the Excel Sort Data VI to access any of the available sorting methods already found in Excel. This example sorts each column of data separately using a For Loop, which scales the worksheet as testing needs chang
e.

Figure 2. Sorting Each Column of Data Separately
Figure 3 shows the sorted results of the worksheet.
You can use the toolkit to add functions to a range of cells with minimum data entry. Using the Excel Insert Formula VI in Figure 4, the VI enters the formula one time for the cell range B7:B17. If you apply the formula to a range of cells with the same VI, the values automatically update to reflect the new data ranges. You can use the Excel Get Excel Location VI and the Excel Set Excel Location VI to place data at specific locations within an Excel worksheet.

Figure 4. Inserting a Function and Running a Macro
If you already developed data manipulation code in Visual Basic or worksheet formatting instructions in the form of Excel macros, you do not have to redo this work. You can use the toolkit to load Visual Basic modules as macros and to run predefined macros on a worksheet, reusing any existing code already developed in Excel. The previous example uses the Excel Run Macro VI to apply some simple formatting to the data. The final results of this example look similar to Figure 5.
You can more easily interpret the test data presented in Figure 5 using a graph. The next part of this tutorial teaches you how to add a graph to the report and format the graph for better presentation.
See Also:
Creating a Report in Microsoft Excel Using the LabVIEW Report Generation Toolkit: Introduction
Creating a Report in Microsoft Excel Using the LabVIEW Report Generation Toolkit: Part 1
Creating a Report in Microsoft Excel Using the LabVIEW Report Generation Toolkit: Part 3
Creating a Report in Microsoft Excel Using the LabVIEW Report Generation Toolkit: Part 4
Download Example Code
Download the tutorial VIs. Requires LabVIEW 6.0 or later, the LabVIEW Report Generation Toolkit, and Microsoft Office.
Related Links:
Buy the Report Generation Toolkit
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).


