Hi @Quentin, I’ve been having a similar problem lately. But I solved it by modify the source codes of document builder sdkjs.
slide/apiBuilder.js : line 709
Api.prototype.CreateTable = function(nCols, nRows, width, height, grid){
var oPresentation = private_GetPresentation();
var oSlide = private_GetCurrentSlide();
if(oPresentation && oSlide){
var oGraphicFrame = oPresentation.Create_TableGraphicFrame(nCols, nRows, oSlide, oPresentation.DefaultTableStyleId, width, height, grid);
var content = oGraphicFrame.graphicObject.Content, i;
if (!AscFormat.isRealNumber(height)) {
for(i = 0; i < content.length; ++i)
{
content[i].Set_Height(0, Asc.linerule_AtLeast );
}
}
return new ApiTable(oGraphicFrame);
}
return null;
};
slide/Editor/Format/Presentation.js : line 6088
CPresentation.prototype.Create_TableGraphicFrame = function (Cols, Rows, Parent, StyleId, Width, Height, DefaultGrid, PosX, PosY, bInline) {
var W;
if (AscFormat.isRealNumber(Width)) {
W = Width;
} else {
W = this.GetWidthMM() * 2 / 3;
}
var X, Y;
if (AscFormat.isRealNumber(PosX) && AscFormat.isRealNumber(PosY)) {
X = PosX;
Y = PosY;
} else {
X = (this.GetWidthMM() - W) / 2;
Y = this.GetHeightMM() / 5;
}
var Inline = false;
if (AscFormat.isRealBool(bInline)) {
Inline = bInline;
}
var Grid = [];
if (Array.isArray(DefaultGrid) && Cols === DefaultGrid.length) {
Grid = DefaultGrid
} else {
for (var Index = 0; Index < Cols; Index++)
Grid[Index] = W / Cols;
}
...
After above modification, you can create table by document builder as follows:
var oPresentation = Api.GetPresentation();
var oSlide = oPresentation.GetCurrentSlide();
var slideWidth = oSlide.GetWidth() / 36000
var tableWidth = slideWidth - 20
var tableHeight = slideWidth / 3
var oTable = Api.CreateTable(2, 4, tableWidth, tableHeight, [tableWidth / 4, tableWidth * 3 / 4]);
The effect is shown below: