[]
Sheets.FloatingObjects.FloatingObjectCollection
• new FloatingObjectCollection(sheet?
, typeName?
)
Represents a floating object manager that managers all floating objects in a sheet.
Name | Type | Description |
---|---|---|
sheet? |
Worksheet |
The worksheet. |
typeName? |
string |
The type name. |
▸ add(floatingObjectOrName
, src?
, x?
, y?
, width?
, height?
): FloatingObject
Adds a floating object to the sheet. The arguments has 2 modes. If there is 1 parameter, the parameter is floatingObject which is a GC.Spread.Sheets.FloatingObjects.FloatingObject type. If there are 6 parameters, the parameters are name, src, x, y, width, and 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);
Name | Type | Description |
---|---|---|
floatingObjectOrName |
string | FloatingObject |
The floating object that will be added to the sheet, or the name of the picture that will be added to the sheet. |
src? |
string |
The image source of the picture. |
x? |
number |
The x location of the picture. |
y? |
number |
The y location of the picture. |
width? |
number |
The width of the picture. |
height? |
number |
The height of the picture. |
The floating object that has been added to the sheet.
▸ all(): FloatingObject
[]
Gets all of the floating objects in the sheet.
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())
}
The collection of all the floating objects in the sheet.
▸ clear(): void
Removes all floating objects in the sheet.
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); // 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(name
): FloatingObject
Gets a floating object from the sheet by the indicate name.
example
activeSheet.pictures.add("f2","tsoutline.png",100,60,200,100);
//button
$("#button1").click(function () {
var pic = activeSheet.pictures.get("f2");
});
Name | Type | Description |
---|---|---|
name |
string |
The name of the floating object. |
The floating object in the sheet with the indicate name.
▸ remove(name
): void
Removes a floating object from the sheet by the indicate name.
example
activeSheet.pictures.add("f2","tsoutline.png",100,60,200,100);
//button
$("#button1").click(function () {
activeSheet.resumePaint();
activeSheet.pictures.remove("f2");
activeSheet.repaint();
});
Name | Type | Description |
---|---|---|
name |
string |
The name of the floating object. |
void
▸ zIndex(name
, zIndex?
): any
Gets or sets the z-index of floating object.
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);
Name | Type | Description |
---|---|---|
name |
string |
The name of the floatingObject. |
zIndex? |
number |
The z-index of the floating object. |
any
If the parameter 'zIndex' is null or undefined,it will return the z-index of the floating object with the indicate name.