User Guide Cancel

SpreadsheetShiftRows

 

Note:

You can find the CFFiddle demo of this function and other spreadsheet functions as part of a project that is shared with you.

Click the button below to launch CFFiddle.

To copy the project in your workspace in CFFiddle, follow the steps below:

  1. Log in with your Gmail or Facebook credentials.
  2. Navigate to the project in the left pane.
  3. Once you make some changes in any cfm in the project, a pop up displays asking you to save the project.
  4. Give the project a suitable name and click Save.


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)

See also

SpreadsheetAddRowSpreadsheetAddRowsSpreadsheetDeleteRowSpreadsheetDeleteRows

SpreadsheetFormatRowSpreadsheetFormatRowsSpreadsheetShiftColumns

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>

 

Get help faster and easier

New user?