cfscript equivalent of cfspreadsheet action="read"

2k Views Asked by At

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.

2

There are 2 best solutions below

2
On

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);
}
0
On
xls = SpreadsheetRead('C:\inetpub\wwwroot\myDomain\myDirectory\myFileName.xls');
for (row=2;row<=xls.rowCount;row+=1) {
    WriteOutput(SpreadsheetGetCellValue(xls,row,1) & '<br>');
}