Click here to Skip to main content
13,634,012 members
Click here to Skip to main content
Add your own
alternative version


4 bookmarked
Posted 17 Aug 2017
Licenced CPOL

Excel Interop, Subscripts and Superscripts

, 17 Aug 2017
Rate this:
Please Sign up or sign in to vote.
A demo that generates a simple Excel spreadsheet with subscripts and superscripts

Note: To run the code, you must have Excel 2010 or above and Visual Studio installed. The assembly that I reference is Microsoft.Office.Interop.Excel 14.0.


From time to time, we need to put subscripts and superscripts into an Excel spreadsheet. While Unicode does support subscripts and superscripts (in plain text format) for some characters, many characters are not supported. This demo will show you how to format characters in Excel as subscripts and superscripts.

Using the Code

Download and unzip the file attached, open ExcelDemo.cs, go to method PopulateTable, you will find this:

private void PopulateTable(Excel.Worksheet sheet)
    Excel.Range cell1 = sheet.Cells[1, 1];
    Excel.Range cell2 = sheet.Cells[1, 2];
    cell1.Value = "Time (s)";
    cell2.Value = "vball1 (m/s)";
    cell2.Characters[2, 4].Font.Subscript = true;
    cell2.Characters[6, 1].Font.Superscript = true;

For a cell in an excel spreadsheet, you may select the characters that you want to format, and set them as subscripts or superscripts.

Similarly, you may also format a chart like this (check method AddChart):

// Format yAxis
var yAxis = (Excel.Axis)chart.Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary);
yAxis.HasTitle = true;
yAxis.AxisTitle.Text = "vball (m/s)";
yAxis.AxisTitle.Characters.Font.Size = 12;
yAxis.AxisTitle.Characters[2, 4].Font.Subscript = true;



  • Version 1.0. August 17, 2017


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Dennis Wu CA
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04-2016 | 2.8.180712.1 | Last Updated 18 Aug 2017
Article Copyright 2017 by Dennis Wu CA
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid