How can I tell if the last row has an "ABC" cell style applied?
It doesn't seem right for me to write it this way.
The result in if is always false.
if(table.rows[-1].cells.everyItem().appliedCellStyle.name!=="ABC"){
. . .
}
It doesn't seem right for me to write it this way.
The result in if is always false.
if(table.rows[-1].cells.everyItem().appliedCellStyle.name!=="ABC"){
. . .
}
Hi rob day.
table.rows[-1].cells.everyItem().texts.everyItem().pointSize = 0.1;
How this sentence is written inside { } is now incorrect.
Also, it won't let me just write height: 1.058mm?
table.rows[-1].cells.everyItem().properties = {
appliedCellStyle: "ABC",
contents: "",
texts.everyItem().pointSize: 0.1,
bottomEdgeStrokeWeight: 0,
leftEdgeStrokeWeight: 0,
rightEdgeStrokeWeight: 0,
topInset:0,
leftInset: 0,
bottomInset: 0,
rightInset: 0,
autoGrow: false,
height: 1.058,
}
table.rows[-1].cells.everyItem().texts.everyItem().pointSize = 0.1;
You would have to set the text properties separately. Also top, left, bottom, and rightInset have been deprecated to textTopInset (ect), And if you don’t want to set ruler or scripting units, use a string like this "1.058 mm":
//the first table in the active document
var t1 = app.activeDocument.stories[0].tables[0]
//all the cells in the last row
var lrc = t1.rows[-1].cells.everyItem().getElements();
var b = false
//check each cell of the last row. If any of the applied cell syle names are ABC set b to true
for (var i = 0; i < lrc.length; i++){
if (lrc[i].appliedCellStyle.name == "ABC") {
b = true;
}
};
// make a new row and set every cell style to "ABC"
if (!b) {
t1.rows.add();
//set cell properties
t1.rows[-1].cells.everyItem().properties = { appliedCellStyle: "ABC", height: "1.058 mm", textTopInset: 0}
//set cell text properties
t1.rows[-1].cells.everyItem().texts.everyItem().properties = {pointSize: 0.1}
}
alert(b + ": Add Row")Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.