콘텐츠 제어 작업 SDT
그 안에 Microsoft Word,템플릿으로 시작하여 확인란,텍스트 상자,날짜 선택기 및 드롭다운 목록을 포함한 콘텐츠 컨트롤을 추가하여 양식을 만들 수 있습니다. 그 안에 Aspose.Words,구조화된 문서 태그 또는 로드된 모든 문서의 콘텐츠 제어 Aspose.Words 수입되는 StructuredDocumentTag 노드 구조화된 문서 태그(SDT 또는 콘텐츠 제어)를 통해 고객 정의 된 의미 체계와 그 동작 및 모양을 문서에 포함 할 수 있습니다. StructuredDocumentTag 다음 위치에서 문서에서 발생할 수 있습니다:
- 블록 수준-단락과 표 중에서 신체의 자식으로, HeaderFooter,주석,각주 또는 모양 노드
- 행 수준-테이블 노드의 자식으로 테이블의 행 중
- 셀 수준-테이블 행의 셀 중 행 노드의 자식으로
- 인라인 수준-단락의 자식으로 내부 인라인 콘텐츠 중
- 다른 내부에 중첩 StructuredDocumentTag
콘텐츠 컨트롤에 입력된 텍스트의 서식을 지정하는 스타일을 설정하는 방법
콘텐츠 컨트롤의 스타일을 설정하려면 다음을 사용할 수 있습니다 StructuredDocumentTag.Style
또는 StructuredDocumentTag.StyleName
속성. 출력 문서의 콘텐츠 컨트롤에 텍스트를 입력하면 입력된 텍스트에는"견적"스타일이 표시됩니다.
다음 코드 예제에서는 콘텐츠 컨트롤의 스타일을 설정하는 방법을 보여 줍니다:
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"input.docx"); | |
System::SharedPtr<StructuredDocumentTag> sdt = System::DynamicCast<StructuredDocumentTag>(doc->GetChild(NodeType::StructuredDocumentTag, 0, true)); | |
System::SharedPtr<Style> style = doc->get_Styles()->idx_get(StyleIdentifier::Quote); | |
sdt->set_Style(style); | |
System::String outputPath = outputDataDir + u"WorkingWithSDT.SetContentControlStyle.docx"; | |
// Save the document to disk. | |
doc->Save(outputPath); |
반복 섹션 콘텐츠 제어 작업
반복 섹션 콘텐츠 컨트롤은 그 안에 포함 된 콘텐츠를 반복 할 수 있습니다. 사용 Aspose.Words,반복 섹션 및 반복 섹션 항목 유형의 구조화된 문서 태그 노드를 만들 수 있으며 이를 위해, SdtType 열거형 유형은 다음을 제공합니다 RepeatingSectionItem 재산.
다음 코드 예제에서는 반복 섹션 콘텐츠 컨트롤을 테이블에 바인딩하는 방법을 보여 줍니다:
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(); | |
System::SharedPtr<DocumentBuilder> builder = System::MakeObject<DocumentBuilder>(doc); | |
System::String xml = System::String(u"<books><book><title>Everyday Italian</title><author>Giada De Laurentiis</author></book>") + | |
u"<book><title>Harry Potter</title><author>J K. Rowling</author></book>" + | |
u"<book><title>Learning XML</title><author>Erik T. Ray</author></book></books>"; | |
System::SharedPtr<CustomXmlPart> xmlPart = doc->get_CustomXmlParts()->Add(u"Books", xml); | |
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, Aspose::Words::Markup::SdtType::RepeatingSection, Aspose::Words::Markup::MarkupLevel::Row); | |
repeatingSectionSdt->get_XmlMapping()->SetMapping(xmlPart, u"/books[1]/book", u""); | |
table->AppendChild(repeatingSectionSdt); | |
System::SharedPtr<StructuredDocumentTag> repeatingSectionItemSdt = System::MakeObject<StructuredDocumentTag>(doc, Aspose::Words::Markup::SdtType::RepeatingSectionItem, Aspose::Words::Markup::MarkupLevel::Row); | |
repeatingSectionSdt->AppendChild(repeatingSectionItemSdt); | |
System::SharedPtr<Row> row = System::MakeObject<Row>(doc); | |
repeatingSectionItemSdt->AppendChild(row); | |
System::SharedPtr<StructuredDocumentTag> titleSdt = System::MakeObject<StructuredDocumentTag>(doc, Aspose::Words::Markup::SdtType::PlainText, Aspose::Words::Markup::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, Aspose::Words::Markup::SdtType::PlainText, Aspose::Words::Markup::MarkupLevel::Cell); | |
authorSdt->get_XmlMapping()->SetMapping(xmlPart, u"/books[1]/book[1]/author[1]", u""); | |
row->AppendChild(authorSdt); | |
doc->Save(outputDataDir + u"WorkingWithSDT.CreatingTableRepeatingSectionMappedToCustomXmlPart.docx"); |