SpreadsheetShiftColumns

Description

Shifts one or more columns in Excel spreadsheet object left or right.

Returns

Does not return a value.

Category

Microsoft Office Integration

Function syntax

SpreadsheetShiftColumns(spreadsheetObj, start[, cols] 
SpreadsheetShiftColumns(spreadsheetObj, start, end [, cols])

History

ColdFusion 9: Added the function.

Parameters

Parameter

Description

spreadsheetObj

The Excel spreadsheet object in which to make the shift.

start

The number of the first, or only, column to shift

end

The number of the last column to shift. If you omit this parameter, the function shifts a single column.

columns

The positive (right) or negative (left) number of columns by which to shift the columns. If you omit this parameter, the function shifts the column right by one unit.

Usage

Example

The following line shifts columns 6 and 7 two columns to the left.

<cfset SpreadsheetShiftColumns(SpreadsheetObj,l0,11,2)><cfscript> 
    ///We need an absolute path, so get the current directory path. 
      theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "shiftcolumns.xls"; 
    //Create a new Excel spreadsheet object. 
    theSheet = SpreadsheetNew("Expenses"); 
    //Set some cell values, indicating their initial location. 
    SpreadsheetSetCellValue(theSheet,"Cell D10",10,4); 
    SpreadsheetSetCellValue(theSheet,"Cell E12",12,5); 
    SpreadsheetSetCellValue(theSheet,"Cell F12",12,6); 
    SpreadsheetSetCellValue(theSheet,"Cell G13",13,7); 
    //Shift columns 6 and 7 left 2 columns. 
    SpreadsheetShiftColumns(theSheet,6,7,-2); 
</cfscript> 
 
<!--- Write the spreadsheet to a file, replacing any existing file. ---> 
<cfspreadsheet action="write" filename="#theFile#" name="theSheet" overwrite=true>