私も同様の問題がありました。私の場合、番号付きリストのGLYPH_TYPEも失われてしまいました。 しかし、CellChildrenを1つずつコピーすると画像が正常にコピーされることが検出されました。
私は新しいテーブルを全体的にコピーしてから、各dstTableセルの内容を元のテーブルから1つずつ置き換えて問題を解決しました。
テーブル内の別のテーブルが検出された場合、この関数はそれ自身を呼び出しますので、これはネストしたテーブルでも正常に機能します。 また、挿入後に属性を追加設定することで、失われたListItem属性の問題も解決されます。ここで
は私も働いコードセグメントである:
は、まず私は、テーブルを検出し、dstBodyに挿入...
...
dstChild = srcChild.copy();
switch(dstChild.getType()) {
case DocumentApp.ElementType.PARAGRAPH:
...
case DocumentApp.ElementType.LIST_ITEM:
...
case DocumentApp.ElementType.TABLE:
var newTable =
dstBody.insertTable(dstBody.getNumChildren()-1, dstChild);
copyTableCellByCell(dstChild, newTable);
break;
....
}
そして、これが最初で、各セルに取って代わるかもしれない再帰関数でありますそれを消去してオリジナルのテーブルからコンテンツをコピーすることができます。
function copyTableCellByCell(srcTable, dstTable) {
var numRows = dstTable.getNumRows();
var dstRow, numCells, dstCell, actCellIndex;
for (var actRowIndex = 0; actRowIndex < numRows; actRowIndex++) {
dstRow = dstTable.getRow(actRowIndex);
numCells = dstRow.getNumCells();
for (actCellIndex = 0; actCellIndex < numCells; actCellIndex++) {
dstCell = dstRow.getCell(actCellIndex);
dstCell.clear();
var srcCell = srcTable.getCell(actRowIndex, actCellIndex);
var numCellChildren = srcCell.getNumChildren();
for (var y = 0; y < numCellChildren; y++) {
var cellChild = srcCell.getChild(y);
var childCopy = cellChild.copy();
switch(childCopy.getType()) {
case DocumentApp.ElementType.PARAGRAPH:
dstCell.insertParagraph(y, childCopy);
break;
case DocumentApp.ElementType.LIST_ITEM:
// that the GLYPH_TYPE doesn't get lost
var atts = childCopy.getAttributes();
var
newListItem = dstCell.insertListItem(y, childCopy);
newListItem.setAttributes(atts);
break;
case DocumentApp.ElementType.TABLE:
var newTable =
dstCell.insertTable(y, childCopy);
copyTableCellByCell(cellChild, newTable);
break;
}
}
// remove the very first empty paragraph in the cell
while ((y = dstCell.getNumChildren()) > numCellChildren) {
dstCell.getChild(y - 1).removeFromParent();
}
}
}
}
もちろん、これは微調整できます。 サーバーで作業する必要がないようにするには、インラインイメージを検索して選択するだけです。
これはどのような点でも役立ちます。 は、私がこのバグに対する解決策をコーディングどれも見つからなかっ
リチャード