Looge DOC, kasutades Python via .NET teeki

Meie võimas Python teek võimaldab arendajatel programmiliselt luua DOC vaid mõne sammuga

Teenuse Python via .NET arendajad saavad hõlpsasti luua DOC, kasutades ainult meie võimsat toote API t. See tähendab, et meie lahendus pakub programmeerijatele kõike, mida nad vajavad DOC loomiseks rakenduses Python.

Kuva koodilõik

Tehke DOC Python programmiliselt

Meie Python teegi abil saavad arendajad DOC lihtsalt nullist luua. Selleks peavad Python via .NET i arendajad tegema vaid mõne sammu:

  1. Lisa faili nimi
  2. Alustage DOC dokumendi loomist Python abil
  3. Salvestage DOC väljundfail

Väärib märkimist, et tühi dokument peaks tehniliselt sisaldama ühte lõiku, nii et programmiliselt DOC dokumendi loomisel saate täpselt selle dokumendi põhistruktuuri.

Pange tähele, et saate vastloodud DOC failile sisu koheselt lisada. Nii saate mitte ainult tühja dokumendi, vaid vajaliku sisuga dokumendi. Lisateavet dokumendi redigeerimise kohta leiate lehelt Redigeerimine.

Looge DOC Python

See Python via .NET i teek võimaldab programmiliselt luua DOC dokumente. Proovige meie võimsat funktsiooni ja vaadake, kuidas järgmise näite abil mõnes vormingus DOC luua:

Looge uus DOC, kasutades Python
Valige loendist sihtvorming
Käivita kood
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.doc")
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") # Kui NextSibling on null, siis tõenäoliselt on see lõigu viimane Run . 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.doc") 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") # Kui NextSibling on null, siis tõenäoliselt on see lõigu viimane Run . 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.doc", 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.doc")
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") # Kui NextSibling on null, siis tõenäoliselt on see lõigu viimane Run . 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.doc") 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") # Kui NextSibling on null, siis tõenäoliselt on see lõigu viimane Run . 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.doc", 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")
# Kui NextSibling on null, siis tõenäoliselt on see lõigu viimane Run .
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.doc")
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") # Kui NextSibling on null, siis tõenäoliselt on see lõigu viimane Run . 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.doc") 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") # Kui NextSibling on null, siis tõenäoliselt on see lõigu viimane Run . 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.doc", 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.doc")
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") # Kui NextSibling on null, siis tõenäoliselt on see lõigu viimane Run . 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.doc") 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") # Kui NextSibling on null, siis tõenäoliselt on see lõigu viimane Run . 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.doc", save_options);
Käivita kood

Kuidas teha DOC riigis Python

  1. Installige Aspose.Words for Python via .NET
  2. Lisage oma Python projektile teegi viide (importige teeki).
  3. Looge uus DOC dokument
  4. Kutsuge meetod "save()", edastades failinime
  5. Hangi tulemus eraldi failina

Python teek, et luua DOC

Hoidame oma Python pakette PyPi hoidlates. Järgige samm-sammult juhiseid selle kohta, kuidas installida "Aspose.Words for Python via .NET" kaudu oma arendajakeskkonda.

Nõuded süsteemile

See pakett ühildub Python ≥3.5 ja <3.12. Kui arendate tarkvara Linuxi jaoks, vaadake tootedokumentatsioonis gcc ja libpython lisanõudeid.

Muud toetatud failivormingud

Saate luua dokumente muudes failivormingutes:

5%

Tellige Aspose'i tootevärskendused

Saate igakuiseid uudiskirju ja pakkumisi otse teie postkasti.

© Aspose Pty Ltd 2001-2024. Kõik õigused kaitstud.