AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Java juice in axlz9/6/2023 ![]() ![]() Wb.saveToFile("output/ApplyMultipleFontsToCell.xlsx", ExcelVersion.Version2016) Apply two fonts to the text in the cell B5 RichText richText = sheet.getCellRange("B5").getRichText() Worksheet sheet = wb.getWorksheets().get(0) Apply the two ExcelFont objects to the rich text using tFont() method. ![]() Get a specific cell using Worksheet.getCellRange() method, and set the rich text content of the cell using CellRange.getRichText().setText() method.Create two ExcelFont objects using Workbook.createFont() method.The following are the steps to apply multiple fonts in a cell using Spire.XLS for Java. Mixing different font styles can help you emphasize some specific characters in a cell. Workbook.saveToFile("output/ApplyFontToCell.xlsx", ExcelVersion.Version2016) Sheet.getCellRange("B7").getCellStyle().getExcelFont().isStrikethrough(true) Sheet.getCellRange("B7").setText("Font style: Strikethrough") Sheet.getCellRange("B6").getCellStyle().getExcelFont().setUnderline(FontUnderlineType.Single) Sheet.getCellRange("B6").setText("Font style: Underline") Sheet.getCellRange("B5").getCellStyle().getExcelFont().isItalic(true) ![]() Sheet.getCellRange("B5").setText("Font style: Italic") Sheet.getCellRange("B4").getCellStyle().getExcelFont().isBold(true) Sheet.getCellRange("B4").setText("Font style: Bold") Sheet.getCellRange("B3").getCellStyle().getExcelFont().setColor(Color.blue) Sheet.getCellRange("B3").setText("Font color: Blue") Sheet.getCellRange("B2").getCellStyle().getExcelFont().setSize(20) Sheet.getCellRange("B2").setText("Font size: 20") Sheet.getCellRange("B1").getCellStyle().getExcelFont().setFontName("Comic Sans MS") Sheet.getCellRange("B1").setText("Font name: Comic Sans MS") Worksheet sheet = workbook.getWorksheets().get(0)
0 Comments
Read More
Leave a Reply. |