Trying to insert a shape equal to the table cell size.
I created the shape using InsertShape() and copied the height of row (possibly height of cell), width of column (possibly width of cell) to the shape.
Problem :
- size of shape is not equal to cell size in height and width.
- The text inside the shape is going out of shape, text of shape should be auto fit, while the text of the cell fits inside the cell.
I can't say how .getRow().getMinimumHeight() works.
Text length not fixed. It could be like a long paragraph.
Limitation of Google Apps Script :
Table Cell - Google Apps Script can't get the width and height of each cell
Google Apps Script:
let activePresentation = SlidesApp.getActivePresentation()
let selection = activePresentation.getSelection()
let pageElements = selection.getPageElementRange().getPageElements()
//get table Left, table Top of each table under the pageElement object
var tableLeft = pageElements[0].asTable().getLeft(),
tableTop = pageElements[0].asTable().getTop();
var cellTop = tableTop; //cell top possible equal to table top
var cellLeft = tableLeft; //cell top possible equal to table Left
//get the row height and column width
var rowHeight = pageElements[0].asTable().getRow(0).getMinimumHeight();
var columnWidth = pageElements[0].asTable().getColumn(0).getWidth();
//get the internal text of cell
var cellText = pageElements[0].asTable().getCell(0, 0).getText().asString()
//insert shape equal to the table cell size
var shape_t = selection.getCurrentPage()
.insertShape(SlidesApp.ShapeType.RECTANGLE,
cellLeft+200,
cellTop,
columnWidth,
rowHeight);
//set the cell text insde the Shape
shape_t.getText().setText(cellText);
Here you can see the demo https://docs.google.com/presentation/d/10nupvk-2BZDSV6-gPn_n2LkrUtkCxot7qr_jcZGBHqw/edit?usp=sharing
Full Script : https://pastebin.com/CrV3qHwG
Replicate Issue Paste above mentioned https://pastebin.com/CrV3qHwG script in Google Script Editor, Add a table with 1 row and 1 column, obviously it will be only one cell. Select the table and then run the script by clicking on "Create Shape" from the "Test So" menu.
Image shows problem and expected result in quick view
