How to create a RichTextString using Apache POI framework in Java?
问题 How to create a RichTextString for Microsoft Excel, using Apache POI framework in Java SE? 回答1: From here and here for HSSF and XSSF: HSSFCell hssfCell = row.createCell(idx); //rich text consists of two runs HSSFRichTextString richString = new HSSFRichTextString( "Hello, World!" ); richString.applyFont( 0, 6, font1 ); richString.applyFont( 6, 13, font2 ); hssfCell.setCellValue( richString ); XSSFRichTextString s1 = new XSSFRichTextString("Apache POI"); s1.applyFont(boldArial); cell1