LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

data from query to excel

I'm using SQL to query a database which works fine. Then I want to pass it to excel from within Labview. So intially I just have it reading row by row, column by column to take in data. Well this can take forever with a lot of info from the database. Is there a faster way than just by using for loops to do this?

I guess if it doesn't work, I'll just go back to doing it in excel.
0 Kudos
Message 1 of 10
(4,005 Views)
I guess one thing to make it better would be to take all of the data from the query and make it tab delimited... but I'm not sure how to do that. Then I can just open the file in excel as opposed to writing the data directly to excel. Is that possible?
0 Kudos
Message 2 of 10
(3,993 Views)
I would recommend reading your data from the database into a 2D array and then wiring it into "Write to Spreadsheet File.vi" found on the "file I/O" palette. It will take care of tab-delimiting your data for you. Let me know if this works for you, or if there are some details specific to your application that require an alternate solution.
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 3 of 10
(3,973 Views)
Thanks for the reply. I've got it working now.
0 Kudos
Message 4 of 10
(3,969 Views)
Can this be done if the data from the database are strings instead of numbers? B/c I'm working on that now and have not figured out if it will work.
0 Kudos
Message 5 of 10
(3,963 Views)
You will first have to convert the strings to numerics before wiring the 2D array to the "Write to Spreadsheet File.vi". You can do this with the "Fract/Exp String to Number" function. It will take a string, and 1D array of strings, or a 2D array of strings and convert them all to numbers.
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 6 of 10
(3,955 Views)
But if your strings are not actually representations of numerics, or if you just want to write them to a spreadsheet file without converting to numbers first, you can do it easily by using Array to Spreadsheet String and Write Characters to File (see attached image).



Regards,
John

Message Edited by Johnner on 03-08-2005 11:48 AM

Message 7 of 10
(3,943 Views)
The data returned is actually a mixture of strings and numbers.

One column has characters in it, the others have numbers. So I think this may change both of the above methods. I've tried them both and neither do exactly as I need, but I'll be working on it later so I'll check a different strategy. Maybe I can use Index Array to pull out the character column and replace it into my written file using activeX commands. I'm sure there is some simple way, but I'm new to LabVIEW so I haven't yet learned all the data passing yet.
0 Kudos
Message 8 of 10
(3,935 Views)
Ok, I've got the first problem solved... now a new one. Any ideas why a column of zeros and ones would return from the query as a column of zeros and negative ones? All other columns have the correct values (mixture of all real numbers). This comes straight from the query which have the exact same SQL statement as the query I used to use in Excel when I did all of this in Excel. I'm trying to automate it all with LabVIEW. More info may be needed to help here, but I just wanted to check if any quick info could be found.
0 Kudos
Message 9 of 10
(3,923 Views)
Nevermind... found out the information that was told to me about our database was incorrect. The number is actually a negative one. So scratch that previous question.
0 Kudos
Message 10 of 10
(3,913 Views)