Creating a Report in Microsoft Excel Using the LabVIEW Report Generation Toolkit: Part 2

Updated Dec 18, 2023



  • LabVIEW Report Generation Toolkit
  • LabVIEW


Microsoft Excel

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, which is included with LabVIEW Professional 2014 and later.

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.

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.

Figure 1. Adding Additional Data to an Excel Worksheet

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 change.

Figure 2. Sorting Each Column of Data Separately

Figure 3 shows the sorted results of the worksheet.

Figure 3. Data Before and After Using Excel Sorting Method


Insert Data and Run Macros

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.

Figure 5. Test Data Sorted and Formatted with a Macro in Excel

Download Example Code

Download the tutorial VIs . Requires LabVIEW 6.0 or later, the LabVIEW Report Generation Toolkit, and Microsoft Office.

Next Steps

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.