Word for WinForms
手順 2:単純なテキストの追加
クイックスタート > 手順 2:単純なテキストの追加

コードビューを表示したまま、InitializeComponent() メソッドの下に次のコードを追加することで、C1Word コンポーネントを使用して Word ドキュメントを作成します。

' ドキュメントを作成します
Dim c1Word As New C1WordDocument()
c1Word.Info.Title = "c"

Dim font As New Font("Cambria", 24, FontStyle.Bold)
c1Word.AddParagraph("こんにちは。C1Wordコンポネントの単純なテキスト例。", 
        font, Color.MediumPurple)

c1Word.Save("simple.docx")
Process.Start("simple.docx")
// ドキュメントを作成します
C1WordDocument c1Word = new C1WordDocument();
c1Word.Info.Title = "単純なテキストサンプル";

Font font = new Font("Cambria", 24, FontStyle.Bold);
c1Word.AddParagraph("こんにちは。C1Wordコンポネントの単純なテキスト例。", 
        font, Color.MediumPurple);

c1Word.Save("Simple.docx");
Process.Start("Simple.docx");

上記のコードは、「単純なテキストサンプル」というタイトルの Word ドキュメントを作成し、AddParagraph メソッドを使用してテキストを追加します。最後に、ドキュメントは Simple.docx という名前で保存されます。