Razvijalci C++ lahko preprosto ustvarijo DOCX samo z uporabo našega zmogljivega API ja izdelka. To pomeni, da bo naša rešitev programerjem zagotovila vse, kar potrebujejo za ustvarjanje DOCX v C++.
Z našo knjižnico C++ lahko razvijalci preprosto ustvarijo DOCX iz nič. Za to morajo razvijalci C++ izvesti le nekaj korakov:
Omeniti velja, da naj bi prazen dokument tehnično vseboval en odstavek, tako da boste, ko programsko ustvarite DOCX dokument, dobili točno to osnovno strukturo dokumenta.
Upoštevajte, da lahko takoj dodate vsebino v novo ustvarjeno DOCX datoteko. Tako ne boste dobili le praznega dokumenta, temveč dokument s potrebno vsebino. Za več informacij o urejanju dokumenta glejte stran Urejanje.
Ta knjižnica C++ vam omogoča programsko ustvarjanje DOCX dokumentov. Preizkusite našo zmogljivo funkcionalnost in si oglejte, kako ustvariti DOCX v nekaterih formatih z naslednjim primerom:
dotnet add package Aspose.Words.Cpp
Kopirati
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto font = builder->get_Font();
font->set_Name(u"Courier New");
font->set_Color(System::Drawing::Color::get_Blue());
font->set_Size(36);
font->set_HighlightColor(System::Drawing::Color::get_Yellow());
builder->Write(u"Morbi enim nunc faucibus a.");
doc->Save(u"Output.docx");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Če je NextSibling nič, je to najverjetneje zadnji Run v odstavku.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
doc->Save(u"Output.docx");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Če je NextSibling nič, je to najverjetneje zadnji Run v odstavku.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->get_OutlineOptions()->get_BookmarksOutlineLevels()->Add(u"Aspose bookmark", 1);
doc->Save(u"Output.docx", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto run = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed.");
auto para = doc->get_FirstSection()->get_Body()->get_FirstParagraph();
para->AppendChild(run);
auto comment = MakeObject<Comment>(doc, u"John Doe", u"JD", System::DateTime::get_Today());
comment->SetText(u"Quisque fringilla leo.");
auto commentRangeStart = MakeObject<CommentRangeStart>(doc, comment->get_Id());
auto commentRangeEnd = MakeObject<CommentRangeEnd>(doc, comment->get_Id());
run->get_ParentNode()->InsertBefore(commentRangeStart, run);
run->get_ParentNode()->InsertAfter(commentRangeEnd, run);
commentRangeEnd->get_ParentNode()->InsertAfter(comment, commentRangeEnd);
comment->AddReply(u"Jane Doe", u"JD", System::DateTime::get_Now(),
u"Pellentesque vel sapien justo.");
doc->Save(u"Output.docx");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Če je NextSibling nič, je to najverjetneje zadnji Run v odstavku.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
doc->Save(u"Output.docx");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Če je NextSibling nič, je to najverjetneje zadnji Run v odstavku.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->get_OutlineOptions()->get_BookmarksOutlineLevels()->Add(u"Aspose bookmark", 1);
doc->Save(u"Output.docx", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Če je NextSibling nič, je to najverjetneje zadnji Run v odstavku.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
doc->Save(u"Output.docx");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Če je NextSibling nič, je to najverjetneje zadnji Run v odstavku.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
doc->Save(u"Output.docx");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Če je NextSibling nič, je to najverjetneje zadnji Run v odstavku.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->get_OutlineOptions()->get_BookmarksOutlineLevels()->Add(u"Aspose bookmark", 1);
doc->Save(u"Output.docx", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto shape = builder->InsertChart(ChartType::Pie, 432, 252);
auto chart = shape->get_Chart();
chart->get_Title()->set_Text(u"Demo Chart");
chart->get_Series()->Clear();
chart->get_Series()->Add(u"Series 1",
MakeArray<String>({ u"Category1", u"Category2", u"Category3" }),
MakeArray<double>({ 2.7, 3.2, 0.8 }));
doc->Save(u"Output.docx");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Če je NextSibling nič, je to najverjetneje zadnji Run v odstavku.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
doc->Save(u"Output.docx");
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto firstRun = MakeObject<Run>(doc, u"Proin eros metus, sagittis sed. ");
auto secondRun = MakeObject<Run>(doc, u"Morbi enim nunc faucibus a.");
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(firstRun);
doc->get_FirstSection()->get_Body()->get_FirstParagraph()->AppendChild(secondRun);
builder->MoveTo(secondRun);
builder->StartBookmark(u"Aspose bookmark");
// Če je NextSibling nič, je to najverjetneje zadnji Run v odstavku.
if (secondRun->get_NextSibling() != NULL)
builder->MoveTo(secondRun->get_NextSibling());
else
builder->MoveTo(secondRun->get_ParentParagraph());
builder->EndBookmark(u"Aspose bookmark");
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->get_OutlineOptions()->get_BookmarksOutlineLevels()->Add(u"Aspose bookmark", 1);
doc->Save(u"Output.docx", saveOptions);
Obstajajo tri možnosti za namestitev Aspose.Words for C++ v okolje razvijalca. Izberite tistega, ki ustreza vašim potrebam, in sledite navodilom po korakih:
To knjižnico C++ lahko uporabite za razvoj programske opreme v Microsoft Windows, Linux in macOS:
Če razvijate programsko opremo za Linux ali macOS, preverite informacije o dodatnih odvisnostih knjižnic (odprtokodni paketi fontconfig in mesa-glu) v dokumentaciji izdelka.
Ustvarite lahko dokumente v drugih oblikah datotek: