NanoXLSX.Formatting 3.1.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
11// TODO: Consider changing this namespace in a future major release.
13{
18 {
19 private readonly FormattedText formattedText = new FormattedText();
20
27 public FormattedTextBuilder AddRun(string text, Font font = null)
28 {
29 formattedText.AddRun(text, font);
30 return this;
31 }
32
39 public FormattedTextBuilder AddRun(string text, Action<InlineStyleBuilder> styleBuilder)
40 {
41 formattedText.AddRun(text, styleBuilder);
42 return this;
43 }
44
52 public FormattedTextBuilder AddPhoneticRun(string text, uint startBase, uint endBase)
53 {
54 formattedText.AddPhoneticRun(text, startBase, endBase);
55 return this;
56 }
57
66 {
67 formattedText.SetPhoneticProperties(fontReference, type, alignment);
68 return this;
69 }
70
76 {
77 return formattedText;
78 }
79
84 public static implicit operator FormattedText(FormattedTextBuilder builder)
85 {
86 return builder.Build();
87 }
88 }
89}
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...