Need help with retrieving Excel WorkSheet List

This is a discussion on Need help with retrieving Excel WorkSheet List within the labview forums in Programming Languages category; My goal is to be able to read an excel file without opening and closing the excel application,  Not sure if this is possible...   I have looked at many of the excel examples but have had no luck retrieving an array list of the available worksheets in an excel spreadsheet.   Any help would be aprreciated.   Thanks Tim C.   I have attached one of my attempts XCEL 2005.zip: http://forums.ni.com/attachments/ni/170/338565/1/XCEL 2005.zip...

Go Back   Application Development Forum > Programming Languages > labview

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-08-2008, 10:10 AM
Tim C.
Guest
 
Default Need help with retrieving Excel WorkSheet List

My goal is to be able to read an excel file without opening and closing the excel application,  Not sure if this is possible...
 
I have looked at many of the excel examples but have had no luck retrieving an array list of the available worksheets in an excel spreadsheet.
 
Any help would be aprreciated.
 
Thanks
Tim C.
 
I have attached one of my attempts


XCEL 2005.zip:
http://forums.ni.com/attachments/ni/170/338565/1/XCEL 2005.zip
Reply With Quote
  #2  
Old 07-08-2008, 10:40 AM
MikeS81
Guest
 
Default Re: Need help with retrieving Excel WorkSheet List

Hi Tim,
what do you mean, without opening and closeing the excel applciation? Your example use&nbsp;ActiveX functions and they open and close excel.Maybe this helps: <a href="http://forums.ni.com/ni/board/message?board.id=170&amp;view=by_date_ascending&am p;message.id=332299#M332299" target="_blank">http://forums.ni.com/ni/board/message?board.id=170&amp;view=by_date_ascending&am p;message.id=332299#M332299</a>
Mike
Reply With Quote
  #3  
Old 07-08-2008, 10:40 AM
Tim C.
Guest
 
Default Re: Need help with retrieving Excel WorkSheet List

I know the example is opening and closing excel,&nbsp; I was following an example that appeared to be opening and closing excel but the user never sees the excel app opeing and closing.&nbsp;
&nbsp;
Just trying steps to get some results...
&nbsp;
Is it possible to handle reading the native excel file through labview?
&nbsp;
Thanks
Tim C.
Reply With Quote
  #4  
Old 07-08-2008, 11:10 AM
MikeS81
Guest
 
Default Re: Need help with retrieving Excel WorkSheet List

Hi Tim,
to not see the excel application you can use the "visible" property node. Itīs possible to read it, but you have to know the format description, to get the information you want. What do you want to do with this information?
Mike
Reply With Quote
  #5  
Old 07-08-2008, 11:10 AM
Tim C.
Guest
 
Default Re: Need help with retrieving Excel WorkSheet List

We have numerous spreadsheets that contain technical data on various pieces of equipment we have used throughout the years on different projects.
These spread sheets have had minor changes throughout the years i.e. a colum has been added or moved.
My goal is to be able read the spreadsheet and determine what columns I need to extract data from.&nbsp; Once tha is determined I can extract the
equipment data i.e. description L, W, H, Weight, Power and BTU ratings and add them to a master list.
once the master list is created I can easily setup equipment groups and perform power, weight, and HVAC calcs.
&nbsp;
Best regards
Tim c.
Reply With Quote
  #6  
Old 07-08-2008, 11:10 AM
MikeS81
Guest
 
Default Re: Need help with retrieving Excel WorkSheet List

Hi Tim,
as i understand it now, you have to use the ActiveX functions.
Mike
Reply With Quote
  #7  
Old 07-08-2008, 11:40 AM
smercurio_fc
Guest
 
Default Re: Need help with retrieving Excel WorkSheet List

Actually, you can also use ADO. I&nbsp; had suggested this mechanism in this <a href="message?board.id=170&amp;message.id=248332" target="_blank">thread</a>, and Mike came up with an <a href="message?board.id=170&amp;message.id=248589#M 248589" target="_blank">example</a>. If you take Mike's example and replace the opening of the recordset with a call to the OpenSchema method for the connection object (with adSchemaTables for the "Schema" input) you'll get a recordset for the sheets in the Excel file. A similar action can be done to get the column names.
Reply With Quote
  #8  
Old 07-08-2008, 01:40 PM
Tim C.
Guest
 
Default Re: Need help with retrieving Excel WorkSheet List

Any chance you could tell me why this is not working?
&nbsp;
I was trying to get the active X read working before I tried the ADO...
&nbsp;
Best Regards
Tim C.
&nbsp;
&nbsp;


XCEL 2005.zip:
http://forums.ni.com/attachments/ni/170/338687/1/XCEL 2005.zip
Reply With Quote
  #9  
Old 07-08-2008, 02:10 PM
Tim C.
Guest
 
Default Re: Need help with retrieving Excel WorkSheet List

I got the ADO example tweaked and working for the sheet names.
&nbsp;
I also tried the adSchemaColumns and it appears to be retrieving the top row with the assumption that these are colum names,&nbsp; is that correct?
&nbsp;
So what exactly am doing by using ADO?&nbsp; Am I some how accessing the excel file as if it were a database and gaining access to the data
without the use of excel?
&nbsp;
Thanks
Tim C.
Reply With Quote
  #10  
Old 07-08-2008, 02:10 PM
smercurio_fc
Guest
 
Default Re: Need help with retrieving Excel WorkSheet List

Tim C. wrote:
Any chance you could tell me why this is not working?Simple. You're never actually opening the reference to Excel. Using text-language speakese: You've declared a variable that is of type Excel.Application. However, you've never actually opened a reference to Excel and set the variable's value. The example you copied this from had an Automation Open function. You still need that.

So what exactly am doing by using ADO?&nbsp; Am I
some how accessing the excel file as if it were a database and gaining
access to the datawithout the use of excel?
That's pretty much it. Whether or not this is of benefit to you, that's for you to decide based on your requirements.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:59 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.