• Post category:ApiTableCellPr
  • Запись изменена:14.05.2023

SetNoWrap(isNoWrap)

Указывает, как размещается текущая ячейка таблицы, когда родительская таблица отображается в документе. Этот параметр влияет на поведение ячейки только в том случае, если макет таблицы ApiTablePr#SetTableLayout для этой таблицы настроен на использование алгоритма «автоподбор».

Параметры:

НазваниеТипОписание
isNoWrapлогическийЗначение true означает, что текущая ячейка таблицы не будет помещена в родительскую таблицу.

Возвращает:

Этот метод не возвращает никаких данных.

Пример

builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered"));
var oTablePr = oTableStyle.GetTablePr();
var oTable = Api.CreateTable(3, 3);
oTablePr.SetTableLayout("autofit");
oTable.SetTableLook(true, true, true, true, false, false);
oTable.SetStyle(oTableStyle);
var oCell = oTable.GetRow(0).GetCell(0);
oCell.GetContent().GetElement(0).AddText("This is a table with the autofit type of the table layout.");
oDocument.Push(oTable);
var oCopyTable1 = oTable.Copy();
oCopyTable1.SetWidth("percent", 10);
oCell = oCopyTable1.GetRow(0).GetCell(0);
oCell.Clear();
oCell.GetContent().GetElement(0).AddText("This is a table cell where text is wrapped when we try to change table width.");
var oTableCellPr = oTableStyle.GetTableCellPr();
oTableCellPr.SetNoWrap(false);
oDocument.Push(oCopyTable1);
var oCopyTable2 = oTable.Copy();
oCopyTable2.SetWidth("percent", 10);
oCell = oCopyTable2.GetRow(0).GetCell(0);
oCell.Clear();
oCell.GetContent().GetElement(0).AddText("This is a table cell where text is not wrapped when we try to change table width.");
oTableCellPr.SetNoWrap(true);
oCopyTable2.SetStyle(oTableStyle);
oDocument.Push(oCopyTable2);
builder.SaveFile("docx", "SetNoWrap.docx");
builder.CloseFile();