如何在Java中使用Apache POI框架创建RichTextString? [英] How to create a RichTextString using Apache POI framework in Java?
本文介绍了如何在Java中使用Apache POI框架创建RichTextString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Java SE中的Apache POI框架为Microsoft Excel创建RichTextString?
How to create a RichTextString for Microsoft Excel, using Apache POI framework in Java SE?
推荐答案
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.setCellValue(s1);
这篇关于如何在Java中使用Apache POI框架创建RichTextString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文