.NET ヘルプ

C# Timespanフォーマット(開発者向けの仕組み)

公開済み 2025年1月14日
共有:

イントロダクション

今日の迅速に進化する開発の世界では、時間間隔の管理は、プロジェクト管理システムから時間追跡ツールに至るまで、さまざまなアプリケーションにとって重要です。 についてTimeSpanC#の構造体は、時間間隔を表すための強力な方法を提供し、開発者が計算を行い、時間データを効率的にフォーマットすることを容易にします。 これに加えて、IronPDF、.NET向けの強力なPDF生成ライブラリは、時間データに基づいて動的で視覚的に魅力的なレポートを作成することを可能にします。

この記事では、C#でのTimeSpanのフォーマットの詳細を掘り下げ、IronPDFとシームレスに統合して有益なレポートを生成する方法を示します。 従業員の労働時間を追跡する場合でも、プロジェクトの期間を測定する場合でも、このガイドは報告機能を強化するための実用的な例を提供します。

C#におけるTimeSpanの理解

C#のTimeSpanとは何ですか?

C# の TimeSpan 構造体は時間間隔を表し、持続時間や2つの日付と時刻の値の差を測定するために使用できます。 これは多用途の構造であり、開発者が次のようなさまざまな時間関連の計算を行うことを可能にします。

  • タスクの所要時間を計算する。
  • イベント間の時間差を測定する。
  • パフォーマンス測定のためのタイマーの作成。

    TimeSpanの重要性は、アプリケーション全体で時間間隔の管理を簡略化し、標準化する能力にあります。これにより、さまざまな時間関連のタスクをより簡単に処理することができます。

時間間隔の作成と使用の基本メソッド

TimeSpan オブジェクトの作成は簡単で、以下のような様々な方法があります。

  • TimeSpan.FromHours(ダブル時間): 指定された時間数を表す TimeSpan を作成します。
  • TimeSpan.FromMinutes(ダブル分): 指定された分数を表す TimeSpan を作成します。
  • TimeSpan.FromSeconds(ダブル秒): 指定された秒数を表す TimeSpan を作成します。

    以下は、TimeSpan インスタンスを作成し、それを計算に使用する方法を示す例です。

// Creating TimeSpan instances
TimeSpan taskDuration = TimeSpan.FromHours(2.5); // 2 hours and 30 minutes
TimeSpan breakDuration = TimeSpan.FromMinutes(15); // 15 minutes
// Calculating total time spent
TimeSpan totalTime = taskDuration + breakDuration;
Console.WriteLine($"Total time spent: {totalTime}"); // Outputs: 02:45:00
// Creating TimeSpan instances
TimeSpan taskDuration = TimeSpan.FromHours(2.5); // 2 hours and 30 minutes
TimeSpan breakDuration = TimeSpan.FromMinutes(15); // 15 minutes
// Calculating total time spent
TimeSpan totalTime = taskDuration + breakDuration;
Console.WriteLine($"Total time spent: {totalTime}"); // Outputs: 02:45:00
' Creating TimeSpan instances
Dim taskDuration As TimeSpan = TimeSpan.FromHours(2.5) ' 2 hours and 30 minutes
Dim breakDuration As TimeSpan = TimeSpan.FromMinutes(15) ' 15 minutes
' Calculating total time spent
Dim totalTime As TimeSpan = taskDuration.Add(breakDuration)
Console.WriteLine($"Total time spent: {totalTime}") ' Outputs: 02:45:00
VB   C#

以下の出力が表示されます:

C# タイムスパンのフォーマット(開発者向けの仕組み):図1

表示用のTimeSpanのフォーマット

TimeSpanの値を表示する際、C#はさまざまな書式設定オプションを提供します。 Specifier 出力は、TimeSpan の値を文字列に変換するときに、その表示方法を制御するために使用されます。 これらの指定子は、TimeSpanオブジェクトの出力形式を定義し、最終的なPDFレポートでの表現をカスタマイズするのに役立ちます。 最も一般的に使用されるフォーマット指定子には以下が含まれます。

  • "c": 不変形式(例:1日、2時間、30分、45秒は1.02:30:45).
  • "g": 標準形式指定子であり、日数の部分がゼロの場合はそれを除外します。(例: 02:30:45).
  • カスタム形式: 時間と分のみ、または日付と時間を表示するなど、特定のニーズを満たすためにカスタム形式を定義できます。

    レポートまたはログで出力する際のTimeSpanのフォーマット例は以下の通りです。

TimeSpan duration = new TimeSpan(1, 2, 30, 45); // 1 day, 2 hours, 30 minutes, 45 seconds
// Default"c" format strings produce the output: 1.02:30:45
Console.WriteLine(duration.ToString("c"));
// Custom format "hh:mm:ss" outputs: 26:30:45
Console.WriteLine(duration.ToString(@"hh\:mm\:ss")); 
// Custom format with days, outputs: 1d 02h 30m
Console.WriteLine(duration.ToString(@"d'd 'hh'h 'mm'm '"));
TimeSpan duration = new TimeSpan(1, 2, 30, 45); // 1 day, 2 hours, 30 minutes, 45 seconds
// Default"c" format strings produce the output: 1.02:30:45
Console.WriteLine(duration.ToString("c"));
// Custom format "hh:mm:ss" outputs: 26:30:45
Console.WriteLine(duration.ToString(@"hh\:mm\:ss")); 
// Custom format with days, outputs: 1d 02h 30m
Console.WriteLine(duration.ToString(@"d'd 'hh'h 'mm'm '"));
Dim duration As New TimeSpan(1, 2, 30, 45) ' 1 day, 2 hours, 30 minutes, 45 seconds
' Default"c" format strings produce the output: 1.02:30:45
Console.WriteLine(duration.ToString("c"))
' Custom format "hh:mm:ss" outputs: 26:30:45
Console.WriteLine(duration.ToString("hh\:mm\:ss"))
' Custom format with days, outputs: 1d 02h 30m
Console.WriteLine(duration.ToString("d'd 'hh'h 'mm'm '"))
VB   C#

この例は次の出力を表示します:

C# タイムスパン形式(開発者向けの動作方法):図2

IronPDFを使用したPDF生成におけるTimeSpanの利用

.NETプロジェクトでのIronPDFのセットアップ

使用を開始するにはIronPDF、最初にそれをインストールする必要があります。 すでにインストールされている場合は、次のセクションに進むことができます。そうでない場合は、以下の手順がIronPDFライブラリのインストール方法を説明しています。

NuGet パッケージ マネージャー コンソール経由で

以下の内容を日本語に翻訳してください:

ToIronPDF をインストールするNuGetパッケージマネージャーコンソールを使用して、Visual Studioを開き、パッケージマネージャーコンソールに移動します。 次に、以下のコマンドを実行します。

Install-Package IronPdf
Install-Package IronPdf
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'Install-Package IronPdf
VB   C#

ソリューション用のNuGet パッケージ マネージャーを介して

Visual Studioを開き、「ツール -> NuGet パッケージマネージャー -> ソリューションのNuGetパッケージを管理」に移動し、IronPDFを検索します。 ここからは、プロジェクトを選択して「インストール」をクリックするだけで、IronPDF がプロジェクトに追加されます。

C# タイムスパンフォーマット(開発者向けの動作):図3

IronPDFをインストールしたら、IronPDFを使用するために必要なのはコードの先頭に正しいusingステートメントを追加することだけです。

using IronPdf;
using IronPdf;
Imports IronPdf
VB   C#

これで、IronPDFとTimeSpanを使用してPDF生成タスクを開始する準備が整いました。

IronPDFを使用した時間ベースのレポートの生成

IronPDFをセットアップした後、TimeSpanデータを使用して情報豊富なPDFレポートを生成できます。 たとえば、従業員の作業ログを生成する必要があるシナリオを考えてみましょう。 TimeSpan 値を活用して、タスクの期間や休憩時間を効果的に表示することができます。

例のシナリオ: PDFレポートでのTimeSpan値の書式設定

以下は、PDFレポートでTimeSpanデータを使用する方法です。簡単な作業ログの生成を含みます。

using IronPdf;
public static void Main(string[] args)
{
    TimeSpan duration = new TimeSpan(9, 30, 25);
    var employees = new List<(string name, TimeSpan timeSpan)> {
    ("Jane Doe",  duration),
    ("John Doe", duration)
    };
    GenerateWorkLogReport(employees);
}
public static void GenerateWorkLogReport(List<(string Employee, TimeSpan Duration)> workLogs)
{
    ChromePdfRenderer renderer = new ChromePdfRenderer();
    var htmlContent = "<h1>Work Log Report</h1><table border='1'><tr><th>Employee</th><th>Duration</th></tr>";
    foreach (var log in workLogs)
    {
        htmlContent += $"<tr><td>{log.Employee}</td><td>{log.Duration.ToString(@"hh\:mm\:ss")}</td></tr>";
    }
    htmlContent += "</table>";
    var pdf = renderer.RenderHtmlAsPdf(htmlContent);
    pdf.SaveAs("WorkLogReport.pdf");
}
using IronPdf;
public static void Main(string[] args)
{
    TimeSpan duration = new TimeSpan(9, 30, 25);
    var employees = new List<(string name, TimeSpan timeSpan)> {
    ("Jane Doe",  duration),
    ("John Doe", duration)
    };
    GenerateWorkLogReport(employees);
}
public static void GenerateWorkLogReport(List<(string Employee, TimeSpan Duration)> workLogs)
{
    ChromePdfRenderer renderer = new ChromePdfRenderer();
    var htmlContent = "<h1>Work Log Report</h1><table border='1'><tr><th>Employee</th><th>Duration</th></tr>";
    foreach (var log in workLogs)
    {
        htmlContent += $"<tr><td>{log.Employee}</td><td>{log.Duration.ToString(@"hh\:mm\:ss")}</td></tr>";
    }
    htmlContent += "</table>";
    var pdf = renderer.RenderHtmlAsPdf(htmlContent);
    pdf.SaveAs("WorkLogReport.pdf");
}
Imports IronPdf
Public Shared Sub Main(ByVal args() As String)
	Dim duration As New TimeSpan(9, 30, 25)
	Dim employees = New List(Of (name As String, timeSpan As TimeSpan)) From {("Jane Doe", duration), ("John Doe", duration)}
	GenerateWorkLogReport(employees)
End Sub
Public Shared Sub GenerateWorkLogReport(ByVal workLogs As List(Of (Employee As String, Duration As TimeSpan)))
	Dim renderer As New ChromePdfRenderer()
	Dim htmlContent = "<h1>Work Log Report</h1><table border='1'><tr><th>Employee</th><th>Duration</th></tr>"
	For Each log In workLogs
		htmlContent &= $"<tr><td>{log.Employee}</td><td>{log.Duration.ToString("hh\:mm\:ss")}</td></tr>"
	Next log
	htmlContent &= "</table>"
	Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
	pdf.SaveAs("WorkLogReport.pdf")
End Sub
VB   C#

C# Timespan フォーマット(開発者向けの動作方法):図4

この例では、従業員の作業記録を表示するためにシンプルなテーブルを作成しました。 GenerateWorkLogReport メソッドは、整形された TimeSpan 値を含むHTMLテーブルを生成し、その後PDFドキュメントに変換します。 IronPDFのChromePdfRendererHTMLコンテンツをPDF形式にレンダリングするクラス。 PdfDocument作成された新しいPDFを処理し、保存するために使用されるPDFオブジェクトを作成するために使用されます。

レポートでのTimeSpanのフォーマットと使用に関する高度な手法

さまざまな使用ケースに合わせたTimeSpan出力のカスタマイズ

TimeSpan出力をカスタマイズすることで、レポートの可読性を大幅に向上させることができます。 たとえば、時間と分だけを表示する必要がある場合、TimeSpanをそれに応じてフォーマットすることができます。 この例では、前回の例で作成した同じ従業員データを使用し、作業した時間と分のみを表示するようにTimeSpanをフォーマットします。 このシナリオでは、秒数は記録に必要なく、単に不要なスペースを取るだけなので、省略してフォーマットします。

using IronPdf;
class Program
{
    public static void Main(string[] args)
    {
        TimeSpan duration = new TimeSpan(9, 30, 25);
        var employees = new List<(string name, TimeSpan timeSpan)> {
        ("Jane Doe",  duration),
        ("John Doe", duration)
        };
        GenerateWorkLogReport(employees);
    }
    public static void GenerateWorkLogReport(List<(string Employee, TimeSpan Duration)> workLogs)
    {
        ChromePdfRenderer renderer = new ChromePdfRenderer();
        var htmlContent = "<h1>Work Log Report</h1><table border='1'><tr><th>Employee</th><th>Duration</th></tr>";
        foreach (var log in workLogs)
        {
            // custom format string to format the TimeSpan value for display
            string formattedDuration = log.Duration.ToString(@"hh\:mm");
            htmlContent += $"<tr><td>{log.Employee}</td><td>{formattedDuration}</td></tr>";
        }
        htmlContent += "</table>";
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("WorkLogReport.pdf");
    }
}
using IronPdf;
class Program
{
    public static void Main(string[] args)
    {
        TimeSpan duration = new TimeSpan(9, 30, 25);
        var employees = new List<(string name, TimeSpan timeSpan)> {
        ("Jane Doe",  duration),
        ("John Doe", duration)
        };
        GenerateWorkLogReport(employees);
    }
    public static void GenerateWorkLogReport(List<(string Employee, TimeSpan Duration)> workLogs)
    {
        ChromePdfRenderer renderer = new ChromePdfRenderer();
        var htmlContent = "<h1>Work Log Report</h1><table border='1'><tr><th>Employee</th><th>Duration</th></tr>";
        foreach (var log in workLogs)
        {
            // custom format string to format the TimeSpan value for display
            string formattedDuration = log.Duration.ToString(@"hh\:mm");
            htmlContent += $"<tr><td>{log.Employee}</td><td>{formattedDuration}</td></tr>";
        }
        htmlContent += "</table>";
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("WorkLogReport.pdf");
    }
}
Imports IronPdf
Friend Class Program
	Public Shared Sub Main(ByVal args() As String)
		Dim duration As New TimeSpan(9, 30, 25)
		Dim employees = New List(Of (name As String, timeSpan As TimeSpan)) From {("Jane Doe", duration), ("John Doe", duration)}
		GenerateWorkLogReport(employees)
	End Sub
	Public Shared Sub GenerateWorkLogReport(ByVal workLogs As List(Of (Employee As String, Duration As TimeSpan)))
		Dim renderer As New ChromePdfRenderer()
		Dim htmlContent = "<h1>Work Log Report</h1><table border='1'><tr><th>Employee</th><th>Duration</th></tr>"
		For Each log In workLogs
			' custom format string to format the TimeSpan value for display
			Dim formattedDuration As String = log.Duration.ToString("hh\:mm")
			htmlContent &= $"<tr><td>{log.Employee}</td><td>{formattedDuration}</td></tr>"
		Next log
		htmlContent &= "</table>"
		Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
		pdf.SaveAs("WorkLogReport.pdf")
	End Sub
End Class
VB   C#

C# Timespan フォーマット(開発者向け):図5

この例では、ToString(@"hh\:mm\:ss") TimeSpan を 09:3 としてフォーマットします(合計時間と分)カスタム形式文字列を使用する場合は、TimeSpanが標準的な形式文字列型の使用もサポートしていることに注意する必要があります。これを使用して、ドキュメントの可読性を維持するためにTimeSpanを任意の形で表示することができます。 これを逆に行い、文字列をTimeSpanに解析することもできます。 パースは特定の形式に従う入力文字列を変換します。(「hh:mm」や「d.hh:mm」などの形式)C# がプログラムで操作できる実際の TimeSpan オブジェクトに変換します。

大きな時間間隔の処理と読みやすさのためのフォーマット

より大きなTimeSpan値を扱う際には、可読性のためにフォーマットすることが重要です。 例えば、「3日5時間」のように長い期間をより理解しやすい形式に変換できます。

class Program
{
    public static void Main(string[] args)
    {
        // Sample data: List of employee names and their work durations (TimeSpan)
        var workLogs = new List<(string Employee, TimeSpan Duration)>
        {
            ("Alice", new TimeSpan(5, 30, 0)), // 5 hours, 30 minutes
            ("Bob", new TimeSpan(3, 15, 0)),   // 3 hours, 15 minutes
            ("Charlie", new TimeSpan(7, 45, 0)) // 7 hours, 45 minutes
        };
        // Create the HTML content for the PDF report
        string htmlContent = @"
            <h1>Work Log Report</h1>
            <table border='1' cellpadding='5' cellspacing='0'>
                <tr>
                    <th>Employee</th>
                    <th>Work Duration (hh:mm:ss)</th>
                </tr>";
        // Loop through the work logs and add rows to the table
        foreach (var log in workLogs)
        {
            string formattedDuration = FormatLargeTimeSpan(log.Duration);  // Custom method to format large TimeSpan values
            htmlContent += $"<tr><td>{log.Employee}</td><td>{formattedDuration}</td></tr>";
        }
        // Close the HTML table
        htmlContent += "</table>";
        // Create a new HtmlToPdf renderer
        ChromePdfRenderer renderer = new ChromePdfRenderer();
        // Render the HTML content as a PDF
        PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
        // Save the PDF to a file
        pdf.SaveAs("WorkLogReport.pdf");
    }
    // Custom method to handle the formatting operation
    static string FormatLargeTimeSpan(TimeSpan timeSpan)
    {
        // Check if there are days in the TimeSpan and format accordingly
        if (timeSpan.TotalDays >= 1)
        {
            return string.Format("{0} days, {1} hours, {2} minutes",
                (int)timeSpan.TotalDays,
                timeSpan.Hours,
                timeSpan.Minutes);
        }
        else
        {
            // If the duration is less than a day, show only hours and minutes
            return string.Format("{0} hours, {1} minutes", timeSpan.Hours, timeSpan.Minutes);
        }
    }
}
class Program
{
    public static void Main(string[] args)
    {
        // Sample data: List of employee names and their work durations (TimeSpan)
        var workLogs = new List<(string Employee, TimeSpan Duration)>
        {
            ("Alice", new TimeSpan(5, 30, 0)), // 5 hours, 30 minutes
            ("Bob", new TimeSpan(3, 15, 0)),   // 3 hours, 15 minutes
            ("Charlie", new TimeSpan(7, 45, 0)) // 7 hours, 45 minutes
        };
        // Create the HTML content for the PDF report
        string htmlContent = @"
            <h1>Work Log Report</h1>
            <table border='1' cellpadding='5' cellspacing='0'>
                <tr>
                    <th>Employee</th>
                    <th>Work Duration (hh:mm:ss)</th>
                </tr>";
        // Loop through the work logs and add rows to the table
        foreach (var log in workLogs)
        {
            string formattedDuration = FormatLargeTimeSpan(log.Duration);  // Custom method to format large TimeSpan values
            htmlContent += $"<tr><td>{log.Employee}</td><td>{formattedDuration}</td></tr>";
        }
        // Close the HTML table
        htmlContent += "</table>";
        // Create a new HtmlToPdf renderer
        ChromePdfRenderer renderer = new ChromePdfRenderer();
        // Render the HTML content as a PDF
        PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
        // Save the PDF to a file
        pdf.SaveAs("WorkLogReport.pdf");
    }
    // Custom method to handle the formatting operation
    static string FormatLargeTimeSpan(TimeSpan timeSpan)
    {
        // Check if there are days in the TimeSpan and format accordingly
        if (timeSpan.TotalDays >= 1)
        {
            return string.Format("{0} days, {1} hours, {2} minutes",
                (int)timeSpan.TotalDays,
                timeSpan.Hours,
                timeSpan.Minutes);
        }
        else
        {
            // If the duration is less than a day, show only hours and minutes
            return string.Format("{0} hours, {1} minutes", timeSpan.Hours, timeSpan.Minutes);
        }
    }
}
Imports System

Friend Class Program
	Public Shared Sub Main(ByVal args() As String)
		' Sample data: List of employee names and their work durations (TimeSpan)
		Dim workLogs = New List(Of (Employee As String, Duration As TimeSpan)) From {("Alice", New TimeSpan(5, 30, 0)), ("Bob", New TimeSpan(3, 15, 0)), ("Charlie", New TimeSpan(7, 45, 0))}
		' Create the HTML content for the PDF report
		Dim htmlContent As String = "
            <h1>Work Log Report</h1>
            <table border='1' cellpadding='5' cellspacing='0'>
                <tr>
                    <th>Employee</th>
                    <th>Work Duration (hh:mm:ss)</th>
                </tr>"
		' Loop through the work logs and add rows to the table
		For Each log In workLogs
			Dim formattedDuration As String = FormatLargeTimeSpan(log.Duration) ' Custom method to format large TimeSpan values
			htmlContent &= $"<tr><td>{log.Employee}</td><td>{formattedDuration}</td></tr>"
		Next log
		' Close the HTML table
		htmlContent &= "</table>"
		' Create a new HtmlToPdf renderer
		Dim renderer As New ChromePdfRenderer()
		' Render the HTML content as a PDF
		Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
		' Save the PDF to a file
		pdf.SaveAs("WorkLogReport.pdf")
	End Sub
	' Custom method to handle the formatting operation
	Private Shared Function FormatLargeTimeSpan(ByVal timeSpan As TimeSpan) As String
		' Check if there are days in the TimeSpan and format accordingly
		If timeSpan.TotalDays >= 1 Then
			Return String.Format("{0} days, {1} hours, {2} minutes", CInt(Math.Truncate(timeSpan.TotalDays)), timeSpan.Hours, timeSpan.Minutes)
		Else
			' If the duration is less than a day, show only hours and minutes
			Return String.Format("{0} hours, {1} minutes", timeSpan.Hours, timeSpan.Minutes)
		End If
	End Function
End Class
VB   C#

C# Timespan フォーマット(開発者向けの仕組み):図6

この例では、カスタムメソッドFormatLargeTimeSpanは、大きなTimeSpan値を「6日、5時間、30分」のように読みやすい形式に変換します。TimeSpanの値に日付が含まれているかどうかを確認し、複合フォーマットをサポートするメソッドを使用して出力を適切にフォーマットします。

  • 合計時間が24時間を超える場合、日数が抽出され、残りの時間と分と共に表示されます。
  • 1日未満の間隔の場合、時間と分のみが表示されます。

TimeSpanベースのPDF生成にIronPDFを選ぶ理由は?

レポートアプリケーションのためのIronPDFの主要な利点

IronPDFは、文字列、時間、およびHTMLデータに基づく動的PDFの生成においてその強力な機能で際立っています。 IronPDFを使用すると、PDF関連の作業が簡単に処理できるようになります。 基本的なPDF生成から安全なPDF暗号化まで、IronPDFが対応します。 いくつかの主な利点には次のものがあります:

  • HTMLからPDFへの変換: 簡単に変換HTMLコンテンツレイアウトとデザインを維持しながらPDFに変換します。 IronPDFは、他の多くのファイルタイプからPDFへの変換も扱うことができます。DOCX, イメージ, URL、およびASPX.
  • カスタマイズオプション: カスタムテンプレートとフォーマットで特定のビジネスニーズに合わせてレポートを調整し、PDFファイルにプロフェッショナルな外観を与えます。ヘッダーとフッターa目次、またはカスタム背景.
  • ピクセルパーフェクトPDF: IronPDFは現代のウェブ標準を強力にサポートしているため、ブランドイメージに視覚的に一致する高品質なPDFドキュメントを生成します。ウェブコンテンツから生成されたPDFでも、常にピクセルパーフェクトに仕上がります。

.NETとのシームレスな統合とTimeSpanのフォーマット

IronPDFは.NETアプリケーションとシームレスに統合され、開発者がTimeSpan構造を効果的に活用できるようにします。 IronPDFを使用すると、最小限の労力で整形された時間データを含むプロフェッショナルなレポートを生成でき、報告プロセスを効率的かつ簡単に進めることができます。

結論

この記事では、C#でTimeSpan値をフォーマットし、扱う方法とそれをスムーズに統合する方法を探りました。IronPDF動的な時間ベースのレポートを生成するために。 C#のTimeSpanフォーマット構造は、プロジェクトの期間、作業ログ、タスク完了時間などの時間間隔を表現するための重要なツールです。 短期間を扱う場合でも、数日、数時間、数分に及ぶ大きな間隔を扱う場合でも、C#はこのデータを人間が読みやすい形式で提示するための柔軟なフォーマットオプションを提供します。 さらに進んだ例として、文化に合わせたフォーマット規則の遵守や、時間入力の取得、文字列をTimeSpanに解析するなどが含まれます。

IronPDFは、HTMLをPDFに精密に変換することに優れており、データ駆動型アプリケーションからレポートを生成するための理想的なツールです。 C#との統合により、TimeSpanのような複雑な構造を高品質のPDFに組み込むことが容易になります。

TimeSpanの値をどのようにフォーマットし、それをIronPDFを使用してPDFレポートに統合するかを理解した今、次のステップに進む時です。ダウンロードして下さい。無料体験IronPDFを活用して、プロジェクトのための動的でデータ駆動のレポートを生成する可能性を最大限に引き出しましょう。 IronPDFを使用すると、時間に基づくデータを洗練されたプロフェッショナルなドキュメントに最小限の労力で変換できます。

< 以前
C# 非同期処理の待機 (開発者向けの仕組み)
次へ >
C# での Parseint(開発者向けの仕組み)