The problem of the border of the created table becoming a dashed line after refreshing the page

When creating multiple tables using the ‘CreateTable’ API, refreshing the page causes the border of the first table to become a dashed line.

          var oTable = Api.CreateTable(2, 4);
          oTable.SetWidth('percent', 100);
          let tableStyle = oDocument.CreateStyle('CustomTableStyle', 'table');
          tableStyle.GetTablePr().SetTableBorderTop('single', 2, 0, 0, 0, 0);
          tableStyle.GetTablePr().SetTableBorderBottom('single', 2, 0, 0, 0, 0);
          tableStyle.GetTablePr().SetTableBorderLeft('single', 2, 0, 0, 0, 0);
          tableStyle.GetTablePr().SetTableBorderRight('single', 2, 0, 0, 0, 0);
          tableStyle.GetTablePr().SetTableBorderInsideV('single', 2, 0, 0, 0, 0);
          tableStyle.GetTablePr().SetTableBorderInsideH('single', 2, 0, 0, 0, 0);
          let tableStylePr = tableStyle.GetConditionalTableStyle('wholeTable');
          tableStylePr.GetTableRowPr().SetHeight('auto');
          oTable.SetStyle(tableStyle);

          let cellWidth = Math.floor(100 / oTable.GetRow(0).GetCellsCount());
          for (var row = 0; row < oTable.GetRowsCount(); row++) {
            for (var col = 0; col < oTable.GetRow(row).GetCellsCount(); col++) {
              var oCell = oTable.GetRow(row).GetCell(col);
              oCell.SetWidth('percent', cellWidth);
              var oPara = oCell.GetContent().GetElement(0);
              oPara.SetStyle(sTable);
            }
          }

ONLYOFFICE Version: 9.0.0

Hello @jinwen

First of all, please note that you are using outdated version of Document Server/Desktop Editors. Can you confirm if the same behavior occurs on the latest version 9.3.1? I cannot test this code, because it is incomplete - sTable variable is not defined.

This issue still exists in version 9.3.1.

(function (window, undefined) {
  window.Asc.plugin.init = function () {
    window.Asc.plugin.callCommand(
      function () {
        var oDocument = Api.GetDocument();
        var sTable = oDocument.GetStyle('标准文件_表格');

        if (!sTable) {
          console.error("未找到'标准文件_表格'样式");
          return { error: "未找到'标准文件_表格'样式" };
        }

        try {
          var oTable = Api.CreateTable(4, 3);
          oTable.SetWidth('percent', 100);
          let tableStyle = oDocument.CreateStyle('CustomTableStyle', 'table');
          tableStyle.GetTablePr().SetTableBorderTop('single', 2, 0, 0, 0, 0);
          tableStyle.GetTablePr().SetTableBorderBottom('single', 2, 0, 0, 0, 0);
          tableStyle.GetTablePr().SetTableBorderLeft('single', 2, 0, 0, 0, 0);
          tableStyle.GetTablePr().SetTableBorderRight('single', 2, 0, 0, 0, 0);
          tableStyle.GetTablePr().SetTableBorderInsideV('single', 2, 0, 0, 0, 0);
          tableStyle.GetTablePr().SetTableBorderInsideH('single', 2, 0, 0, 0, 0);
          let tableStylePr = tableStyle.GetConditionalTableStyle('wholeTable');
          tableStylePr.GetTableRowPr().SetHeight('auto');
          oTable.SetStyle(tableStyle);

          let cellWidth = Math.floor(100 / oTable.GetRow(0).GetCellsCount());
          for (var row = 0; row < oTable.GetRowsCount(); row++) {
            for (var col = 0; col < oTable.GetRow(row).GetCellsCount(); col++) {
              var oCell = oTable.GetRow(row).GetCell(col);
              oCell.SetWidth('percent', cellWidth);
              var oPara = oCell.GetContent().GetElement(0);
              oPara.SetStyle(sTable);
            }
          }

          oDocument.InsertContent([oTable]);
        } catch (error) {
          console.error('创建表格失败:', error);
          return { error: error.message };
        }
      },
      false,
      true,
      function (result) {
        if (result && result.error) {
          window.Asc.plugin.executeMethod('ShowError', ['插入表格失败:' + result.error]);
        }
        window.Asc.plugin.executeCommand('close', '');
      }
    );
  };

  window.Asc.plugin.button = function () {
    window.Asc.plugin.executeCommand('close', '');
  };
})(window, undefined);

Thank you for the sample, I was able to reproduce the issue. I have forwarded all necessary information to the QA team for analysis, please await the feedback.

UPD: the bug 80950 has been registered on this issue.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.