Κάντε το DOC χρησιμοποιώντας τη βιβλιοθήκη Node.js via .NET

Η ισχυρή βιβλιοθήκη μας JavaScript επιτρέπει στους προγραμματιστές να δημιουργήσουν μέσω προγραμματισμού το DOC σε λίγα μόλις βήματα

Οι προγραμματιστές του Node.js via .NET μπορούν εύκολα να δημιουργήσουν DOC χρησιμοποιώντας μόνο το ισχυρό API προϊόντων μας. Σημαίνει ότι η λύση μας θα παρέχει στους προγραμματιστές όλα όσα χρειάζονται για να δημιουργήσουν το DOC στο JavaScript.

Προβολή αποσπάσματος κώδικα

Δημιουργήστε το DOC σε JavaScript μέσω προγραμματισμού

Με τη βιβλιοθήκη JavaScript, οι προγραμματιστές μπορούν εύκολα να δημιουργήσουν το DOC από την αρχή. Για να γίνει αυτό, οι προγραμματιστές Node.js via .NET πρέπει να εκτελέσουν μερικά μόνο βήματα:

  1. Προσθήκη ονόματος αρχείου
  2. Ξεκινήστε τη δημιουργία ενός DOC εγγράφου χρησιμοποιώντας JavaScript
  3. Αποθηκεύστε το αρχείο εξόδου του DOC

Αξίζει να σημειωθεί ότι ένα κενό έγγραφο τεχνικά υποτίθεται ότι περιέχει μία παράγραφο, επομένως όταν δημιουργείτε μέσω προγραμματισμού ένα DOC έγγραφο, θα έχετε ακριβώς αυτή τη βασική δομή εγγράφου.

Σημειώστε ότι μπορείτε να προσθέσετε άμεσα περιεχόμενο σε ένα DOC αρχείο που δημιουργήθηκε πρόσφατα. Έτσι, δεν θα λάβετε απλώς ένα κενό έγγραφο, αλλά ένα έγγραφο που περιέχει το απαραίτητο περιεχόμενο. Για περισσότερες πληροφορίες σχετικά με τον τρόπο επεξεργασίας ενός εγγράφου, ανατρέξτε στη σελίδα Επεξεργασία.

Δημιουργία DOC σε JavaScript

Αυτή η βιβλιοθήκη Node.js via .NET σάς επιτρέπει να δημιουργείτε μέσω προγραμματισμού DOC έγγραφα. Δοκιμάστε την ισχυρή μας λειτουργικότητα και δείτε πώς μπορείτε να δημιουργήσετε DOC σε ορισμένες μορφές χρησιμοποιώντας το ακόλουθο παράδειγμα:

Δημιουργήστε ένα νέο DOC χρησιμοποιώντας το JavaScript
Επιλέξτε τη μορφή προορισμού από τη λίστα
Εκτέλεση κώδικα
npm install @aspose/words
αντίγραφο
const aw = require('@aspose/words');

var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)

font = builder.font
font.name = "Courier New"
font.color = '#FF0000'
font.size = 36
font.highlightColor = '#F0DB4F'

builder.write("Morbi enim nunc faucibus a.")

doc.save("Output.doc")
const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Εάν το NextSibling είναι μηδενικό, τότε πιθανότατα αυτή είναι η τελευταία εκτέλεση στην παράγραφο. if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") doc.save("Output.doc") const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Εάν το NextSibling είναι μηδενικό, τότε πιθανότατα αυτή είναι η τελευταία εκτέλεση στην παράγραφο. if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") var saveOptions = new aw.Saving.PdfSaveOptions() saveOptions.outlineOptions.bookmarksOutlineLevels.add("Aspose bookmark", 1); doc.save("Output.doc", saveOptions)
const aw = require('@aspose/words');

var doc = new aw.Document()

var run = new aw.Run(doc, "Proin eros metus, sagittis sed.")
var para = doc.firstSection.body.firstParagraph
para.appendChild(run)

var comment = new aw.Comment(doc)
comment.author = "John Doe"
comment.initial = "JD"
comment.dateTime = new Date()
comment.setText("Quisque fringilla leo.")

var commentRangeStart = new aw.CommentRangeStart(doc, comment.id)
var commentRangeEnd = new aw.CommentRangeEnd(doc, comment.id)

run.parentNode.insertBefore(commentRangeStart, run)
run.parentNode.insertAfter(commentRangeEnd, run)
commentRangeEnd.parentNode.insertAfter(comment, commentRangeEnd)

comment.addReply("Jane Doe", "JD", new Date(), "Pellentesque vel sapien justo.")

doc.save("Output.doc")
const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Εάν το NextSibling είναι μηδενικό, τότε πιθανότατα αυτή είναι η τελευταία εκτέλεση στην παράγραφο. if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") doc.save("Output.doc") const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Εάν το NextSibling είναι μηδενικό, τότε πιθανότατα αυτή είναι η τελευταία εκτέλεση στην παράγραφο. if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") var saveOptions = new aw.Saving.PdfSaveOptions() saveOptions.outlineOptions.bookmarksOutlineLevels.add("Aspose bookmark", 1); doc.save("Output.doc", saveOptions)
const aw = require('@aspose/words');

var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)

var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ")
var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.")
doc.firstSection.body.firstParagraph.appendChild(firstRun)
doc.firstSection.body.firstParagraph.appendChild(secondRun)

builder.moveTo(secondRun)
builder.startBookmark("Aspose bookmark")
// Εάν το NextSibling είναι μηδενικό, τότε πιθανότατα αυτή είναι η τελευταία εκτέλεση στην παράγραφο.
if (secondRun.nextSibling != null)
    builder.moveTo(secondRun.nextSibling)
else
    builder.moveTo(secondRun.parentParagraph)
builder.endBookmark("Aspose bookmark")

doc.save("Output.doc")
const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Εάν το NextSibling είναι μηδενικό, τότε πιθανότατα αυτή είναι η τελευταία εκτέλεση στην παράγραφο. if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") doc.save("Output.doc") const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Εάν το NextSibling είναι μηδενικό, τότε πιθανότατα αυτή είναι η τελευταία εκτέλεση στην παράγραφο. if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") var saveOptions = new aw.Saving.PdfSaveOptions() saveOptions.outlineOptions.bookmarksOutlineLevels.add("Aspose bookmark", 1); doc.save("Output.doc", saveOptions)
const aw = require('@aspose/words');

var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)

shape = builder.insertChart(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")
const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Εάν το NextSibling είναι μηδενικό, τότε πιθανότατα αυτή είναι η τελευταία εκτέλεση στην παράγραφο. if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") doc.save("Output.doc") const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) var firstRun = new aw.Run(doc, "Proin eros metus, sagittis sed. ") var secondRun = new aw.Run(doc, "Morbi enim nunc faucibus a.") doc.firstSection.body.firstParagraph.appendChild(firstRun) doc.firstSection.body.firstParagraph.appendChild(secondRun) builder.moveTo(secondRun) builder.startBookmark("Aspose bookmark") // Εάν το NextSibling είναι μηδενικό, τότε πιθανότατα αυτή είναι η τελευταία εκτέλεση στην παράγραφο. if (secondRun.nextSibling != null) builder.moveTo(secondRun.nextSibling) else builder.moveTo(secondRun.parentParagraph) builder.endBookmark("Aspose bookmark") var saveOptions = new aw.Saving.PdfSaveOptions() saveOptions.outlineOptions.bookmarksOutlineLevels.add("Aspose bookmark", 1); doc.save("Output.doc", saveOptions)
Εκτέλεση κώδικα

Πώς να φτιάξετε το DOC στο JavaScript

  1. Εγκαταστήστε Aspose.Words for Node.js via .NET
  2. Προσθέστε μια αναφορά βιβλιοθήκης (εισάγετε τη βιβλιοθήκη) στο έργο σας JavaScript
  3. Δημιουργήστε ένα νέο DOC έγγραφο
  4. Καλέστε τη μέθοδο save(), περνώντας το όνομα του αρχείου
  5. Λάβετε το αποτέλεσμα ως ξεχωριστό αρχείο

JavaScript βιβλιοθήκη για δημιουργία DOC

We host our Node.js via .Net packages in NPM repositories. Please follow the step-by-step instructions on how to install "Aspose.Words for Node.js via .NET" to your developer environment.

System Requirements

This package is compatible with Node.js 14.17.0 or higher.

Άλλες υποστηριζόμενες μορφές αρχείων

Μπορείτε να δημιουργήσετε έγγραφα σε άλλες μορφές αρχείων:

5%

Εγγραφείτε στις ενημερώσεις προϊόντων Aspose

Λάβετε μηνιαία ενημερωτικά δελτία και προσφορές απευθείας στο γραμματοκιβώτιό σας.

© Aspose Pty Ltd 2001-2025. Ολα τα δικαιώματα διατηρούνται.