フォントに上付きおよび下付きの効果を適用する
Contents
[
Hide
]
Aspose.Cellsは、テキストに上付き(基線の上)および下付き(基線の下)の効果を適用する機能を提供します。
上付きおよび下付きの操作
上付き文字の効果を適用するには、Style.Font オブジェクトの IsSuperscript プロパティを true に設定します。下付き文字を適用するには、Style.Font オブジェクトの IsSubscript プロパティを true に設定します。
以下のコード例では、テキストに上付き文字と下付き文字を適用する方法を示しています。
テキストに上付き文字の効果を適用する C# コード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Adding a new worksheet to the Excel object | |
workbook.Worksheets.Add(); | |
// Obtaining the reference of the newly added worksheet by passing its sheet index | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.Cells["A1"]; | |
// Adding some value to the "A1" cell | |
cell.PutValue("Hello"); | |
// Setting the font Superscript | |
Style style = cell.GetStyle(); | |
style.Font.IsSuperscript = true; | |
cell.SetStyle(style); | |
// Saving the Excel file | |
workbook.Save(dataDir+ "Superscript.out.xls", SaveFormat.Auto); |
テキストに下付き文字の効果を適用する C# コード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Adding a new worksheet to the Excel object | |
workbook.Worksheets.Add(); | |
// Obtaining the reference of the newly added worksheet by passing its sheet index | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.Cells["A1"]; | |
// Adding some value to the "A1" cell | |
cell.PutValue("Hello"); | |
// Setting the font Subscript | |
Style style = cell.GetStyle(); | |
style.Font.IsSubscript = true; | |
cell.SetStyle(style); | |
// Saving the Excel file | |
workbook.Save(dataDir+ "Subscript.out.xls", SaveFormat.Auto); |