House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Search cf-newbie

July 04, 2009

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Home / Groups / ColdFusion Newbie (CF-Newbie)

writing file, csv or xls?

Author:
John Barrett
11/19/2008 10:03 PM

Hi, I am wondering what I would have to do to change this to work with a .xls file compare to now using a csv file? I tried to change the csv variables to xls, as well as the name of the file from .csv to .xls, but I guess there are differences between the two formats. When I try that I get the error: Thanks so much, John Error Code Invalid list index 2. In function ListGetAt(list, index [, delimiters]), the value of index, 2, is not a valid as the first argument (this list has 1 elements). Valid indexes are in the range 1 through the number of elements in the list. The error occurred in /Users/johnbarrett/Sites/GotNutrients/adminNew/upload/write_file_xls.cfm: line 57 55 :          VALUES 56 :                   ('#listgetAt('#index#',1, ',')#', 57 :                    '#listgetAt('#index#',2, ',')#', 58 :                    '#listgetAt('#index#',3, ',')#', 59 :            '#listgetAt('#index#',4, ',')#', The write file code <!--- get and read the CSV-TXT file ---> <cffile action="read" file="myfolder/csvdemo.csv" variable="csvfile"> <!--- loop through the CSV-TXT file on line breaks and insert into database ---> <cfloop index="index" list="#csvfile#" delimiters="#chr(10)##chr(13)#">     <cfquery name="importcsv" datasource="#REQUEST.dataSource#">          INSERT INTO   datefield2(tiptopic,dailytip,tipdate,consumer_link,research_link)          VALUES                   ('#listgetAt('#index#',1, ',')#',                    '#listgetAt('#index#',2, ',')#',                    '#listgetAt('#index#',3, ',')#',        '#listgetAt('#index#',4, ',')#',                    '#listgetAt('#index#',5)#'                   )    </cfquery> </cfloop> <!--- use a simple database query to check the results of the import - dumping query to screen ---> <cfquery name="rscsvdemo" datasource="#REQUEST.dataSource#">          SELECT * FROM  datefield2 </cfquery> <cfdump var="#rscsvdemo#">


Mailing Lists