Assuming you already have an Excel sheet, and are trying to dynamically add the filter to the entire row, you need to
- Get the column count
- Translate the column count into the corresponding letter. For example column E -> 5
- Create a range from that, such as
A1:E1 and pass that string into the SpreadSheetAddAutoFilter() function.
Here is a working example that I wrote:
<cffunction name="columnToLetter" returntype="any">
<cfargument name="index" type="numeric">
<cfset letterArray = listToArray('A B C D E F G H I J K L M N O P Q R S T U V W X Y Z', ' ')>
<cfreturn letterArray[index]>
</cffunction>
<cfspreadsheet action="read" src="fin.xlsx" name="spreadSheetObj" sheetname="Sheet1">
<cfset count = SpreadsheetGetColumnCount(spreadSheetObj, 'Sheet1')>
<cfoutput>
count: #count# <br>
<cfset column_label = columnToLetter(count)>
<cfset column_label = 'A1:' & column_label & '1'>
label: #column_label#
<cfset SpreadSheetAddAutoFilter(spreadSheetObj, column_label)>
<cfspreadsheet action="write" filename="updatedFile.xls" name="spreadSheetObj" sheetname="courses" overwrite=true>
</cfoutput>