This action might not be possible to undo. Are you sure you want to continue?
Bridging the Gap Between LabVIEW and Excel
Using the XL-VIEW Toolkit
by Eric Mallett
How often has your customer or manager requested presentation quality graphs and data tables from your LabVIEW applications? LabVIEW, though brilliant in other ways, has limited capabilities for generating formatted output, making it difficult to create data presentations which meet a customer or manager’s expectations.
For comparison, let’s examine a simple quality checking and reporting data acquisition program. The block diagram shown in Figure 1 outputs a plain page of numbers or a text file that is really quite basic . Your customer now has the data, but not in a very useful format, unless you first import the file into Excel and then format it. Reformatting an
your customer’s satisfaction. By replacing the Write to Spreadsheet VIs with a few simple Excel communication VIs, your data will look more professional (see Figure 3b). Often, the data is not simply composed of numeric data. How frequently do you need a column representing time
Figure 1: Writing ASCII data files
Up until now, a typical method for generating formatted output was to save simple tab-delimited ASCII text files, and later import those files into Excel to manually create formatted data tables and graphs. There is a new toolkit available which will cut out this extra step and have your LabVIEW programs talk directly to Excel using ActiveX. The new toolkit, XL-VIEW, allows you to bridge the gap between LabVIEW and Excel, giving you the best of both worlds. This modular package of VIs allows your programs to create formatted data tables and graphs ready for use by your manager or customer. XL-VIEW lets you easily take advantage of the data formatting power of Excel from within LabVIEW.
imported text file in Excel can be time consuming, especially since Excel tends to break up header information.
Writing Formatted Excel Files from LabVIEW The block diagram shown in Figure 2 illustrates how to output formatted data more efficiently by eliminating the text file writing VIs and sending your data directly to Excel. The new toolkit of VIs called XL-VIEW makes it easy to automate this process. Adding borders, bold or italic fonts, or even some color and data alignment will make the table easier to read. Yes, the program has grown Figure 2: Writing Excel files using XL-VIEW (see Figure 3a), but so has
occurrences? The data formatting VI reformats the first column to reflect the time of day. You will also want to format the rest of the data table. Additionally, the formatting VIs give you access to Excel’s “format>>cells” pull-down menu of data type formatting options. The Name Sheet.vi assigns meaningful names to each work or chart sheet.
LabVIEW Technical Resource • Volume 7, Number 2 • www.ltrpub.com
too.vi. There is no need to open Excel.1. create a hard copy of the table and graph. you can format the legend. you’ll want to format the output pages. the Print.LabVIEW Technical Resource – tools and techniques ™ Figure 3a: Using XL-VIEW to format an Excel data Table Creating Excel Graphs from LabVIEW Graphs enhance the look of a data presentation.vi in XL-VIEW will print the graph and data for you directly from within your LabVIEW program. Before your program directs Excel to print. Printing Excel Output from LabVIEW Now that your data is presentable and stored in a form specifically created for data manipulation. page numbers. you have that flexibility. you still need to Figure 3b: XL-VIEW format results can apply descriptive headers and footers. If you only need to build a simple graph. Using XL-VIEW. Number 2 • LabVIEW Technical Resource . however. Having full access to the Graph Wizard allows you to label axes. your application Figure 4b: XL-VIEW graph results www. use XL-VIEW’s Easy Graph. However. legend. graph title and much more (see Figure 4a and 4b). plot area. The XL-VIEW VIs allow you to take full Additionally. if you want direct control over the Excel Graph Wizard steps. We’ve seen great improvements in LabVIEW’s printing abilities with the release of 5. the date. title and other advanced Excel Graph Wizard features Voltage Drop advantage of Excel’s graphing capabilities from within your LabVIEW programs.com • Volume 7. and can also Figure 4a: Using XL-VIEW to format graph axes.ltrpub. Excel is currently more powerful in this area. making it easier to comprehend. apply gridlines and modify scaling.
com . read the entire data table. then you now have control over it from LabVIEW. then average and write the results at the end of ™ Figure 5: Controlling Excel’s page setup and printing scale your print-out and adjust the margins as shown in Figure 5. a better solution is to store your data in Excel and take advantage of its calculation abilities.LabVIEW Technical Resource – tools and techniques Using Excel Formulas in LabVIEW Output Files Have you ever needed to make calculations on a table similar to the previous example shown in Figure 3b on page 15? What if your customer wants to know the average voltage measured per quarter-hour during the shift? How would you determine this? If you are using a text file. calculate average values. Write the observed voltages using the XL-VIEW VIs. use the Logic. If you also need to know if the average was greater than normal. The formula can even be written to another worksheet. Figure 6 demonstrates how to solve this problem using XL-VIEW. then use XL-VIEW’s equation building VIs to construct the averaging formula and write to whichever cell you wish. as shown previously. Number 2 • www. and write the results. and at the end of the shift.ltrpub. However. The first option is to sum and store the numbers of each measurement determined throughout the shift. Both are workable solutions if the data sets are small. The second option is to write the voltage measurements to file during each interval. If it is part of Excel’s Page Setup process. Comparison and IF Statement VIs to construct an Excel formula and Figure 7: Example results using the XL-VIEW toolkit LabVIEW Technical Resource • Volume 7. you have two options. Figure 6: Writing three averaging equations and three IF statements Voltage Drop the shift.
Using row-column format allows you to write the same equation to multiple cells and to increment the cells within the equation. Not only does this toolkit expand LabVIEW’s data output formatting abilities. If the data were saved in Excel. this toolkit makes LabVIEW much more attractive to Measure users considering an upgrade to LabVIEW. All equation building VIs have inputs for both the A1 and row-column formats. what is really of interest are calculations made from a portion of the data set and how changes to one or more specific values alter the results of these calculations. and then recalculate the overall mean. and you have direct access to the information stored in these locations. A demo of the XL-VIEW toolkit for Windows NT/98/95 users is included on this issue’s LTR resource disk. nor can you read. since any templates they have created can now be accessed with ease. Compare the report you were able to create programmatically with the XL-VIEW toolkit (see Figure 7) and the text file you produced without it (see Figure 1) to see the ease of using XL-VIEW to automate the task. The cell is specified by the Using Excel Calculations to Access and Maintain LabVIEW Data Many applications require maintenance of a large data set. use the array functions to replace the value of interest. This concept was information within these cells. About the author: SQUARE ROOT Figure 8: Building a formula in A1 Format row and column numbers.aol. the toolkit is only available for Windows NT/98/95 users. for example. You want to change the value in row 51 and column 10. Notice how the B4 term is added. and Mathematics VIs provide the flexibility to construct any formula that can be created when working in Excel. Additionally. Number 2 • LabVIEW Technical Resource . you need only read a single cell of data after making the needed changes. Because the XL-VIEW VIs use the ActiveX technology. Constructing Excel Equations in LabVIEW Output Files XL-VIEW’s Logic. you would read the entire data set. not by the string “B4”. Comparison. you could still add the equation at any time to the data set using the XL-VIEW VIs. let’s construct the equation The block diagram shown in Figure 8 does this quite easily. Simply open the existing data set. With a text data file. however. www. Even if the equation had not been setup previously. If you have been able to change individual values in a text file from LabVIEW. the middle 200 observations from the fifteenth column of data without significant effort. About XL-VIEW The XL-VIEW toolkit generates formatted LabVIEW output by having your LabVIEW programs talk directly to Excel using ActiveX. calculate the overall mean. This is possible because when you created the data set. column 10) and read the overall mean from cell CV101 (row 101. XL-VIEW can be obtained from E & L Software Solutions either online at members. You can create a pie chart with the graph VIs just as you did with the data table. You cannot easily read or write a specific value from an ASCII file. column 100). specify the sheet and range of cells you are interested in.LabVIEW Technical Resource – tools and techniques ™ include the answer as part of the data table. Consider the example of a 100 row by 100 column data set.com • Volume 7. With an Excel data file. However. you wrote the equation “sum(A1:CV100)” to cell CV101. Using text files to perform these tasks in LabVIEW is very difficult. illustrated previously in Figure 6. and rewrite the entire data file. the developers of the XL-VIEW toolkit.ltrpub. A pie chart of the averages would clearly indicate which voltage is highest. Eric Mallett is President of E&L Software Solutions. then your LabVIEW program can easily access the data using XL-VIEW. you write the new value to cell J51 (row 51.com/ELSSsales or by telephone at 480-807-3873 (country code 01). The power of this capability becomes even more evident when you need to determine the effects of changing if you had been maintaining this data set within Excel and written the equations to perform the calculations. For example. recalculating values of interest still requires you to read the entire data set. Only one VI is required to send your equations from LabVIEW to the cell or group of cells you choose.
INTL.the only labview subscription with vi software included order form Company ____________________________________ WHAT IS LTR? LabVIEW Technical Resource (LTR) is a quarterly journal for LabVIEW users and developers available by subscription from LTR Publishing. OR send the completed order form with U. BANK ONLY* – Make check payable to LTR Publishing) (Texas residents please add 8. and timesaving tips and techniques address everyday programming issues in LabVIEW. Central Expressway. Copyright © 1999 LTR Publishing. 6060 N.ltrpub. Only) / P. To subscribe to the LabVIEW Technical Resource or to order the CD-ROM Library of Back Issues.com to download a free sample issue.25% TOTAL payment information PAYMENT METHOD Check enclosed (U.0 and browse this searchable CD-ROM for easy access to over 150 articles and VIs from LTR Vol I-VI. LTR Publishing.0 (20 issues / over 150 VIs) $325 Upgrade CD toVersion 2. Inc.S.Texas 75206 You may also include your own Federal Express or Airborne #. T E L : 214 . Suite 502.com] $89 $25 SUBTOTAL Download sample issue at www.S.S.S. Inc. in-depth tutorials. Inc. EXTENDED PRICE 1 year subscription (4 issues / 4 diskettes) 2 year subscription (8 issues / 8 diskettes) $95 $175 $120 $215 $350 $99 $30 CD library of back issues Ver 2.O. Dallas. Technical articles on LabVIEW programming methodology.0 5 0 6 contact information Name _______________________________________________ Address_____________________________________________________________________________________________ City ___________________________ State______________________ Zip/Post Code__________ Country____________ Tel (required) ______________________ FAX ______________________ E-mail ____________________________________ order information QTY WIN/MAC PRODUCT U. Inc.ltrpub. All rights reserved. number required Visa / MC Card Number Signature * Wire information available for international orders Fill out the form above and Fax it to: 214-706-0506 with your credit card information and signature.ltrpub. LabVIEW is a registered trademark of National Instruments Corporation. In its seventh year of publication. lt r p u b .0 (requires version 1.7 0 6 .7 0 6 . LabVIEW Technical Resource is an independently produced publication of LTR Publishing. c o m .0 5 8 7 FA X : 2 1 4 . Each LTR issue presents powerful LabVIEW tips and techniques and includes a resource disk packed with VI source code. utilities. and documentation. check to: Exp.0) Back issues – [Article Index available at www.25% sales tax) Bill company (U. w w w . please include Texas Sales Tax at 8.com TX TAX @ 8. If you are ordering a product for delivery within Texas. Purchase the LabVIEW Technical Resource CD-ROM Library of Back Issues Version 2.25%. LTR has subscribers in over 45 countries and is well-known as a leading independent source of LabVIEW-specific information.. fax this form to LTR Publishing at (214) 706-0506 or visit the LTR web page at www.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.