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#"> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4187
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to