From 47e484912d968c5f70027b8212939d7417fc33b0 Mon Sep 17 00:00:00 2001 From: Ramya Sivakumar Date: Mon, 8 Dec 2025 11:25:41 +0530 Subject: [PATCH 1/2] 992302-Superscript --- Document-Processing-toc.html | 3 + ...uperscript-for-certain-text-in-the-cell.md | 90 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-superscript-for-certain-text-in-the-cell.md diff --git a/Document-Processing-toc.html b/Document-Processing-toc.html index d785366d0..d6ca72322 100644 --- a/Document-Processing-toc.html +++ b/Document-Processing-toc.html @@ -5891,6 +5891,9 @@
  • How to extract embedded OLE files from an Excel workbook as streams?
  • +
  • + How to apply superscript to certain text in a cell? +
  • diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-superscript-for-certain-text-in-the-cell.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-superscript-for-certain-text-in-the-cell.md new file mode 100644 index 000000000..13436fffd --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-superscript-for-certain-text-in-the-cell.md @@ -0,0 +1,90 @@ +--- +title: Apply Superscript to Text in an Excel Cell | Syncfusion +description: Learn how to apply superscript to specific text in an Excel cell without affecting existing styles using the Syncfusion .NET Excel library (XlsIO). +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to apply superscript to certain text in a cell? + +The following code example illustrates how to apply superscript to certain text in a cell without affecting the existing style in C# (cross-platform and Windows-specific) and VB.NET. +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/FAQ/Superscript/.NET/Superscript%20for%20certain%20texts/SuperscriptForCertainTexts/Program.cs,180" %} + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + //Create a workbook + IWorkbook workbook = application.Workbooks.Open("../../../Data/Sample.xlsx"); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Add Text + IRange range = worksheet.Range["A1"]; + IRichTextString richText = range.RichText; + + IFont superScript = workbook.CreateFont(); + superScript.Size = richText.GetFont(6).Size; + superScript.FontName = richText.GetFont(6).FontName; + superScript.Color = richText.GetFont(6).Color; + superScript.Superscript = true; + richText.SetFont(6, 6, superScript); + + + //Save the workbook to disk in xlsx format + workbook.SaveAs("../../../Output/Output.xlsx"); + } +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + //Create a workbook + IWorkbook workbook = application.Workbooks.Open("../../Data/Sample.xlsx"); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Add Text + IRange range = worksheet.Range["A1"]; + IRichTextString richText = range.RichText; + + IFont superScript = workbook.CreateFont(); + superScript.Size = richText.GetFont(6).Size; + superScript.FontName = richText.GetFont(6).FontName; + superScript.Color = richText.GetFont(6).Color; + superScript.Superscript = true; + richText.SetFont(6, 6, superScript); + + + //Save the workbook to disk in xlsx format + workbook.SaveAs("../../Output/Output.xlsx"); +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + Using excelEngine As New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + 'Create a workbook + Dim workbook As IWorkbook = application.Workbooks.Open("../../Data/Sample.xlsx") + Dim worksheet As IWorksheet = workbook.Worksheets(0) + + 'Add Text + Dim range As IRange = worksheet.Range("A1") + Dim richText As IRichTextString = range.RichText + + Dim superScript As IFont = workbook.CreateFont() + superScript.Size = richText.GetFont(6).Size + superScript.FontName = richText.GetFont(6).FontName + superScript.Color = richText.GetFont(6).Color + superScript.Superscript = True + richText.SetFont(6, 6, superScript) + + 'Save the workbook to disk in xlsx format + workbook.SaveAs("../../Output/Output.xlsx") + End Using +{% endhighlight %} +{% endtabs %} + +A complete working example to apply superscript to certain text in a cell using C# is available on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/FAQ/Superscript/.NET/Superscript%20for%20certain%20texts). From 19b421c0543fda09d56b39c3449f7f5ead1a6c2d Mon Sep 17 00:00:00 2001 From: Ramya Sivakumar Date: Mon, 8 Dec 2025 12:32:46 +0530 Subject: [PATCH 2/2] 992302-Superscript --- .../how-to-apply-superscript-for-certain-text-in-the-cell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-superscript-for-certain-text-in-the-cell.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-superscript-for-certain-text-in-the-cell.md index 13436fffd..42587b3e8 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-superscript-for-certain-text-in-the-cell.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-superscript-for-certain-text-in-the-cell.md @@ -87,4 +87,4 @@ using (ExcelEngine excelEngine = new ExcelEngine()) {% endhighlight %} {% endtabs %} -A complete working example to apply superscript to certain text in a cell using C# is available on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/FAQ/Superscript/.NET/Superscript%20for%20certain%20texts). +A complete working example to apply superscript to certain text in a cell using C# is present on this GitHub page. \ No newline at end of file