Shift Cells"

From Documentation
(Created page with "{{ZKSpreadsheetEssentials3PageHeader}} Shift a range of cells can be performed by calling <tt>shift()</tt> wit row and column offset: <source lang='java'> range.shift(rowOffse...")
 
m (correct highlight (via JWB))
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
  
  
Shift a range of cells can be performed by calling <tt>shift()</tt> wit row and column offset:
+
Shift a range of cells can be performed by calling <code>shift()</code> wit row and column offset:
 
<source lang='java'>
 
<source lang='java'>
 
range.shift(rowOffset, columnOffset)
 
range.shift(rowOffset, columnOffset)
Line 9: Line 9:
  
 
You can also use  
 
You can also use  
<tt>CellOperationUtil.shift()</tt> which checks protection for you. The first Range object is your source range to be shifted. The second argument is row offset. If it's positive, source range will be shifted down, otherwise it will be shifted up. The third argument is column offset. If it's positive, source range will be shifted right, otherwise it will be shifted left.
+
<code>CellOperationUtil.shift()</code> which checks protection for you. The first Range object is your source range to be shifted. The second argument is row offset. If it's positive, source range will be shifted down, otherwise it will be shifted up. The third argument is column offset. If it's positive, source range will be shifted right, otherwise it will be shifted left.
  
 
Assume that we have selected  a selected range of cells:
 
Assume that we have selected  a selected range of cells:

Latest revision as of 12:53, 19 January 2022



Shift a range of cells can be performed by calling shift() wit row and column offset:

range.shift(rowOffset, columnOffset)

You can also use CellOperationUtil.shift() which checks protection for you. The first Range object is your source range to be shifted. The second argument is row offset. If it's positive, source range will be shifted down, otherwise it will be shifted up. The third argument is column offset. If it's positive, source range will be shifted right, otherwise it will be shifted left.

Assume that we have selected a selected range of cells:

Zss-essentials-shift-before.png


We want to move the selected cells 3 columns to the right, we can write the below code to shift it:

Range range = Ranges.range(spreadsheet.getSelectedSheet(), "F6:F10");
//move 3 columns to the right
CellOperationUtil.shift(range, 0, 3);

The result will be like:

Zss-essentials-shift-after.png



All source code listed in this book is at Github.


Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.