cfscript equivalent of cfspreadsheet action="read"
Asked Answered
K

2

9

What is the equivalent of this...

<cfspreadsheet action="read" src="#form.uploadedFile#" query="mycontent" >  

in cfscript?

cfscript has spreadSheetRead(fileName) - but the result is an object with the file metadata, Even if I specify the sheet, it only returns metadata not row column data.

I need to loop over the rows... how do I do this?

I am trying to avoid exiting my script format, and interjecting 'cf' tag format...Any help is appreciated.

Knightly answered 16/1, 2014 at 20:37 Comment(4)
I have a feeling that there's no way around it... Include a .cfm in CMFL and call your function from your cfscript.Gant
@henry, I may end up there, I've found this - silverink.nl/cfspreadsheet-cfscript-hard - and it's got some bugs so I'll see if I can get it to word 'reliably'...otherwise I may have to do it the 'old' way...Knightly
Just to confirm - I am about 99% certain there isn't a script based version. So the two options you are considering are pretty much it.Fourpenny
Is there no script based version in CF 2016?Goodill
P
2
xls = SpreadsheetRead('C:\inetpub\wwwroot\myDomain\myDirectory\myFileName.xls');
for (row=2;row<=xls.rowCount;row+=1) {
    WriteOutput(SpreadsheetGetCellValue(xls,row,1) & '<br>');
}
Parse answered 2/1, 2015 at 20:10 Comment(0)
H
-3

Well , the proper way to do this is to use the java file reader inside cfscript and do all the imports you need.

import    java.io.BufferedReader;
import    java.io.FileReader;
import    java.io.IOException;
.
.
.
BufferedReader br=new BufferedReader(new FileReader(directory+uploadedfile));
while ((sCurrentLine = br.readLine()) != null) {
 System.out.println(sCurrentLine);
}
Holily answered 22/1, 2014 at 6:6 Comment(2)
I wanted to point that this can be done in java . anyway here's a post that you might find useful silverink.nl/cfspreadsheet-cfscript-hardHolily
Yes, but if you review the comments, that is the same example they are already using.Fourpenny

© 2022 - 2024 — McMap. All rights reserved.