Read excel file in Red Lion

Ce.O

Member
Join Date
Sep 2018
Location
MEXICO
Posts
19
Hello
I am working in a project where I have to read data from an excel file. I'm not sure whether this is possible. The screen that I'm using is a Red Lion Cr3000700000420, I'm workig with Crimson 3.1

What I want to do is make a comparison from a text that is enter with a scanner and check whether this data is in the excel file.
 
I never read from an Excel file, but from a text file.
In the Crimson menu, go to Help -> Reference. In the Reference manual, look for the file instructions, like OpenFile, ReaFile, etc.
You need to create a program in the Programs tab.
 
Like CSV? is it possible to read an specific cell with csv files?
Do you read the files from an USB or sd card?
Thanks for your answer
 
Last edited:
Like CSV? is it possible to read an specific cell with csv files?
Do you read the files from an USB or sd card?
Thanks for your answer

Yes, it can be cvs. You'll need to convert/export the spreadsheet to csv or txt. Each cell will be separate by commas or some other character that you can select.
In my case, I'm reading from the sd or compactflash card.
 
Could you give me an example please?
I have never read files in red lion
I did this program and create a tag called dato, and I tried to read the file but it didn't work.
int archivo;
archivo = OpenFile("Volumen.csv",0);
FileSeek(archivo,23);
dato = ReadFileLine(archivo);
 
Last edited:
Could you give me an example please?
Here you are. I also sent you a private message.

/* This program reads a file where the tag names and its values are stored in */

int tagindex; int Hfile; int count; int space1; int space2; int decimal;
int IntValue; float FloatValue;
cstring line; cstring TagName; cstring TextValue;

//Open file
Hfile := OpenFile("/param/param.txt", 1);
//Read a line from the file
line := ReadFileLine(Hfile);

//While the line read from the files retrieves something, keep reading
while (Len(line)>0)
{
//Read the position of the first and second space occurrence
//Example of line: Polisher_System.Polisher.Vibration 22 mm/s
space1 := Find(line,' ',0);
space2 := Find(line,' ',1);
//The tag name is the section before the first space
TagName := Left(line, space1);
//The tag value is located between the first and the second spaces
TextValue := Mid(line, space1+1, space2-space1);
//Find the tag index
tagindex = FindTagIndex(TagName);

//Find out if the value is decimal (has a ".")
decimal := Find(TextValue,'.',0);

//Write the value to the corresponding tag in Crimson
if (decimal == 0)//If the tag is a integer
{IntValue= TextToInt(TextValue,10);
SetIntTag(tagindex,IntValue);}
else //If the tag is a float
{FloatValue= TextToFloat(TextValue);
SetRealTag(tagindex,FloatValue);}

//Read a new line from the file
line := ReadFileLine(Hfile);
}

//Close the file
CloseFile(Hfile);
 
Last edited:

Similar Topics

Hi Guys, Im back again after 1&1/2 year. But my question is... How can I read values in excel file especially from one column then compare it with...
Replies
4
Views
1,926
I have just been given the task of figuring out how to move data from a csv txt file into a excel spreadsheet in VBA. i have no idea about VBA and...
Replies
3
Views
3,689
Hello, I want to send the data from Rslogix500 to Excel. I created a connection between RSlinx and Excel. The values in Excel automatically...
Replies
5
Views
1,130
Is it possible to pull information from a specific cell in an excel spreadsheet and use it in a program? I am wanting to display a time amount for...
Replies
4
Views
1,143
Dear Friends; I am trying to read the Tag Values in excel by using VBA. I write a code but was stuck on the following error: Dim OPC Server1 As...
Replies
21
Views
6,273
Back
Top Bottom