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.

Mike Causer
  • 8,196
  • 2
  • 43
  • 63
j-p
  • 3,698
  • 9
  • 50
  • 93
  • 1
    I have a feeling that there's no way around it... Include a .cfm in CMFL and call your function from your cfscript. – Henry Jan 16 '14 at 20:46
  • 1
    @henry, I may end up there, I've found this - http://www.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... – j-p Jan 16 '14 at 20:53
  • 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. – Leigh Jan 16 '14 at 21:55
  • Is there no script based version in CF 2016? – James A Mohler Feb 03 '17 at 17:29

2 Answers2

2
xls = SpreadsheetRead('C:\inetpub\wwwroot\myDomain\myDirectory\myFileName.xls');
for (row=2;row<=xls.rowCount;row+=1) {
    WriteOutput(SpreadsheetGetCellValue(xls,row,1) & '<br>');
}
Phillip Senn
  • 46,771
  • 90
  • 257
  • 373
-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);
}
SANN3
  • 9,459
  • 6
  • 61
  • 97
pedrov
  • 35
  • 7
  • I wanted to point that this can be done in java . anyway here's a post that you might find useful http://www.silverink.nl/cfspreadsheet-cfscript-hard/ – pedrov Jan 24 '14 at 08:55
  • Yes, but if you review the comments, that is the same example [they are already using](http://stackoverflow.com/questions/21172356/cfscript-equivalent-of-cfspreadsheet-action-read/21275442?noredirect=1#comment31874076_21172356). – Leigh Jan 24 '14 at 09:57