cfspreadsheet / checking for tabs in a workbook
- ColdFusion version:9.0.1 standard
- server OS: Windows 2008 R2
- webserver: Apache 2.2.19
These forums worked great once before, hopefully we can go 2 / 2.
I am opening a workbook, adding a header row to all the tabs, and then saving the workbook back to the directory as a different file. My problem is that the workbook can have any various combination of tabs in it, and I don't know what ones unless I open the workbook itself. Is there a way to read either the name of every tab in the workbook and then loop through those names (or the amount of sheets would work also).
Code is here:
<!--- All possible prefixes that could be in the sheet name --->
<cfset prefixList = "10-00, 10-10, 10-20, 10-30, 10-40, 10-50">
<!--- All possible status that could be in the sheet name --->
<cfset statusList = "In progress,Closed">
<cfloop list="#statusList#" index="si">
<cfloop list="#prefixList#" index="pi">
<!--- Read the sheet --->
<cfspreadsheet action="read" query="qWip" sheetName="#pi#-#si#" src="accounting/Files/wip.xls">
<cfset column = 1>
<!--- create new sheet with old information --->
<cfset sObj = spreadsheetNew("#pi#-#si#")>
<cfset SpreadsheetAddRow(sObj, "Header")>
<!--- add column header to all rows --->
<cfloop from="#column#" to="#listLen(qWip.columnList)#" index="i">
<cfset spreadsheetSetCellFormula(sObj, "CONCATENATE(""job""&#i#)", 1 , #i#)>
</cfloop>
<cfset SpreadsheetAddRows(sObj, qWip)>
<!--- dump excel file back into directory with new row header --->
<cfspreadsheet action="update" name="sObj" filename="accounting/Files/wipHeader.xls">
</cfloop>
</cfloop>
The error comes up when a sheet does not exist in the cfspreadsheet read action. Example: 10-10-In progress does not exist.
Any help is appreciated.
