You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
Thread Tools Display Modes
Unread November 7th, 2019, 12:06 PM   #1
Ce.O
Member
Mexico

Ce.O is offline
 
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.
  Reply With Quote
Unread November 7th, 2019, 12:52 PM   #2
Elcan
Member
United States

Elcan is offline
 
Join Date: Apr 2008
Location: NC
Posts: 808
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.
  Reply With Quote
Unread November 7th, 2019, 02:40 PM   #3
Ce.O
Member
Mexico

Ce.O is offline
 
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.
  Reply With Quote
Unread November 7th, 2019, 03:17 PM   #4
Elcan
Member
United States

Elcan is offline
 
Join Date: Apr 2008
Location: NC
Posts: 808
Quote:
Originally Posted by Ce.O View Post
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.
  Reply With Quote
Unread November 7th, 2019, 03:30 PM   #5
Ce.O
Member
Mexico

Ce.O is offline
 
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.
  Reply With Quote
Unread November 8th, 2019, 05:24 AM   #6
Elcan
Member
United States

Elcan is offline
 
Join Date: Apr 2008
Location: NC
Posts: 808
Quote:
Originally Posted by Ce.O View Post
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 by Elcan; November 8th, 2019 at 05:32 AM.
  Reply With Quote
Unread November 8th, 2019, 09:48 AM   #7
Ce.O
Member
Mexico

Ce.O is offline
 
Join Date: Sep 2018
Location: MEXICO
Posts: 17
Thank you very much
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
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


All times are GMT -5. The time now is 04:24 PM.


.