User Guide Cancel

SpreadsheetShiftColumns

 

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 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])

See also

SpreadsheetAddColumnSpreadsheetDeleteColumnSpreadsheetDeleteColumnsSpreadsheetFormatColumn

SpreadsheetFormatColumnsSpreadsheetShiftRows

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>

Get help faster and easier

New user?