Whatever message this page gives is out now! Go check it out!

Example- storing the spreadsheet data in a CSV string

Last update:
May 18, 2026
The following example reads the spreadsheet file - SingleSheet.xls and stores the spreadsheet data in a CSV string.
<cfspreadsheet action = "read" 
format="csv" 
src="C:\documents\SingleSheet.xls" 
name="csvvar" 
rows="1-4,5,6,7-8"> 
<cfoutput>#csvvar#</cfoutput>
The following example reads the spreadsheet file - template_02.xls and stores the spreadsheet data in a query.
<cfspreadsheet 
action = "read" 
src="C:\dcuments\template_02.xls" 
query="excelquery" 
sheet="1" 
rows="1-3,4-5" 
columns="1,4"> 
<cfoutput 
query="excelquery" 
startrow="1" 
maxrows="#excelquery.recordcount#"> 
#excelquery.col_1# 
#excelquery.col_2# 
</cfoutput>
The following example reads a spreadsheet file - template_08_Charts_Graph.xls and stores the spreadsheet data in an HTML string.
<cfspreadsheet 
action = "read" 
format="html" 
src="C:\documents\template_08_Charts_Graph.xls" 
name="report1" 
rows="5-11" 
columns="1-6"> 
<cfoutput> 
#report1# 
</cfoutput>
The following example uses data from a query and writes it to a single sheet in the spreadsheet file - SingleSheet1.xls
<cfquery 
name="excelquery" 
datasource="cfdocexamples"> 
SELECT PARKNAME, REGION, STATE FROM Parks WHERE STATE='WI' 
ORDER BY ParkName, State 
</cfquery> 
<cfspreadsheet 
action = "write" 
filename="C:\SingleSheet1.xls" 
query="excelquery" 
overwrite="true">

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page