Node.js via .NETライブラリを使用してDOCを作成します

強力なJavaScriptライブラリを使用すると、開発者はわずか数ステップでDOCをプログラムで作成できます。

Node.js via .NET開発者は、強力な製品APIのみを使用してDOCを簡単に作成できます。これは、私たちのソリューションがプログラマーにJavaScriptでDOCを作成するために必要なすべてのものを提供することを意味します。

コード スニペットを表示

プログラムで JavaScript で DOC を作成する

JavaScript ライブラリを使用すると、開発者は DOC を最初から簡単に作成できます。これを行うには、Node.js via .NET 開発者はいくつかの手順を実行する必要があります。

  1. ファイル名を追加
  2. JavaScript を使用して DOC ドキュメントの作成を開始します
  3. 出力 DOC ファイルを保存します

空白のドキュメントには技術的に1つの段落が含まれることになっているため、プログラムで DOC ドキュメントを作成すると、まさにその基本的なドキュメント構造が得られることに注意してください。

新しく作成した DOC ファイルにコンテンツをすぐに追加できることに注意してください。したがって、空のドキュメントだけでなく、必要なコンテンツを含むドキュメントも取得できます。ドキュメントを編集する方法の詳細については、編集ページを参照してください。

JavaScript で DOC を作成する

この Node.js via .NET ライブラリを使用すると、DOC ドキュメントをプログラムで作成できます。強力な機能を試して、次の例を使用していくつかの形式で DOC を作成する方法を確認してください。

JavaScriptを使用して新しいDOCを作成します
リストからターゲットフォーマットを選択します
コードを実行する
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がnullの場合、これが段落の最後の実行である可能性が最も高いです。 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がnullの場合、これが段落の最後の実行である可能性が最も高いです。 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がnullの場合、これが段落の最後の実行である可能性が最も高いです。 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がnullの場合、これが段落の最後の実行である可能性が最も高いです。 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がnullの場合、これが段落の最後の実行である可能性が最も高いです。
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がnullの場合、これが段落の最後の実行である可能性が最も高いです。 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がnullの場合、これが段落の最後の実行である可能性が最も高いです。 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がnullの場合、これが段落の最後の実行である可能性が最も高いです。 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がnullの場合、これが段落の最後の実行である可能性が最も高いです。 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)
コードを実行する

JavaScriptでDOCを作成する方法

  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. 全著作権所有。