Answered
セルの結合について
- October 11, 2024
- 2 replies
- 1096 views
Copy the code below and paste it in a plain text file. Save it with a .jsx extension. Click in the table and choose File > Script > Run and select the script. It should do what you want. Please let me know if you have any questions or comments.
main ();
function main () {
var doc;
doc = app.ActiveDoc;
if (doc.ObjectValid () === 1) {
processDoc (doc);
}
}
function processDoc (doc) {
var tbl;
// Make sure the cursor is in a table.
tbl = doc.SelectedTbl;
if (tbl.ObjectValid () === 1) {
if (app.Displaying === 1) {
app.Displaying = 0;
}
processTbl (tbl, doc);
if (app.Displaying === 0) {
app.Displaying = 1;
doc.Rehyphenate ();
doc.Redisplay ();
}
}
}
function processTbl (tbl, doc) {
var row, cell;
// Go to the first body row.
row = tbl.FirstRowInTbl.NextRowInTbl;
// Go to the second cell.
cell = row.FirstCellInRow.NextCellInRow;
// Loop through the cells in the second column.
while (cell.ObjectValid () === 1) {
if ((cell.CellIsStraddled === 0) && (cell.CellNumColsStraddled === 1)) {
if (cellToRightIsEmpty (cell) === true) {
cell.StraddleCells (1, 2); // rows, columns
}
}
cell = cell.CellBelowInCol;
}
}
function cellToRightIsEmpty (cell) {
var textList;
cell = cell.NextCellInRow;
if (cell.ObjectValid () === 1) {
if (cell.FirstPgf.id === cell.LastPgf.id) {
textList = cell.FirstPgf.GetText (Constants.FTI_PgfEnd);
if (textList[0].offset === 0) {
return true;
}
}
}
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.