dhruv_x0
18th July 2011, 06:51
Hi,
I am writing AFS for generating a production order, in which item and order quantity should be picked from excel file and then that AFS will be executed.
How can i get that item and and its quantity from that excel file.
If anybody have some source code or link, please help me out.
Thanks
royspk
18th July 2011, 07:35
YOu can directly convert the excel file to CSV(Comma Seperated Value) File.
Using string.scan() function you can read from this file.
dhruv_x0
18th July 2011, 07:48
Dear royspk,
There is bulk of data in that file....then how will this string.scan() work.
If You have any source code related to this then please mail me dhruv.333.sharma@gmail.com or paste it here.
royspk
18th July 2011, 08:06
In the file each field is seperated by | in my case. You can use, or any other field seperator.
function open.file()
{
fp = seq.open(s.file,"w+")
if fp < 1 then
message("Error in opening file for data upload.")
end()
endif
process.file()
seq.close(fp)
}
function process.file()
{
line.no = 1
if fp > 0 then
seq.seek(0, 0, fp)
while seq.gets(line, 300, fp) = 0
{
ret2 = string.scan(line, "%d|%s|%d|%s|%s|%s|%s|%s|%f|%f|%s|%d|%d|%d|%d|",
hold.line,
hold.item, |Item
hold.date,
hold.cntr,
hold.cwar,
hold.loca,
hold.stun,
hold.clot,
hold.stks,
hold.strs,
hold.suno,
hold.oudt,
hold.cert,
hold.mfdt,
hold.mrdt
)
| cnt = cnt + 1
line.no = line.no + 1
}
endwhile
endif
}
dhruv_x0
18th July 2011, 08:12
Thanks royspk....i think it will work.
dhruv_x0
18th July 2011, 09:09
Dear royspk,
It is not reading any data from the file....file is opened but when it comes to
seq.gets(line,1024,FP)..it gets blank "line".
I have saved that excel file on desktop.
royspk
18th July 2011, 13:16
Oh no no.
You need to save the file in text format not notepad.
Please save the fExcel file in .csv format from save as menu in Excel.
royspk
18th July 2011, 13:46
Dear Dhruv,
Save the file in .csv or .txt format to be opened in Notepad using Excel Save as Option.
It does not open Excel file directly.
dhruv_x0
18th July 2011, 14:21
Dear roy..
its done..actually it need to be written on server first by client2server()
Anyways thanks very much.