SpreadsheetShiftRows

Description

Shifts one or more rows in Excel spreadsheet object up or down. The contents of the shifted row, including empty cells, overwrites data in the column to which it is shifted.

Returns

Does not return a value.

Category

Microsoft Office Integration

Function syntax

SpreadsheetShiftRows(spreadsheetObj, start[, rows] 
SpreadsheetShiftRows(spreadsheetObj, start, end, rows)

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 row to shift

end

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

rows

The positive (down) or negative (up) number of rows by which to shift the rows. If you omit this parameter, the function shifts the row down by one unit.

Usage

Example

The following line shifts 10 and 11 down two rows. Notice that the shifted rows completely overwrite the previous rows 12 and 13.

<cfscript> 
    ///We need an absolute path, so get the current directory path. 
      theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "shiftrows.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 E11",11,5); 
    SpreadsheetSetCellValue(theSheet,"Cell A12",12,1); 
    SpreadsheetSetCellValue(theSheet,"Cell B13",13,2); 
    //Shift rows 10 and 11 down 2 rows. 
    SpreadsheetShiftRows(theSheet,10,11,2); 
</cfscript> 
 
<!--- Write the spreadsheet to a file, replacing any existing file. ---> 
<cfspreadsheet action="write" filename="#theFile#" name="theSheet" overwrite=true>