Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Spread.Sheets has a drag fill option that allows the user to select cells and fill other cells with the same or different values.  The fill type can be set to linear, growth, date, or automatic fill. The fill direction can also be specified. Additional options can be set such as step and stop values.
Select a cell or block and move the mouse pointer over the square at the corner of the selection.  The mouse pointer changes to a plus shape that can be used to expand the fill range.
Image Removed
Expand the range and release the mouse.
Image Removed
Click on the plus mark to display a menu with additional fill options as shown in the following image:
Image Removed
Drag fill is not supported if the destination range contains a spanned cell. Drag fill does not apply to a conditional format or filtered range.
The options.allowUserDragFill property is used to specify whether to allow drag fill. The fillAuto method can be used to programmatically specify the type of fill.
Image Removed
Using Code
This example fills a cell range.有拖拽填充选项,允许用户选择单元格并使用相同内容或不同内容进行填充。

填充类型可以设置为线性,增长或者自动填充。

填充方向也可以设置。

拖拽填充也提供其他选项,比如步进和停止值等。


操作步骤:

选择一个单元格或者区域,并将鼠标移动到右下角,鼠标指针样式将会变成一个加号。
Image Added
此时拖拽并松开鼠标,即可进行拖拽填充操作。
Image Added

点击下方的加号标志,你可以选择填充选项,如图所示:
Image Added

拖拽填充在有合并单元格区域时不适用。

拖拽填充对条件格式和筛选区域不适用。
options.allowUserDragFill 属性用来设置是否允许拖拽填充, fillAuto 方法用于使用代码进行填充操作。
Image Added
示例代码
以下了例子填充了一个单元格区域。


JavaScript

Copy Code

spread.options.allowUserDragFill = true; activeSheet.setValue(0, 0, new Date(2011, 1, 1));activeSheet.setValue(0, 1, new Date(2011, 2, 9));activeSheet.setValue(0, 2, 5); activeSheet.setValue(0, 3, 10);activeSheet.setValue(0, 4, 1);
var start = new GC.Spread.Sheets.Range(0, 0, 1, 1);var r = new GC.Spread.Sheets.Range(0, 0, 4, 1);activeSheet.fillAuto(start, r, {    fillType: GC.Spread.Sheets.Fill.FillType.date,    series: GC.Spread.Sheets.Fill.FillSeries.column,    fillDirection: GC.Spread.Sheets.Fill.FillDirection.down,    unit: GC.Spread.Sheets.Fill.FillDateUnit.day,    step: 1,    stop: new Date(2011, 2, 11)});
start = new GC.Spread.Sheets.Range(0, 1, 1, 1);var r2 = new GC.Spread.Sheets.Range(0, 1, 4, 1);activeSheet.fillAuto(start, r2, {fillType: GC.Spread.Sheets.Fill.FillType.date,series: GC.Spread.Sheets.Fill.FillSeries.column,fillDirection:GC.Spread.Sheets.Fill.FillDirection.down,unit: GC.Spread.Sheets.Fill.FillDateUnit.day,step: 1,stop: new Date(2011, 2, 11)});
start = new GC.Spread.Sheets.Range(0, 2, 1, 1);var r3 = new GC.Spread.Sheets.Range(0, 2, 4, 1);activeSheet.fillAuto(start, r3, {    fillType: GC.Spread.Sheets.Fill.FillType.auto,    series: GC.Spread.Sheets.Fill.FillSeries.column,});
start = new GC.Spread.Sheets.Range(0, 3, 1, 1);var r4 = new GC.Spread.Sheets.Range(0, 3, 4, 1);activeSheet.fillAuto(start, r4, {    fillType: GC.Spread.Sheets.Fill.FillType.growth,    series: GC.Spread.Sheets.Fill.FillSeries.column,    step:2,    stop:55});
start = new GC.Spread.Sheets.Range(0, 4, 1, 1);var r5 = new GC.Spread.Sheets.Range(0, 4, 4, 1);activeSheet.fillAuto(start, r5, {    fillType: GC.Spread.Sheets.Fill.FillType.linear,    series: GC.Spread.Sheets.Fill.FillSeries.column,    step:3,    stop:20});
activeSheet.setValue(0, 5, 123);var r6 = new GC.Spread.Sheets.Range(0, 5, 4, 1);activeSheet.fillAuto(new GC.Spread.Sheets.Range(0, 5, 1, 1), r6, {    fillType: GC.Spread.Sheets.Fill.FillType.auto,    series: GC.Spread.Sheets.Fill.FillSeries.column,});

 


See Also另见
Workbook Method