LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

read xls file and display the data in table.

Solved!
Go to solution

Hi,

Trying to read the data from xls or csv file and populate the same data in table. whether i need to use array to store the file data and then display, hoping someone could help.

 

Thanks,

hari

0 Kudos
Message 1 of 6
(5,278 Views)

Hi hari,

regarding reading a data file you must consider firstly its format: if it's an Excel file you must use the activeX interface with Excel and read this native format. See examples\activex\excel\excel2000dem example program for an introduction to reading / writing in excel format.

On the other hand, a file in csv format is a simple ASCII file which can be read with file I/O instructions like fopen/fread/sscanf or OpenFile/ReadLine/sscanf.

 

Looking in the example programs and this forum you may find several hints to approach both environments. While deciding wether to use one format or the other, consider that using activex is not a trivial task and requires excel to be installed on the target machine, while reading a csv / ascii file requires nothing more than cvi native functions: for this reason, if you have an influence on the file format to use you may prefer to use csv format, as it is considerably easier to develop.

 

 

As per writing to the table, if you have no memory constraint and can store your data in arrays, writing to the table will be faster using SetTableCellRangeVals command.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 6
(5,262 Views)
Solution
Accepted by topic author rravi

Hi hari,

 

One thing that's very important when using Excel activeX interface (in case you need it) is proper termination of application/workbook/worksheet handles.

You need those handles to specify which cell in which file you are trying to access.

 

If you fail to discard every handle you acquired then you'll end up with ghost Excel processes in your task manager, eating up your system memory.

So while debugging your application open the task manager and watch as Excel processes created/destroyed and be sure you end up with zero Excel processes running when your application is closed.

 

Also consider fault cases for your program. Check that your exit routes does not skip any handle termination.

S. Eren BALCI
IMESTEK
Message 3 of 6
(5,234 Views)

 

lots of kudos.

 

0 Kudos
Message 4 of 6
(5,176 Views)

Hello, please can you to give the project ? because ,I need this  method in my project

 

 

 

 

 

 

0 Kudos
Message 5 of 6
(3,960 Views)

JJHGH,

as I told you before, it is better to start a new discussion instead of spreading the same question in multiple (old) threads which sometimes do not really match with your problem.

 

Anyway, I suggest you to look at the Excel Report instrument that comes with CVI: this instrument includes ExcelRpt_ReadDataToTableControl () function which does exactly what you want. A symmetric function is ExcelRpt_WriteDataFromTableControl (), which takes data fro a table control and writes them to an Excel sheet. An example of the latter can be found in the Excel Report example program, that you can locate with the Example finder (Help >> Find examples menu function) by seraching with Excel. There is a good tutorial on Excel Report instrument that you should read before approaching this tool.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 6
(3,947 Views)