Thanks for the help first of all !!!, but there is an error in my program when i was trying to read the data from the excel file and the error was"The remote procedure call failed. in OpenXL_Workbook.vi->Get Excel Values.vi"
I think this error generates bcoz of my file is in the text format with the delimited tabs, and the program is for .xls extension but not any other types, so is there any solutions for that??? i want it urgent.
If you are using tab-delimited text files rather than Excel files, then you can just use a VI in the LabVIEW File I/O palette called Read from Spreadsheet File.vi. Just click the search button and type spreadsheet if you have problems finding it. There's no need to automate Excel to read a plain old text file. Keep in mind: automating Excel is SLOW (all things considered 😉 ).
Hi Jarrod S
This is exactly what I want to know. I'm a bit behind the times using 7.0. Can you explain the data type of a range? I want to read just one part of the excel spreadsheet and I don't know how to specify the range. This gem is hidden in your no doubt excellent program.
Please look at the LV example called Write Table to XL. It demonstrates how to write a tabel of data to a worksheet by addressing individual cells. Just convert the Range_>Value2 write to read and you can get the data from the cell. The Value returned is a variant,so you need to convert to either a string or a double, depending on your data type with the Variant To Data.vi.
If you want to address specific cells there are 3 choices for specifying a Range. 1) Use the example VI to convert Row and Column to the A1 format. 2) Specify the A1 format using string formatting (watch out for Z, AA) or 3) Use a Named Range. By defining a specific name to represent a cell or group of cells, you can bypass the string formatting altogether.
The VBA code for reading the cell is Result = Application.Sheets(1).Range("MyCell").Value2
Message Edited by Jarrod S. on 06-27-2007 12:20 PM
First at all, I would like to thank Jarrod for the GetExcelValues.llb because it has been really useful for the program I am trying to develop.
However, now I have a problem with this software: when I try to read dates from Excel files, instead of get a string (like 2-Sep or 9/02/2008) I get a number. What I have seen (I don't know too much about Excel), it seems like Excel uses a kind of mask so you can see the date in a normal way (2-Sep) but actually it is saving a number. This is the number that I get. Nevertheless, what I would like to have is the string of the date.
So far, I am using the following blocks: the VI, Get Excel Values (modified to received just one string), a string control (which lets me see that the read data is the number associated to the string). After that, and following MikeS81's advice, I have put the variant to data function, and after that another string control. So both string controls show me the same result.
I suppose that problem is that I don't have anything in the "type" input, but I don't know what I have to put. Watching the examples of Jarrod's library, I should use ActiveXclass (or something like that).What exactaly do I have to do?Create a class (activex) with the convertion (number to data string) or is something simpler (I hope so).
If I had to create a Active X class, could somebody tell me:
1-.How to do it?
2-.What the formule that I have to use to convert data form a number to a date string.
Thank you very much
Yes. Dates in Excel are just a number. The formatting of the field is how it shows up as a meaningful data to you when you view it in Excel. The number is the number of days since 1/1/1900.
LabVIEW dates are also inherently a number. They are the number of seconds since 1/1/1904. Search the forums for lots of different examples on how to convert.