NanoXLSX.Formatting 3.0.0
Loading...
Searching...
No Matches
FormattedTextBuilder.cs
1/*
2 * NanoXLSX is a small .NET library to generate and read XLSX (Microsoft Excel 2007 or newer) files in an easy and native way
3 * Copyright Raphael Stoeckli © 2026
4 * This library is licensed under the MIT License.
5 * You find a copy of the license in project folder or on: http://opensource.org/licenses/MIT
6 */
7
8using System;
9using NanoXLSX.Styles;
10
12{
17 {
18 private readonly FormattedText formattedText = new FormattedText();
19
26 public FormattedTextBuilder AddRun(string text, Font font = null)
27 {
28 formattedText.AddRun(text, font);
29 return this;
30 }
31
38 public FormattedTextBuilder AddRun(string text, Action<InlineStyleBuilder> styleBuilder)
39 {
40 formattedText.AddRun(text, styleBuilder);
41 return this;
42 }
43
51 public FormattedTextBuilder AddPhoneticRun(string text, uint startBase, uint endBase)
52 {
53 formattedText.AddPhoneticRun(text, startBase, endBase);
54 return this;
55 }
56
65 {
66 formattedText.SetPhoneticProperties(fontReference, type, alignment);
67 return this;
68 }
69
75 {
76 return formattedText;
77 }
78
83 public static implicit operator FormattedText(FormattedTextBuilder builder)
84 {
85 return builder.Build();
86 }
87 }
88}
Builder for creating formatted text entries with a fluent API.
FormattedText Build()
Method to build the formatted text instance.
FormattedTextBuilder AddRun(string text, Action< InlineStyleBuilder > styleBuilder)
Adds a text run with a style defined by a style builder action.
FormattedTextBuilder AddPhoneticRun(string text, uint startBase, uint endBase)
Adds a phonetic run to the formatted text.
FormattedTextBuilder SetPhoneticProperties(Font fontReference, PhoneticRun.PhoneticType type=PhoneticRun.PhoneticType.FullwidthKatakana, PhoneticRun.PhoneticAlignment alignment=PhoneticRun.PhoneticAlignment.Left)
Sets the phonetic properties for the formatted text.
FormattedTextBuilder AddRun(string text, Font font=null)
Adds a text run with an optional style to the formatted text.
Represents a phonetic run that provides pronunciation guidance for text.
PhoneticAlignment
Enumeration for phonetic text alignment.
PhoneticType
Enumeration for phonetic text types.
Represents a formatted text entry in Excel shared strings, supporting rich text with multiple runs an...