Word开发工具功能推荐:使用Aspose.Words for C ++创建重复节内容控件

Aspose.Words for C ++与其等效的.NET版本的API相比有一些差异:

  • 当前版本不支持加密功能-无法验证,签名,加密或解密文档。
  • 当前版本不支持从Internet下载远程资源。
  • 当前版本不支持计量许可证。
  • 当前版本不支持多页TIFF格式。
  • 当前版本不支持LINQ和 告功能。
  • 当前版本对数据库功能的支持有限-C ++没有用于DB的通用API,例如.Net System.Data。
  • 当前版本仅支持Microsoft Visual C ++版本2015或更高版本,并且仅支持x64平台。

重复部分内容控件允许重复其中包含的内容。为此,SdtType枚举类型提供了RepeatingSectionItem属性。下面的代码示例演示如何将Word文档中的重复节内容控件绑定到表。

System::SharedPtr<Document> doc = System::MakeObject<Document>();    System::SharedPtr<DocumentBuilder> builder = System::MakeObject<DocumentBuilder>(doc);    System::SharedPtr<CustomXmlPart> xmlPart = doc->get_CustomXmlParts()->Add(u"Books", u"<books><book><title>Everyday Italian</title><author>Giada De Laurentiis</author></book><book><title>Harry Potter</title><author>J K. Rowling</author></book><book><title>Learning XML</title><author>Erik T. Ray</author></book></books>");    System::SharedPtr<Table> table = builder->StartTable();    builder->InsertCell();    builder->Write(u"Title");    builder->InsertCell();    builder->Write(u"Author");    builder->EndRow();    builder->EndTable();    System::SharedPtr <StructuredDocumentTag> repeatingSectionSdt = System::MakeObject<StructuredDocumentTag>(doc, SdtType::RepeatingSection, MarkupLevel::Row);    repeatingSectionSdt->get_XmlMapping()->SetMapping(xmlPart, u"/books[1]/book", u"");    table->AppendChild(repeatingSectionSdt);    System::SharedPtr <StructuredDocumentTag> repeatingSectionItemSdt = System::MakeObject<StructuredDocumentTag>(doc, SdtType::RepeatingSectionItem, MarkupLevel::Row);    repeatingSectionSdt->AppendChild(repeatingSectionItemSdt);    System::SharedPtr<Row> row = System::MakeObject<Row>(doc);    repeatingSectionItemSdt->AppendChild(row);    System::SharedPtr <StructuredDocumentTag> titleSdt = System::MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Cell);    titleSdt->get_XmlMapping()->SetMapping(xmlPart, u"/books[1]/book[1]/title[1]", u"");    row->AppendChild(titleSdt);    System::SharedPtr <StructuredDocumentTag> authorSdt = System::MakeObject<StructuredDocumentTag>(doc, SdtType::PlainText, MarkupLevel::Cell);    authorSdt->get_XmlMapping()->SetMapping(xmlPart, u"/books[1]/book[1]/author[1]", u"");    row->AppendChild(authorSdt);    doc->Save(outputDataDir + u"Document.docx");

将自定义文档属性链接到书签

“ Aspose.Words for C ++” API现在提供了一种方法CustomDocumentProperties.addLinkToContent(String,String)来创建新的“链接至内容”自定义文档属性,该属性将返回新创建的属性对象;如果链接源无效,则返回null。下面的代码示例演示如何配置到内容定制属性的链接。

System::SharedPtrdoc = System::MakeObject(inputDataDir + u"test.docx");// Retrieve a list of all custom document properties from the file.System::SharedPtrcustomProperties = doc->get_CustomDocumentProperties();// Add linked to content property.System::SharedPtrcustomProperty = customProperties->AddLinkToContent(u"PropertyName", u"BookmarkName");// Also, accessing the custom document property can be performed by using the property name.customProperty = customProperties->idx_get(customProperties->IndexOf(u"PropertyName"));// Check whether the property is linked to content.bool isLinkedToContent = customProperty->get_IsLinkToContent();// Get the source of the property.System::String source = customProperty->get_LinkSource();// Get the value of the property.System::String value = customProperty->get_Value()->ToString();

ASPOSE技术交流QQ群()已开通,各类资源及时分享,欢迎交流讨论!

如果你对Aspose的产品感兴趣或有任何技术难题都可以扫描下方二维码告诉我们哦~

↓↓↓

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年9月20日
下一篇 2019年9月20日

相关推荐

发表回复

登录后才能评论