02-03-2020 06:13 AM
I am reading more than 250 parameters and storing that in binary file. parameters which I am selecting only that parameters are converted into readable form from the bin file and stored in excel file.
Now I need to add a feature where user will select parameters. And the data which is stored under that parameter in excel file should be plotted on graph of control panel.
Please tell me how can I determine the selected parameters and read data from that column of excel file.
[note: I am storing data in .csv file and using Labwindow cvi 2013 ]
here i attached my excel file
02-03-2020 10:30 AM
If I'm not wrong you are not connected to Excel but working on the .csv file instead. I mean, you are not using neither Excel2000.ft nor ExcelReport.fp instruments in your program.
If this is true, you can treat .csv files as a regular text file to read line by line, extracting the corresponding values with either sscanf () or Scan () commands.
Just as an example, these lines can be executed into the Interactive Execution window and provided you check the file path will graph the selected column:
#include <userint.h>
#include <formatio.h>
static int fH;
static int r;
static int i, column;
static int data[60];
static char msg[512];
column = 6;
fH = OpenFile ("c:\\Temp\\data_file.csv", VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
// Read header line and text line
ReadLine (fH, msg, -1);
ReadLine (fH, msg, -1);
// Read data lines
i = 0;
while (1) {
r = ReadLine (fH, msg, -1);
if (r == -2) break; // End of file
Scan (msg, "%*i[dx]%d[x]", column - 1, &data[i]);
i++;
}
CloseFile (fH);
YGraphPopup ("Data", data, i, VAL_INTEGER);
This is just a code framework: to integrate them into your app you will need some adaptations, add I/O error checking, count lines and dimension data array accordingly...
If on the contrary you want to operate inside Excel environment you will need to tell us at least which instrument you are using to interact with that application. Nevertheless, this is a basic task that is demonstrated for example inside excel2000dem sample program that ships with CVI so you can go there and look at that code for first.