[]
        
(Showing Draft Content)

GC.Spread.Sheets.FloatingObjects.FloatingObject

类: FloatingObject

Sheets.FloatingObjects.FloatingObject

继承关系

Table of contents

构造方法

属性

方法

构造方法

constructor

new FloatingObject(name, x, y, width, height)

一个浮动对象元素

remarks 这是供内部使用的基类

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
name string 浮动对象元素的名称
x number 浮动对象元素的x位置
y number 浮动对象元素的y位置
width number 浮动对象元素的宽度
height number 浮动对象元素的高度

属性

typeName

typeName: string

支持序列化的类型名称字符串

方法

allowMove

allowMove(value?): any

获取或设置是否禁用移动浮动对象元素

代码示例

//本示例阻止您移动或调整浮动对象元素的大小
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.allowResize(false);
customFloatingObject.allowMove(false);
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? boolean 是否禁用移动浮动对象元素的设置

返回值

any

如果未设置任何值,则返回是否禁用移动浮动对象元素的设置;否则,返回浮动对象元素


allowResize

allowResize(value?): any

获取或设置是否禁用调整浮动对象的大小

代码示例

//本示例阻止您移动或调整浮动对象元素的大小
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.allowResize(false);
customFloatingObject.allowMove(false);
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? boolean 是否禁用调整浮动对象大小的设置

返回值

any

如果未设置任何值,则返回是否禁用调整浮动对象大小的设置;否则,返回浮动对象


alt

alt(value?): any

获取或设置浮动对象的可选文本

代码示例

var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject('f1', 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
customFloatingObject.alt("A button");
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? string 浮动对象的可选文本

返回值

any

浮动对象的可选文本


cloneContent

cloneContent(): HTMLElement

获取当前实例的内容副本

代码示例

var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject('f1', 10, 10, 64, 30);
customFloatingObject.content(createButton('button 1', '64px', '30px'));
activeSheet.floatingObjects.add(customFloatingObject);

var btn = customFloatingObject.cloneContent();
btn.innerText = 'button 2';
customFloatingObject.content(btn);

function createButton (text, width, height) {
    var btn = document.createElement('button');
    btn.style.width = width;
    btn.style.height = height;
    btn.innerText = text;
    return btn;
}

返回值

HTMLElement

当前实例内容的副本


content

content(value?): any

获取或设置自定义浮动对象元素的内容

代码示例

var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject('f1', 10, 10, 64, 30);
customFloatingObject.content(createButton('button 1', '64px', '30px'));
activeSheet.floatingObjects.add(customFloatingObject);

console.log(customFloatingObject.content()); // get current content, the result is button element with the text "button 1".
customFloatingObject.content(createButton('button 2', '64px', '30px')); // set new content.

function createButton (text, width, height) {
    var btn = document.createElement('button');
    btn.style.width = width;
    btn.style.height = height;
    btn.innerText = text;
    return btn;
}

参数

属性名 类型 说明
value? HTMLElement 自定义浮动对象元素的内容

返回值

any

如果未设置任何值,则返回自定义浮动对象元素的内容;否则,返回浮动对象元素


dynamicMove

dynamicMove(value?): any

获取或设置对象在隐藏或显示,调整大小或移动行或列时是否移动

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
customFloatingObject.isVisible(true);
customFloatingObject.dynamicSize(true);
customFloatingObject.dynamicMove(true);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? boolean 该值指示对象在隐藏或显示,调整大小或移动行或列时是否移动

返回值

any

如果未设置任何值,则返回此浮动对象元素是否动态移动;否则,返回浮动对象元素


dynamicSize

dynamicSize(value?): any

获取或设置在隐藏或显示,调整大小或移动行或列时对象的大小是否改变

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
customFloatingObject.isVisible(true);
customFloatingObject.dynamicSize(true);
customFloatingObject.dynamicMove(true);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? boolean 该值指示在隐藏或显示,调整大小或移动行或列时对象的大小是否改变

返回值

any

如果未设置任何值,则返回此浮动对象元素是否动态更改大小;否则,返回浮动对象元素


endColumn

endColumn(value?): any

获取或设置浮动对象元素位置的结束列索引

代码示例

//Creates a floating object.
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);
//Position the upper left corner of the floating object by cell anchors.
customFloatingObject.startRow(2);
customFloatingObject.startColumn(2);
customFloatingObject.startRowOffset(10);
customFloatingObject.startColumnOffset(10);
//Position the lower right corner of the floating object by cell anchors.
customFloatingObject.endRow(7);
customFloatingObject.endColumn(5);
customFloatingObject.endRowOffset(10);
customFloatingObject.endColumnOffset(10);

参数

属性名 类型 说明
value? number 浮动对象元素位置的结束列索引

返回值

any

如果未设置任何值,则返回浮动对象元素位置的结束列索引;否则,返回浮动对象元素


endColumnOffset

endColumnOffset(value?): any

获取或设置相对于浮动对象元素的结束列的偏移量

代码示例

//Creates a floating object.
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);
//Position the upper left corner of the floating object by cell anchors.
customFloatingObject.startRow(2);
customFloatingObject.startColumn(2);
customFloatingObject.startRowOffset(10);
customFloatingObject.startColumnOffset(10);
//Position the lower right corner of the floating object by cell anchors.
customFloatingObject.endRow(7);
customFloatingObject.endColumn(5);
customFloatingObject.endRowOffset(10);
customFloatingObject.endColumnOffset(10);

参数

属性名 类型 说明
value? number 相对于浮动对象元素的结束列的偏移量

返回值

any

如果未设置任何值,则返回相对于浮动对象元素的结束列的偏移量;否则,返回浮动对象元素


endRow

endRow(value?): any

获取或设置浮动对象元素位置的末行索引

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);
//Position the upper left corner of the floating object by cell anchors.
customFloatingObject.startRow(2);
customFloatingObject.startColumn(2);
customFloatingObject.startRowOffset(10);
customFloatingObject.startColumnOffset(10);
//Position the lower right corner of the floating object by cell anchors.
customFloatingObject.endRow(7);
customFloatingObject.endColumn(5);
customFloatingObject.endRowOffset(10);
customFloatingObject.endColumnOffset(10);

参数

属性名 类型 说明
value? number 浮动对象元素位置的末行索引

返回值

any

如果未设置任何值,则返回浮动对象元素位置的末端行索引;否则,返回浮动对象元素


endRowOffset

endRowOffset(value?): any

获取或设置相对于浮动对象元素的最后一行的偏移量

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);
//Position the upper left corner of the floating object by cell anchors.
customFloatingObject.startRow(2);
customFloatingObject.startColumn(2);
customFloatingObject.startRowOffset(10);
customFloatingObject.startColumnOffset(10);
//Position the lower right corner of the floating object by cell anchors.
customFloatingObject.endRow(7);
customFloatingObject.endColumn(5);
customFloatingObject.endRowOffset(10);
customFloatingObject.endColumnOffset(10);

参数

属性名 类型 说明
value? number 相对于浮动对象元素的最后一行的偏移量

返回值

any

如果未设置任何值,则返回相对于浮动对象元素的最后一行的偏移量;否则,返回浮动对象元素


fixedPosition

fixedPosition(value): any

获取或设置浮动对象元素的位置是否固定 当fixedPosition为true时,dynamicMove和dynamicSize被禁用

代码示例

//本示例将对象的位置设置为固定
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
customFloatingObject.fixedPosition(true);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value boolean 该值指示浮动对象元素的位置是否固定

返回值

any

如果未设置任何值,则返回浮动对象元素的位置是否固定 否则,返回浮动对象元素


getHost

getHost(): HTMLElement[]

获取自定义内容的dom宿主

返回值

HTMLElement[]


height

height(value?): any

获取或设置浮动对象元素的高度

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1");
customFloatingObject.x(10);
customFloatingObject.y(10);
customFloatingObject.width(60);
customFloatingObject.height(64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? number 浮动对象元素的高度

返回值

any

如果未设置任何值,则返回一个浮动对象元素的高度;否则,返回浮动对象元素


isLocked

isLocked(value?): any

获取或设置此浮动对象元素是否被锁定

代码示例

var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1");
customFloatingObject.x(10);
customFloatingObject.y(10);
customFloatingObject.width(60);
customFloatingObject.height(64);
customFloatingObject.isLocked(true);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);
activeSheet.options.isProtected = true;

参数

属性名 类型 说明
value? boolean 该值指示此浮动对象元素是否被锁定

返回值

any

如果未设置任何值,则返回此浮动对象元素是否被锁定;否则,返回浮动对象元素


isSelected

isSelected(value?): any

获取或设置是否选择此浮动对象元素

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
customFloatingObject.isSelected(true);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? boolean 该值指示此浮动对象元素是否被选择

返回值

any

如果未设置任何值,则返回是否选择此浮动对象元素;否则,返回浮动对象元素


isVisible

isVisible(value?): any

获取或设置此浮动对象元素是否可见

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
customFloatingObject.isVisible(true);
customFloatingObject.dynamicSize(true);
customFloatingObject.dynamicMove(true);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? boolean 该值指示此浮动对象元素是否可见

返回值

any

如果未设置任何值,则返回此浮动对象元素是否可见;否则,返回浮动对象元素


name

name(value?): any

获取浮动对象元素的名称

代码示例

//本示例使用name方法
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject();
customFloatingObject.name("f1");
customFloatingObject.x(10);
customFloatingObject.y(10);
customFloatingObject.width(60);
customFloatingObject.height(64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? string 浮动对象元素的名称

返回值

any

如果未设置任何值,则返回浮动对象元素的名称;否则,返回浮动对象元素


refreshContent

refreshContent(): void

刷新floatObject中的内容用户应重写此方法,以使其内容与floatObject同步

返回值

void


startColumn

startColumn(value?): any

获取或设置浮动对象元素位置的起始列索引

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);
//加入表中时生效
customFloatingObject.startRow(2);
customFloatingObject.startColumn(2);
customFloatingObject.startRowOffset(10);
customFloatingObject.startColumnOffset(10);

参数

属性名 类型 说明
value? number 浮动对象元素位置的起始列索引

返回值

any

如果未设置任何值,则返回浮动对象元素位置的起始列索引;否则,返回浮动对象元素


startColumnOffset

startColumnOffset(value?): any

获取或设置相对于浮动对象元素的起始列的偏移量

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);
//加入表中时生效
customFloatingObject.startRow(2);
customFloatingObject.startColumn(2);
customFloatingObject.startRowOffset(10);
customFloatingObject.startColumnOffset(10);

参数

属性名 类型 说明
value? number 相对于浮动对象元素的起始列的偏移量

返回值

any

如果未设置任何值,则返回相对于浮动对象元素的起始列的偏移量;否则,返回浮动对象元素


startRow

startRow(value?): any

获取或设置浮动对象元素位置的起始行索引

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);
//加入表中时生效
customFloatingObject.startRow(2);
customFloatingObject.startColumn(2);
customFloatingObject.startRowOffset(10);
customFloatingObject.startColumnOffset(10);

参数

属性名 类型 说明
value? number 动对象元素位置的起始行索引

返回值

any

如果未设置任何值,则返回浮动对象元素位置的起始行索引;否则,返回浮动对象


startRowOffset

startRowOffset(value?): any

获取或设置相对于浮动对象元素的起始行的偏移量

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);
//加入表中时生效
customFloatingObject.startRow(2);
customFloatingObject.startColumn(2);
customFloatingObject.startRowOffset(10);
customFloatingObject.startColumnOffset(10);

参数

属性名 类型 说明
value? number 相对于浮动对象元素的起始行的偏移量

返回值

any

如果未设置任何值,则返回相对于浮动对象元素起始行的偏移量;否则,返回浮动对象元素


width

width(value?): any

获取或设置浮动对象元素的宽度

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1");
customFloatingObject.x(10);
customFloatingObject.y(10);
customFloatingObject.width(60);
customFloatingObject.height(64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? number 浮动对象元素的宽度

返回值

any

如果未设置任何值,则返回一个浮动对象元素的宽度;否则,返回浮动对象元素


x

x(value?): any

获取或设置浮动对象元素的水平位置

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1");
customFloatingObject.x(10);
customFloatingObject.y(10);
customFloatingObject.width(60);
customFloatingObject.height(64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? number 浮动对象元素的水平位置

返回值

any

如果未设置任何值,则返回浮动对象元素的水平位置;否则,返回浮动对象元素


y

y(value?): any

获取或设置浮动对象元素的垂直位置

代码示例

//本示例创建了一个浮动对象
var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1");
customFloatingObject.x(10);
customFloatingObject.y(10);
customFloatingObject.width(60);
customFloatingObject.height(64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);

参数

属性名 类型 说明
value? number 获取或设置浮动对象元素的垂直位置

返回值

any

如果未设置任何值,则返回浮动对象对象的垂直位置;否则,返回浮动对象元素