How to Use IronWord on iOS

This article was translated from English: Does it need improvement?
Translated
View the article in English

.NET MAUI (マルチプラットフォームアプリUI) は、単一の.NETコードベースを使用して、Android、iOS、Windows、およびmacOSでネイティブアプリケーションを構築できるようにします。 IronWordを使用すると、.NET 開発者は Microsoft Office を必要とせずに、Microsoft Word (.docx) ドキュメントを作成、読み取り、編集、保存できます—完全にクロスプラットフォーム対応です。

IronWordは、標準のIronWord NuGetパッケージを使用して、共有の.NET MAUIコードベースを介してiOSでシームレスに動作します—プラットフォーム固有のバージョンは必要ありません。

IronWord NuGetパッケージのインストール

IronWord は標準のクロスプラットフォーム NuGet パッケージとして提供され、iOS を含むすべての主要な .NET MAUI ターゲットをサポートします。

Install-Package IronWord

.NET MAUIプロジェクトの作成

Visual Studioで:

  1. ファイル > 新規 > プロジェクト に進みます。
  2. マルチプラットフォームの下で、.NET MAUI アプリを選択します。
  3. プロジェクトに名前を付け(例: IronWordMauiIOS)、作成をクリックします。

プロジェクトにIronWordを追加する

NuGetパッケージマネージャー経由または.csprojファイルを編集することでパッケージを追加できます:

<ItemGroup>
  <PackageReference Include="IronWord" Version="2025.5.0" />
</ItemGroup>
<ItemGroup>
  <PackageReference Include="IronWord" Version="2025.5.0" />
</ItemGroup>
XML

プラットフォーム条件は必要ありません—IronWordはすべてのターゲットに自動で動作します。

XAMLでアプリインターフェースを作成

Wordドキュメントを読み込み、編集、保存するためのシンプルなUIを追加します。 MainPage.xmlコードにこのコードを追加して開始します:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="IronWordMauiIOS.MainPage"
             BackgroundColor="White">

    <VerticalStackLayout Padding="20"
                         Spacing="15"
                         VerticalOptions="Center">

        <!-- Header -->
        <Label Text="IronWord iOS Demo"
               FontSize="24"
               FontAttributes="Bold"
               HorizontalOptions="Center"
               TextColor="#222"/>

        <!-- Open .docx -->
        <Button Text=" Open Word Document"
                Clicked="OpenDocx"
                BackgroundColor="#007AFF"
                TextColor="White"
                CornerRadius="10"
                HeightRequest="50"/>

        <!-- Editable content -->
        <Editor x:Name="docEditor"
                Placeholder="Start editing..."
                AutoSize="TextChanges"
                HeightRequest="250"
                FontSize="16"
                TextColor="#333"
                BackgroundColor="#F9F9F9"
                CornerRadius="10"
                Margin="0,10,0,0"/>

        <!-- Save Button -->
        <Button Text=" Save as .docx"
                Clicked="SaveDocx"
                BackgroundColor="#34C759"
                TextColor="White"
                CornerRadius="10"
                HeightRequest="50"/>

        <!-- Status message -->
        <Label x:Name="statusLabel"
               FontSize="14"
               TextColor="Gray"
               HorizontalOptions="Center"/>
    </VerticalStackLayout>
</ContentPage>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="IronWordMauiIOS.MainPage"
             BackgroundColor="White">

    <VerticalStackLayout Padding="20"
                         Spacing="15"
                         VerticalOptions="Center">

        <!-- Header -->
        <Label Text="IronWord iOS Demo"
               FontSize="24"
               FontAttributes="Bold"
               HorizontalOptions="Center"
               TextColor="#222"/>

        <!-- Open .docx -->
        <Button Text=" Open Word Document"
                Clicked="OpenDocx"
                BackgroundColor="#007AFF"
                TextColor="White"
                CornerRadius="10"
                HeightRequest="50"/>

        <!-- Editable content -->
        <Editor x:Name="docEditor"
                Placeholder="Start editing..."
                AutoSize="TextChanges"
                HeightRequest="250"
                FontSize="16"
                TextColor="#333"
                BackgroundColor="#F9F9F9"
                CornerRadius="10"
                Margin="0,10,0,0"/>

        <!-- Save Button -->
        <Button Text=" Save as .docx"
                Clicked="SaveDocx"
                BackgroundColor="#34C759"
                TextColor="White"
                CornerRadius="10"
                HeightRequest="50"/>

        <!-- Status message -->
        <Label x:Name="statusLabel"
               FontSize="14"
               TextColor="Gray"
               HorizontalOptions="Center"/>
    </VerticalStackLayout>
</ContentPage>
XML

これにより、Wordコンテンツの読み込み/保存用のボタンとエディターUIが作成されます。

共有コードでIronWordを使用

MainPage.xaml.csで、IronWordを使用してDOCXドキュメントの読み取りと書き込みを実装します:

using IronWord;
using IronWord.Models;
using Microsoft.Maui.Storage;
using System.Text;

namespace IronWordMauiIOS;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        License.LicenseKey = "YOUR-LICENSE-KEY"; 
    }

    private async void OpenDocx(object sender, EventArgs e)
    {
        try
        {
            var file = await FilePicker.PickAsync();
            if (file == null) return;

            var path = Path.Combine(FileSystem.CacheDirectory, file.FileName);
            using (var source = await file.OpenReadAsync())
            using (var target = File.Create(path))
                await source.CopyToAsync(target);

            var doc = new WordDocument(path);
            docEditor.Text = ExtractText(doc);
            statusLabel.Text = "Document loaded successfully.";
        }
        catch (Exception ex)
        {
            statusLabel.Text = $"Error: {ex.Message}";
        }
    }

    private async void SaveDocx(object sender, EventArgs e)
    {
        try
        {
            var document = new WordDocument();
            var paragraph = new Paragraph();
            paragraph.Texts.Add(new TextContent(docEditor.Text));
            document.Paragraphs.Add(paragraph);

            var fileName = $"ExportedDoc_{DateTime.Now:yyyyMMddHHmmss}.docx";
            var path = Path.Combine(FileSystem.AppDataDirectory, fileName);
            document.SaveAs(path);

            statusLabel.Text = $"Saved to: {fileName}";
        }
        catch (Exception ex)
        {
            statusLabel.Text = $"Save error: {ex.Message}";
        }
    }

    private string ExtractText(WordDocument doc)
    {
        var sb = new StringBuilder();
        foreach (var para in doc.Paragraphs)
        {
            foreach (var element in para.Texts)
            {
                if (element is TextContent text)
                    sb.AppendLine(text.Text);
            }
        }
        return sb.ToString();
    }
}
using IronWord;
using IronWord.Models;
using Microsoft.Maui.Storage;
using System.Text;

namespace IronWordMauiIOS;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        License.LicenseKey = "YOUR-LICENSE-KEY"; 
    }

    private async void OpenDocx(object sender, EventArgs e)
    {
        try
        {
            var file = await FilePicker.PickAsync();
            if (file == null) return;

            var path = Path.Combine(FileSystem.CacheDirectory, file.FileName);
            using (var source = await file.OpenReadAsync())
            using (var target = File.Create(path))
                await source.CopyToAsync(target);

            var doc = new WordDocument(path);
            docEditor.Text = ExtractText(doc);
            statusLabel.Text = "Document loaded successfully.";
        }
        catch (Exception ex)
        {
            statusLabel.Text = $"Error: {ex.Message}";
        }
    }

    private async void SaveDocx(object sender, EventArgs e)
    {
        try
        {
            var document = new WordDocument();
            var paragraph = new Paragraph();
            paragraph.Texts.Add(new TextContent(docEditor.Text));
            document.Paragraphs.Add(paragraph);

            var fileName = $"ExportedDoc_{DateTime.Now:yyyyMMddHHmmss}.docx";
            var path = Path.Combine(FileSystem.AppDataDirectory, fileName);
            document.SaveAs(path);

            statusLabel.Text = $"Saved to: {fileName}";
        }
        catch (Exception ex)
        {
            statusLabel.Text = $"Save error: {ex.Message}";
        }
    }

    private string ExtractText(WordDocument doc)
    {
        var sb = new StringBuilder();
        foreach (var para in doc.Paragraphs)
        {
            foreach (var element in para.Texts)
            {
                if (element is TextContent text)
                    sb.AppendLine(text.Text);
            }
        }
        return sb.ToString();
    }
}
Imports IronWord
Imports IronWord.Models
Imports Microsoft.Maui.Storage
Imports System.Text

Namespace IronWordMauiIOS

	Partial Public Class MainPage
		Inherits ContentPage

		Public Sub New()
			InitializeComponent()
			License.LicenseKey = "YOUR-LICENSE-KEY"
		End Sub

		Private Async Sub OpenDocx(ByVal sender As Object, ByVal e As EventArgs)
			Try
				Dim file = Await FilePicker.PickAsync()
				If file Is Nothing Then
					Return
				End If

				Dim path As System.String = System.IO.Path.Combine(FileSystem.CacheDirectory, file.FileName)
				Using source = Await file.OpenReadAsync()
				Using target = System.IO.File.Create(path)
					Await source.CopyToAsync(target)
				End Using
				End Using

				Dim doc = New WordDocument(path)
				docEditor.Text = ExtractText(doc)
				statusLabel.Text = "Document loaded successfully."
			Catch ex As Exception
				statusLabel.Text = $"Error: {ex.Message}"
			End Try
		End Sub

		Private Async Sub SaveDocx(ByVal sender As Object, ByVal e As EventArgs)
			Try
				Dim document = New WordDocument()
				Dim paragraph As New Paragraph()
				paragraph.Texts.Add(New TextContent(docEditor.Text))
				document.Paragraphs.Add(paragraph)

				Dim fileName = $"ExportedDoc_{DateTime.Now:yyyyMMddHHmmss}.docx"
				Dim path As System.String = System.IO.Path.Combine(FileSystem.AppDataDirectory, fileName)
				document.SaveAs(path)

				statusLabel.Text = $"Saved to: {fileName}"
			Catch ex As Exception
				statusLabel.Text = $"Save error: {ex.Message}"
			End Try
		End Sub

		Private Function ExtractText(ByVal doc As WordDocument) As String
			Dim sb = New StringBuilder()
			For Each para In doc.Paragraphs
				For Each element In para.Texts
					Dim tempVar As Boolean = TypeOf element Is TextContent
					Dim text As TextContent = If(tempVar, CType(element, TextContent), Nothing)
					If tempVar Then
						sb.AppendLine(text.Text)
					End If
				Next element
			Next para
			Return sb.ToString()
		End Function
	End Class
End Namespace
$vbLabelText   $csharpLabel

プロジェクトファイルの概要

プロジェクト構造には次の項目が含まれているはずです:

IronWordMauiIOS/
│
├── MainPage.xaml              ← UIレイアウト
├── MainPage.xaml.cs          ← UIのロジック(Wordドキュメントのアクション)
├── IronWordMauiIOS.csproj     ← IronWord NuGetパッケージを参照
├── Platforms/ios/             ← iOS特有の設定(ここで変更は不要)
└── ...

プロジェクトの実行

  1. ターゲットをiOSシミュレーターに設定します。
  2. 実行を押します。
  3. シミュレートされたiOSデバイスで直接.docxドキュメントの読み取りと書き込みをテストします。

最終注意事項

  • 完全なクロスプラットフォーム (iOS, Android, Windows, macOS)
  • Microsoft OfficeやInteropの必要なし
  • 100% C#/.NET MAUIネイティブ
  • オフラインで動作
  • エディター、履歴書ビルダー、ドキュメントビューアの構築に最適

よくある質問

IronWordとは何か、どのようにしてiOSで使用できるか?

IronWordは、Wordドキュメントを扱うために設計されたパワフルなライブラリで、.NETアプリケーション(iOSを含む)で利用できます。これにより、開発者はモバイルアプリ内でWordドキュメントを作成、操作、変換することが可能です。

私のiOSプロジェクトにIronWordを統合するにはどうすればいいですか?

iOSプロジェクトにIronWordを統合するには、.NETソリューションにIronWordライブラリを追加し、プロジェクトを設定して参照し、提供されたAPIを使ってWordドキュメントを管理する必要があります。

iOSでIronWordを使用するためのシステム要件は何ですか?

IronWordは、iOS開発環境に互換性のある.NET環境を必要とします。シームレスな統合のために、開発環境が最新で必要なフレームワークをサポートしていることを確認してください。

iOS上でWordドキュメントを他のフォーマットに変換できますか?

はい、IronWordはWordドキュメントをPDFなどさまざまなフォーマットに変換して、iOSアプリケーションでの汎用的なドキュメントの取り扱いと共有を可能にします。

IronWordはiOS上でのドキュメント操作をサポートしていますか?

もちろんです。IronWordは、テキストの編集、画像の挿入、ドキュメントプロパティの管理など、iOSアプリケーション内で直接利用できる幅広いドキュメント操作をサポートしています。

IronWordを使用してiOSで新しいWordドキュメントを作成することは可能ですか?

はい、IronWordを使用すると、iOSで新しいWordドキュメントをゼロから作成でき、プログラムでコンテンツ、フォーマット、スタイルを追加するための包括的なツールスイートを提供しています。

IronWordはiOSアプリケーションでWordドキュメントのセキュリティをどのように扱いますか?

IronWordには、パスワード保護や暗号化などのドキュメントセキュリティを管理する機能が含まれており、iOSアプリでWordドキュメントのセキュリティを確保します。

iOS用のIronWordを使用するためのサンプルプロジェクトはありますか?

はい、Iron Softwareは、開発者がiOSでIronWordを迅速に開始するためのサンプルプロジェクトとドキュメントを提供し、さまざまな機能とユースケースを紹介しています。

iOSデプロイメントにIronWordは追加のライセンスを必要としますか?

IronWordは、iOSアプリケーションを含む本番環境でのデプロイのための有効なライセンスを必要とします。使用ガイドラインを遵守するために、ライセンス条項を確認してください。

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'name'

Filename: sections/author_component.php

Line Number: 18

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 18
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/get-started/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Getstarted.php
Line: 25
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'title'

Filename: sections/author_component.php

Line Number: 38

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 38
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/get-started/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Getstarted.php
Line: 25
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'comment'

Filename: sections/author_component.php

Line Number: 48

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 48
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/get-started/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Getstarted.php
Line: 25
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

準備はいいですか?
Nuget ダウンロード 25,807 | バージョン: 2025.11 ただ今リリースされました