article

How to Apply Superscript & Subscript Effects on Fonts in Worksheet using Java

Email
Submitted on: 10/7/2015 8:55:09 AM
By: Sherazam  
Level: Intermediate
User Rating: Unrated
Compatibility: Java (JDK 1.4), Java (JDK 1.5)
Views: 3804
 
     This technical tip show how developers can apply Superscript and Subscript effects on Fonts in Excel Workshet inside Android Apps. Superscript - characters that are raised above font's baseline - and subscript - characters lowered below the baseline - are used for many different reasons. Such as superscript is often used for trademark and copyright signs: Aspose TM and Subscript is probably best known from mathematical formulas and chemical descriptions: Uranium 234. Both are frequently used in mathematical notation. Aspose.Cells provides the functionality to set superscript and subscript effects on text.

 
				This technical tip show how developers can apply Superscript and Subscript effects on Fonts in Excel Workshet inside Android Apps. Superscript - characters that are raised above font's baseline - and subscript - characters lowered below the baseline - are used for many different reasons. Such as superscript is often used for trademark and copyright signs: Aspose TM and Subscript is probably best known from mathematical formulas and chemical descriptions: Uranium 234. Both are frequently used in mathematical notation. Aspose.Cells provides the functionality to set superscript and subscript effects on text. The code examples below show how to apply superscript and subscript effects on text using Aspose.Cells.
//Setting Superscript Effect
 
File sdDir = Environment.getExternalStorageDirectory();
String sdPath = sdDir.getCanonicalPath();
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Accessing the added worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
//Adding some value to the "A1" cell
Cell cell = cells.get("A1");
cell.setValue("Hello");
//Setting the font name to "Times New Roman"
Style style = cell.getStyle();
Font font = style.getFont();
font.setSuperscript(true);
cell.setStyle(style);
//Saving the modified Excel file in default format
workbook.save(sdPath + "/Superscript.xls");
//Setting Subscript Effect
File sdDir = Environment.getExternalStorageDirectory();
String sdPath = sdDir.getCanonicalPath();
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Accessing the added worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
//Adding some value to the "A1" cell
Cell cell = cells.get("A1");
cell.setValue("Hello");
//Setting the font name to "Times New Roman"
Style style = cell.getStyle();
Font font = style.getFont();
font.setSubscript(true);
cell.setStyle(style);
//Saving the modified Excel file in default format
workbook.save(sdPath + "/Subscript.xls");

More about Aspose.Cells for Android

  • Homepage of Aspose.Cells for Android
  • Download Aspose.Cells for Android

  • Other 6 submission(s) by this author

     


    Report Bad Submission
    Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
    This submission should be removed because:

    Your Vote

    What do you think of this article (in the Intermediate category)?
    (The article with your highest vote will win this month's coding contest!)
    Excellent  Good  Average  Below Average  Poor (See voting log ...)
     

    Other User Comments


     There are no comments on this submission.
     

    Add Your Feedback
    Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
     

    To post feedback, first please login.