Python via .NET programeri mogu lako izraditi Word koristeći samo naš moćni API proizvoda. To znači da će naše rješenje programerima pružiti sve što im je potrebno za stvaranje Word u Python.
S našom Python bibliotekom programeri mogu jednostavno izraditi Word od nule. Da bi to učinili, Python via .NET programeri moraju izvršiti samo nekoliko koraka:
Vrijedno je napomenuti da bi prazan dokument tehnički trebao sadržavati jedan paragraf, tako da kada programski kreirate Word dokument, dobit ćete upravo tu osnovnu strukturu dokumenta.
Imajte na umu da možete odmah dodati sadržaj novostvorenoj Word datoteci. Tako ćete dobiti ne samo prazan dokument, već dokument koji sadrži potreban sadržaj. Za više informacija o tome kako urediti dokument, pogledajte stranicu Uređivanje.
Ova Python via .NET biblioteka omogućuje programsku izradu Word dokumenata. Isprobajte našu moćnu funkcionalnost i pogledajte kako stvoriti Word u nekim formatima pomoću sljedećeg primjera:
pip install aspose-words
Kopirati
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
font = builder.font
font.name = "Courier New"
font.color = drawing.Color.blue
font.size = 36
font.highlight_color = drawing.Color.yellow
builder.write("Morbi enim nunc faucibus a.")
doc.Save("Output.docx")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Ako je NextSibling null, tada je najvjerojatnije ovo zadnje Run u paragrafu.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
doc.Save("Output.docx")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Ako je NextSibling null, tada je najvjerojatnije ovo zadnje Run u paragrafu.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
save_options = aw.saving.PdfSaveOptions()
save_options.outline_options.bookmarks_outline_levels.add("Aspose bookmark", 1);
doc.Save("Output.docx", save_options);
import aspose.words as aw
doc = aw.Document()
run = aw.Run(doc, "Proin eros metus, sagittis sed.")
para = doc.first_section.body.first_paragraph
para.append_child(run)
comment = aw.Comment(doc)
comment.author = "John Doe"
comment.initial = "JD"
comment.date_time = datetime.now()
comment.set_text("Quisque fringilla leo.")
commentRangeStart = aw.CommentRangeStart(doc, comment.id)
commentRangeEnd = aw.CommentRangeEnd(doc, comment.id)
run.parent_node.insert_before(commentRangeStart, run)
run.parent_node.insert_after(commentRangeEnd, run)
commentRangeEnd.parent_node.insert_after(comment, commentRangeEnd)
comment.add_reply("Jane Doe", "JD", datetime.now(), "Pellentesque vel sapien justo.")
doc.save("Output.docx")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Ako je NextSibling null, tada je najvjerojatnije ovo zadnje Run u paragrafu.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
doc.Save("Output.docx")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Ako je NextSibling null, tada je najvjerojatnije ovo zadnje Run u paragrafu.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
save_options = aw.saving.PdfSaveOptions()
save_options.outline_options.bookmarks_outline_levels.add("Aspose bookmark", 1);
doc.Save("Output.docx", save_options);
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Ako je NextSibling null, tada je najvjerojatnije ovo zadnje Run u paragrafu.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
doc.Save("Output.docx")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Ako je NextSibling null, tada je najvjerojatnije ovo zadnje Run u paragrafu.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
doc.Save("Output.docx")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Ako je NextSibling null, tada je najvjerojatnije ovo zadnje Run u paragrafu.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
save_options = aw.saving.PdfSaveOptions()
save_options.outline_options.bookmarks_outline_levels.add("Aspose bookmark", 1);
doc.Save("Output.docx", save_options);
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
shape = builder.insert_chart(aw.drawing.charts.ChartType.PIE, 432, 252)
chart = shape.chart
chart.title.text = "Demo Chart"
chart.series.clear()
chart.series.add("Series 1",
["Category1", "Category2", "Category3"],
[2.7, 3.2, 0.8])
doc.save("Output.docx")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Ako je NextSibling null, tada je najvjerojatnije ovo zadnje Run u paragrafu.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
doc.Save("Output.docx")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
firstRun = aw.Run(doc, "Proin eros metus, sagittis sed. ")
secondRun = aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.first_section.body.first_paragraph.append_child(firstRun)
doc.first_section.body.first_paragraph.append_child(secondRun)
builder.move_to(secondRun)
builder.start_bookmark("Aspose bookmark")
# Ako je NextSibling null, tada je najvjerojatnije ovo zadnje Run u paragrafu.
if (secondRun.next_sibling != None):
builder.move_to(secondRun.next_sibling)
else:
builder.move_to(secondRun.parent_paragraph)
builder.end_bookmark("Aspose bookmark")
save_options = aw.saving.PdfSaveOptions()
save_options.outline_options.bookmarks_outline_levels.add("Aspose bookmark", 1);
doc.Save("Output.docx", save_options);
Naše Python pakete hostiramo u PyPi repozitorijumima. Slijedite upute korak po korak o tome kako instalirati "Aspose.Words for Python via .NET" u svoje razvojno okruženje.
Ovaj paket je kompatibilan s Python ≥3.5 i <3.12. Ako razvijate softver za Linux, pogledajte dodatne zahtjeve za gcc i libpython u dokumentaciji proizvoda.
Možete izraditi dokumente u drugim formatima datoteka: