[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
在线咨询 立即试用
(Showing Draft Content)

GC.Spread.Sheets.FloatingObjects.FloatingObjectCollection

Class: FloatingObjectCollection

Sheets.FloatingObjects.FloatingObjectCollection

Table of contents

Constructors

Methods

Constructors

constructor

• new FloatingObjectCollection(sheet?, typeName?)

表示一个浮动对象管理器,用于管理工作表中的所有浮动对象。

Parameters

Name Type Description
sheet? Worksheet 工作表。
typeName? string 类型名称。

Methods

add

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

向工作表中添加浮动对象。 参数有两种模式: 如果只有1个参数,该参数是floatingObject,类型为GC.Spread.Sheets.FloatingObjects.FloatingObject。 如果有6个参数,参数分别是name、src、x、y、width和height。

example

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

Parameters

Name Type Description
floatingObjectOrName string | FloatingObject 要添加到工作表的浮动对象,或要添加到工作表的图片名称。
src? string 图片的图像源。
x? number 图片的x位置。
y? number 图片的y位置。
width? number 图片的宽度。
height? number 图片的高度。

Returns

FloatingObject

已添加到工作表的浮动对象。


all

▸ all(): FloatingObject[]

获取工作表中的所有浮动对象。

example

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())
}

Returns

FloatingObject[]

工作表中所有浮动对象的集合。


clear

▸ clear(): void

移除工作表中的所有浮动对象。

example

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); // 结果是 2
activeSheet.floatingObjects.clear(); // 移除所有浮动对象
console.log(activeSheet.floatingObjects.all().length); // 结果是 0

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

Returns

void


get

▸ get(name): FloatingObject

通过指定名称获取工作表中的浮动对象。

example

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

Parameters

Name Type Description
name string 浮动对象的名称。

Returns

FloatingObject

工作表中具有指定名称的浮动对象。


remove

▸ remove(name): void

通过指定名称从工作表中移除浮动对象。

example

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

Parameters

Name Type Description
name string 浮动对象的名称。

Returns

void


zIndex

▸ zIndex(name, zIndex?): any

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

example

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

Parameters

Name Type Description
name string 浮动对象的名称。
zIndex? number 浮动对象的z-index。

Returns

any

如果参数'zIndex'为null或undefined,则返回具有指定名称的浮动对象的z-index。