Spire.Doc for C++ 14.1.4 现已发布,该版本同步了一系列 Spire.Doc for .NET 的功能,主要集中于表格和列表相关的功能。具体更新如下。
新功能:
- Bookmark 类新增 GetFirstColumn和 GetLastColumn属性,支持获取书签在表格中的首末列索引。
- TableFormat 类新增SetStyle、SetStyleOptions和SetStyleName属性支持操作表格样式。
int firstColumn = doc->GetBookmarks()->FindByName(L"t_insert")->GetFirstColumn();
int lastColumn = doc->GetBookmarks()->FindByName(L"t_insert")->GetLastColumn();
intrusive_ptr<TableStyle> tableStyle = Object::Dynamic_cast<TableStyle>(
doc->GetStyles()->Add(StyleType::TableStyle, L"TestTableStyle1")
);
tableStyle->GetBorders()->SetColor(Color::GetBlue());
tableStyle->GetBorders()->SetBorderType(BorderStyle::Single);
tableStyle->SetHorizontalAlignment(RowAlignment::Center);
intrusive_ptr<Table> table = sec->AddTable();
table->ResetCells(1, 1);
table->GetRows()->GetItemInRowCollection(0)
->GetCells()->GetItemInCellCollection(0)
->AddParagraph()->AppendText(L"Aligned to the center of the page");
table->SetPreferredWidth(PreferredWidth::FromPoints(300));
table->ApplyStyle(tableStyle);
sec->AddParagraph()->AppendText(L"");
tableStyle = Object::Dynamic_cast<TableStyle>(
doc->GetStyles()->Add(StyleType::TableStyle, L"TestTableStyle2")
);
tableStyle->SetLeftIndent(55);
tableStyle->GetBorders()->SetColor(Color::GetGreen());
tableStyle->GetBorders()->SetBorderType(BorderStyle::Single);
table = sec->AddTable();
table->ResetCells(1, 1);
table->GetRows()->GetItemInRowCollection(0)
->GetCells()->GetItemInCellCollection(0)
->AddParagraph()->AppendText(L"Aligned according to left indent");
table->SetPreferredWidth(PreferredWidth::FromPoints(300));
table->GetFormat()->SetStyle(tableStyle);
intrusive_ptr<TableStyle> tableStyle = Object::Dynamic_cast<TableStyle>(
doc->GetStyles()->Add(StyleType::TableStyle, L"TestTableStyle1")
);
tableStyle->GetBorders()->SetColor(Color::GetBlack());
tableStyle->GetBorders()->SetBorderType(BorderStyle::Double);
tableStyle->SetRowStripe(3);
tableStyle->GetConditionalStyles()->GetItem(TableConditionalStyleType::OddRowStripe)
->GetShading()->SetBackgroundPatternColor(Color::GetLightBlue());
tableStyle->GetConditionalStyles()->GetItem(TableConditionalStyleType::EvenRowStripe)
->GetShading()->SetBackgroundPatternColor(Color::GetLightCyan());
tableStyle->SetColumnStripe(1);
tableStyle->GetConditionalStyles()->GetItem(TableConditionalStyleType::EvenColumnStripe)
->GetShading()->SetBackgroundPatternColor(Color::GetLightPink());
table->ApplyStyle(tableStyle);
table->GetFormat()->SetStyleOptions(TableStyleOptions::ColumnStripe);
tableStyle = Object::Dynamic_cast<TableStyle>(
doc->GetStyles()->Add(StyleType::TableStyle, L"TestTableStyle3")
);
tableStyle->SetLeftIndent(55);
tableStyle->GetBorders()->SetColor(Color::GetGreen());
tableStyle->GetBorders()->SetBorderType(BorderStyle::Single);
tableStyle->SetHorizontalAlignment(RowAlignment::Right);
table = sec->AddTable();
table->ResetCells(1, 1);
table->GetRows()->GetItemInRowCollection(0)
->GetCells()->GetItemInCellCollection(0)
->AddParagraph()->AppendText(L"Aligned according to left indent");
table->SetPreferredWidth(PreferredWidth::FromPoints(300));
table->GetFormat()->SetStyleName(L"TestTableStyle3");
document->GetStyles()->GetItem(L"Normal")->RemoveSelf();
intrusive_ptr<Document> doc = ConvertUtil::GetNewEngineDocument();
intrusive_ptr navigator = new DocumentNavigator(doc);
doc->LoadFromFile(inputFile.c_str());
navigator->MoveToDocumentStart();
navigator->Writeln(L"Test insert at DocumentStart");
navigator->Writeln(L"Test insert without move");
navigator->MoveToDocumentEnd();
navigator->Writeln(L"Test insert at DocumentEnd");
doc->SaveToFile(outputFile.c_str(), FileFormat::Docx);
doc->Close();
| 类名 | 新功能 | 功能描述 |
|---|---|---|
| Paragraph | GetText | 获取段落的文本内容 |
| Table | SetBorders, ClearBorders |
设置表格边框样式;清除表格的所有边框格式 |
| CellFormat | ClearFormatting | 清除单元格的所有格式 |
| Borders | ClearFormatting, IsShadow |
清除边框格式设置;控制边框是否显示阴影效果 |
| RowFormat | ClearBackground, Height | 清除行背景色;设置行高 |
| StyleCollection | Add (重载) | 新增样式添加重载 |
| PreferredWidth | FromPercent, FromPoints |
宽度数据类型 |
| CharacterFormat | LocaleIdBi | 支持双向文本的区域设置 |
| Frame | IsFrame | 判断对象是否为 Frame |
| OfficeMath | ToLaTexMathCode, FromOMMLCode |
将公式对象转换为 LaTeX 数学代码;从 OMML 字符串创建公式对象 |
| 类名 | 新功能 | 功能描述 |
|---|---|---|
| CompareOptions | IgnoreTable、IgnoreHeadersAndFooters | 比较时可忽略表格内容、页眉页脚 |
| DifferRevisions | MoveToRevisions、MoveFromRevisions | 获取"移动到"和"从...移动"类型的修订 |
| StructureDocumentTag* (含 Cell/Inline/Row) | RemoveSelfOnly | 仅移除内容控件本身,保留其包含的内容 |
| 类名 | 新功能 | 功能描述 |
|---|---|---|
| ToPdfParameterList | PdfImageCompression、 DigitalSignatureInfo | 保存到PDF时配置图像压缩以及数字签名信息 |
| Document | MarkdownExportOptions、 ListReferences | 支持 Markdown 导出选项及列表引用 |
| 类名 | 新功能 | 功能描述 |
|---|---|---|
| ListFormat | ApplyStyle, ApplyListRef | 支持直接引用和快速设置 |
| ListLevel | Equals, CreatePictureBullet, DeletePictureBullet, PictureBullet | 支持图片项目符号及比较操作 |
| ListStyle | ListRef, BaseStyle | 支持列表引用与基础样式 |
| Document | ListReferences | 获取文档中的列表引用集合 |
获取Spire.Doc for C++ 14.1.4请点击:







