![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]()
|
New Here? Please read this important info!!!
![]() |
#1 |
Member
![]() ![]() Join Date: Sep 2018
Location: MEXICO
Posts: 17
|
Read excel file in Red Lion
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. |
![]() |
![]() |
#2 |
Member
![]() ![]() Join Date: Apr 2008
Location: NC
Posts: 817
|
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. |
![]() |
![]() |
#3 |
Member
![]() ![]() Join Date: Sep 2018
Location: MEXICO
Posts: 17
|
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 by Ce.O; November 7th, 2019 at 02:57 PM. |
![]() |
![]() |
#4 | |
Member
![]() ![]() Join Date: Apr 2008
Location: NC
Posts: 817
|
Quote:
In my case, I'm reading from the sd or compactflash card. |
|
![]() |
![]() |
#5 |
Member
![]() ![]() Join Date: Sep 2018
Location: MEXICO
Posts: 17
|
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 by Ce.O; November 7th, 2019 at 03:36 PM. |
![]() |
![]() |
#6 |
Member
![]() ![]() Join Date: Apr 2008
Location: NC
Posts: 817
|
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 by Elcan; November 8th, 2019 at 05:32 AM. |
![]() |
![]() |
#7 |
Member
![]() ![]() Join Date: Sep 2018
Location: MEXICO
Posts: 17
|
Thank you very much
|
![]() |
![]() |
Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Lantronix to Red Lion Data Station Plus via Modbus | CCasalie | LIVE PLC Questions And Answers | 5 | September 6th, 2016 05:03 PM |
Red Lion G307K to Excel - options? | kolyur | LIVE PLC Questions And Answers | 3 | August 26th, 2016 08:33 AM |
Add Remote IO with Devicenet | SicknoteX | LIVE PLC Questions And Answers | 11 | April 15th, 2016 05:11 PM |
Red Lion G310 Series Touch Screens reading and dropping out | DiverseTechNewbie | LIVE PLC Questions And Answers | 10 | February 4th, 2015 10:56 PM |
Data Tables | bosshen | LIVE PLC Questions And Answers | 5 | April 28th, 2003 07:30 PM |