Aspose::Words::Tables::RowFormat::get_Height метод
Содержание
[
Скрывать
]RowFormat::get_Height method
Получает или задает высоту строки таблицы в пунктах.
double Aspose::Words::Tables::RowFormat::get_Height()
Примеры
Показывает, как создать отформатированную таблицу с использованием DocumentBuilder.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
System::SharedPtr<Aspose::Words::Tables::Table> table = builder->StartTable();
builder->InsertCell();
table->set_LeftIndent(20);
// Установите некоторые параметры форматирования текста и внешнего вида таблицы.
builder->get_RowFormat()->set_Height(40);
builder->get_RowFormat()->set_HeightRule(Aspose::Words::HeightRule::AtLeast);
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::FromArgb(198, 217, 241));
builder->get_ParagraphFormat()->set_Alignment(Aspose::Words::ParagraphAlignment::Center);
builder->get_Font()->set_Size(16);
builder->get_Font()->set_Name(u"Arial");
builder->get_Font()->set_Bold(true);
// Настройка параметров форматирования в построителе документа применит их
// к текущей ячейке/строке, в которой находится курсор,
// а также к любым новым ячейкам и строкам, созданным с помощью этого построителя.
builder->Write(u"Header Row,\n Cell 1");
builder->InsertCell();
builder->Write(u"Header Row,\n Cell 2");
builder->InsertCell();
builder->Write(u"Header Row,\n Cell 3");
builder->EndRow();
// Перенастройте объекты форматирования построителя для новых строк и ячеек, которые мы собираемся создать.
// The builder will not apply these to the first row already created so that it will stand out as a header row.
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_White());
builder->get_CellFormat()->set_VerticalAlignment(Aspose::Words::Tables::CellVerticalAlignment::Center);
builder->get_RowFormat()->set_Height(30);
builder->get_RowFormat()->set_HeightRule(Aspose::Words::HeightRule::Auto);
builder->InsertCell();
builder->get_Font()->set_Size(12);
builder->get_Font()->set_Bold(false);
builder->Write(u"Row 1, Cell 1.");
builder->InsertCell();
builder->Write(u"Row 1, Cell 2.");
builder->InsertCell();
builder->Write(u"Row 1, Cell 3.");
builder->EndRow();
builder->InsertCell();
builder->Write(u"Row 2, Cell 1.");
builder->InsertCell();
builder->Write(u"Row 2, Cell 2.");
builder->InsertCell();
builder->Write(u"Row 2, Cell 3.");
builder->EndRow();
builder->EndTable();
doc->Save(get_ArtifactsDir() + u"DocumentBuilder.CreateFormattedTable.docx");
Показывает, как форматировать строки с помощью Document Builder.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
System::SharedPtr<Aspose::Words::Tables::Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, cell 1.");
// Начните вторую строку, а затем настройте её высоту. Builder применит эти настройки к
// текущей строке, а также всем новым строкам, которые он создаст позже.
builder->EndRow();
System::SharedPtr<Aspose::Words::Tables::RowFormat> rowFormat = builder->get_RowFormat();
rowFormat->set_Height(100);
rowFormat->set_HeightRule(Aspose::Words::HeightRule::Exactly);
builder->InsertCell();
builder->Write(u"Row 2, cell 1.");
builder->EndTable();
// Первая строка не пострадала от переустановки отступов и по‑прежнему содержит значения по умолчанию.
ASPOSE_ASSERT_EQ(0.0, table->get_Rows()->idx_get(0)->get_RowFormat()->get_Height());
ASSERT_EQ(Aspose::Words::HeightRule::Auto, table->get_Rows()->idx_get(0)->get_RowFormat()->get_HeightRule());
ASPOSE_ASSERT_EQ(100.0, table->get_Rows()->idx_get(1)->get_RowFormat()->get_Height());
ASSERT_EQ(Aspose::Words::HeightRule::Exactly, table->get_Rows()->idx_get(1)->get_RowFormat()->get_HeightRule());
doc->Save(get_ArtifactsDir() + u"DocumentBuilder.SetRowFormatting.docx");
См. также
- Class RowFormat
- Namespace Aspose::Words::Tables
- Library Aspose.Words for C++