Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
What is Developer Zone?
United States

Document TypeTutorial
NI Supported: Yes
Publish Date: Sep 16, 2009


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links -Products and Services

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

12 Ratings | 3.92 out of 5
 Print |  PDF

Overview

This tutorial teaches you how to create and customize a graph in Microsoft Excel. This is the third 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 and second parts of the tutorial teach you how to open Excel, add data to a worksheet, and manipulate that data in Excel using the toolkit. The third part of the tutorial builds on that work to create and customize graphs for better data presentation.

Table of Contents

  1. Retrieve Data from Microsoft Excel
  2. Create a Graph
  3. Use Advanced Graph Options
  4. Continue to the Next Tutorial
  5. Download Example Code

Retrieve Data from Microsoft Excel

In Figure 1, the Lesson 2 VI represents the code developed in the first and second parts of this tutorial, which teach you how to open Excel, add and rename worksheets, add data to a worksheet, and manipulate that data with functions and macros.


Figure 1. Retrieving Data from an Excel Worksheet


Before you can create a graph, you need to have the data values in one array within LabVIEW. Because you added data at two different points in the VI, the easiest way to gather those values into one array is to read them back from the Excel worksheet. Use the Excel Get Data VI to retrieve the data from the worksheet to LabVIEW. This VI reads a large data set after you specify a cell range and expected data type.

Create a Graph


After retrieving the data, create a graph on the worksheet. Excel contains several default graph types you can use to portray the data. In this case, select a line graph with marker points embedded as an object in the worksheet to plot the sample data. Alternatively, you can use the toolkit to create graphs as objects not embedded in a worksheet if you only need to present data visually without accompanying text. As shown in Figure 2, you can use the Excel Easy Graph VI to create a graph of any valid Excel data type and to specify a title and position.


Figure 2. Creating a Graph on an Excel Worksheet


Figure 3 shows the effect of adding the graph through LabVIEW.



Figure 3. Graph Added to a Report in an Excel Worksheet

Use Advanced Graph Options

If you want to customize a graph beyond the options offered in the Excel Chart Wizard, the toolkit includes a full suite of VIs you can use to modify and customize graphs. Figure 4 shows the Excel Set Graph Colors, Set Graph Font, and Set Graph Scale VIs, which adjust the properties of a graph programmatically from LabVIEW.


Figure 4. Customizing the Marker Style, Fonts and Axis’s of an Excel Graph



Figure 5 shows the modified graph included in the final report.



Figure 5. Customized Graph in an Excel Worksheet



These advanced options of the LabVIEW Report Generation Toolkit for Microsoft Office reduce development time and eliminate the need to manually polish the final report.

Continue to the Next Tutorial


The test data and graph in Figure 3 need a title and minor adjustments to fonts and positioning. The final part of this tutorial teaches you how to adjust and customize cells and add a report title to complete the report for final 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 2
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

12 Ratings | 3.92 out of 5
 Print |  PDF

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/).