How to Apply Superscript & Subscript Effects on Fonts in Worksheet inside Androi
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.
//your code here...//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");
Url: http://www.aspose.com/java/excel-component.aspx
Language: Java | User: Sheraz Khan | Created: Oct 7, 2015 | Tags: Apply Superscript in Excel workbook , set Subscript Effects in workbook, Setting Superscript Effect, Setting the font name, Adding some value Excel Cell, Android Excel component Apply Superscript in Excel workbook set Subscript Effects in workbook Setting Superscript Effect Setting the font name Android Excel component create Excel file in Android