LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Formatting Question

Solved!
Go to solution

I have looked at some examples of formatting the cells in Excel, and they have a "range" input which I do not know how to generate or where it comes from. I would like to do something like make the font bolded from cells A4:D4. I want to play with the color and column widths, but I think I can figure that out if I know where these inputs come from and how to tell a property node which file to operate upon. Thanks,

Gregory

0 Kudos
Message 1 of 8
(3,288 Views)
Solution
Accepted by topic author gjacob

A Range object refers to a range of cells. It is one of the classes in the Excel object model. You can create a Range object in several ways. One way is to simply use the Range method of a Worksheet object. If you look at the "Write Table to XL" example that ships with LabVIEW there's a subVI called "Set Cell Value". That shows you how a Range object is created so that its value can be set. In this case the Range is one cell, but the Range can be multiple cells. Some of the properties for a Range are themselves other objects. For instance, to set a bold font you need to write to the "Font" property of a Range object. The "Font" property is itself another class (Excel.Font).

 

All of the above is standard ActiveX (nothing to do with LabVIEW), so you basically need to understand ActiveX programming. With respect to Excel, there have been numerous examples posted to do various things, and the community has created the Excel thread to collect links to examples. You should peruse that thread to get links to all sorts of examples. NOTE: Do not post a question in that thread - it is a repository of links only. 

Message 2 of 8
(3,273 Views)
Do you know which examples folder to look in?
0 Kudos
Message 3 of 8
(3,271 Views)
The example that I was referring to can be found by simply searching the examples. Help -> Find Examples, then switch to the search tab, and enter "excel" in the search text.
Message 4 of 8
(3,262 Views)
After playing around for a bit, I amended the macro running example to look like the picture. If you have a lot of excel spreadsheets that are going to be formatted the same, you can connect those to the 'new spreadsheet' input. In my case, the new spreadsheet comes from a VI that acquires data, all of which I want to have a similarly formatted spreadsheet. You will have to save one of the spreadsheets, and create the macro that you want to use to format it, the datapath of this goes into the macro containing spreadsheet spot. The name of the macro containing spreadsheet goes between the single quotes and the name of the macro goes after the exclamation mark in the macro input.
0 Kudos
Message 5 of 8
(3,216 Views)
Why are you opening two instances of Excel? You only need one. Excel is an MDI application.
0 Kudos
Message 6 of 8
(3,211 Views)
Ah, I don't know what MDI is, but thank you, I will change that.
0 Kudos
Message 7 of 8
(3,208 Views)
MDI. Smiley Wink
Message 8 of 8
(3,205 Views)