Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JSpreadsheet
>
Tutorial
> Superscript Text
The following example shows you how to set superscript text.
import com.independentsoft.office.spreadsheet.Cell; import com.independentsoft.office.spreadsheet.RichTextInline; import com.independentsoft.office.spreadsheet.Run; import com.independentsoft.office.spreadsheet.RunVerticalAlignment; import com.independentsoft.office.spreadsheet.Text; import com.independentsoft.office.spreadsheet.Workbook; import com.independentsoft.office.spreadsheet.Worksheet; public class Example { public static void main(String[] args) { try { Run run1 = new Run(); run1.setText(new Text("normal ")); Run run2 = new Run(); run2.setText(new Text("superscript")); run2.setRunVerticalAlignment(RunVerticalAlignment.SUPERSCRIPT); RichTextInline richTextInline = new RichTextInline(); richTextInline.getRuns().add(run1); richTextInline.getRuns().add(run2); Cell cell1 = new Cell(); cell1.setRichTextInline(richTextInline); Worksheet sheet1 = new Worksheet(); sheet1.set("A1",cell1); Workbook book = new Workbook(); book.getSheets().add(sheet1); book.save("c:\\test\\output.xlsx", true); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*