[]
        
(Showing Draft Content)

GC.Spread.Sheets.FloatingObjects.FloatingObjectCollection

类: FloatingObjectCollection

Sheets.FloatingObjects.FloatingObjectCollection

Table of contents

构造方法

方法

构造方法

constructor

new FloatingObjectCollection(sheet?, typeName?)

一个浮动对象元素管理器,用于管理表单中的所有浮动对象元素

参数

属性名 类型 说明
sheet? Worksheet 表单
typeName? string 类型名称

方法

add

add(floatingObjectOrName, src?, x?, y?, width?, height?): FloatingObject

将浮动对象元素添加到表 参数有2种模式 如果有1个参数,则该参数为floatObject,这是GC.Spread.Sheets.FloatingObjects.FloatingObject类型 如果有6个参数,则参数为name, src, x, y, width, 和 height

代码示例

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

参数

属性名 类型 说明
floatingObjectOrName string | FloatingObject 将添加到表单的浮动对象,或将添加到表单的图片的名称
src? string 图片的图像来源
x? number 图片的x位置
y? number 图片的y位置
width? number 图片的宽度
height? number 图片的高度

返回值

FloatingObject

已添加到表的浮动对象元素


all

all(): FloatingObject[]

获取表单表中的所有浮动对象元素

代码示例

activeSheet.pictures.add("p1", "pics/download.jpg", 1, 6, 400, 400);
activeSheet.pictures.add("p2", "pics/download.jpg", 500, 150, 200, 300);
var pictures = activeSheet.pictures.all();
for (var i = 0; i < pictures.length; i++) {
    alert("Path of picture " + i + " is:  " + pictures[i].src())
}

返回值

FloatingObject[]

表单中所有浮动对象元素的集合


clear

clear(): void

删除表单中的所有浮动对象元素

代码示例

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

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

console.log(activeSheet.floatingObjects.all().length); // result is 2
activeSheet.floatingObjects.clear(); // removes all floating objects.
console.log(activeSheet.floatingObjects.all().length); // result is 0

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

返回值

void


get

get(name): FloatingObject

从表中通过指示名称获取一个浮动对象元素

代码示例

activeSheet.pictures.add("f2","tsoutline.png",100,60,200,100);
//button
$("#button1").click(function () {
 var pic = activeSheet.pictures.get("f2");
});

参数

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

返回值

FloatingObject

表单中带有指示名称的浮动对象元素


remove

remove(name): void

通过指示名称从表单中删除一个浮动对象元素

代码示例

activeSheet.pictures.add("f2","tsoutline.png",100,60,200,100);
//button
$("#button1").click(function () {
     activeSheet.resumePaint();
     activeSheet.pictures.remove("f2");
     activeSheet.repaint();
});

参数

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

返回值

void


zIndex

zIndex(name, zIndex?): any

获取或设置浮动对象元素的z-index

代码示例

var customFloatingObject = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f1", 20, 20, 60, 64);
var btn = document.createElement('button');
btn.style.width = "60px";
btn.style.height = "30px";
btn.innerText = "button1";
customFloatingObject.content(btn);
activeSheet.floatingObjects.add(customFloatingObject);
var customFloatingObject1 = new GC.Spread.Sheets.FloatingObjects.FloatingObject("f2", 5, 5, 30, 64);
var btn1 = document.createElement('button');
btn1.style.width = "60px";
btn1.style.height = "30px";
btn1.innerText = "button2";
customFloatingObject1.content(btn1);
activeSheet.floatingObjects.add(customFloatingObject1);
activeSheet.floatingObjects.zIndex("f2", 897);
activeSheet.floatingObjects.zIndex("f1", 898);

参数

属性名 类型 说明
name string 浮动对象元素的名称
zIndex? number 浮动对象元素的z-index

返回值

any

如果参数'z-Index'为null或undefined,它将返回带有指示名称的浮动对象元素的z-index