使用 apache poi 将单元格内容的一部分设置为粗体? [英] Setting a part of the cell contents to bold using apache poi?

查看:42
本文介绍了使用 apache poi 将单元格内容的一部分设置为粗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 java apache poi 将此字符串放入单元格中?
字符串是Hello world Hello"
正如你所看到的,我需要将文本的一部分加粗?
我可以将单元格的全部内容设置为粗体,但不能将特定部分设置为粗体.
请帮助我.

How can i put this string in to a cell using java apache poi?
The string is "Hello world Hello"
As u can see i need to make a part of the text bold?
I'm able to set the entire contents of the cell to bold but not specific parts.
Please help me.

推荐答案

这可能就是您要找的:http://poi.apache.org/spreadsheet/quick-guide.html#DrawingShapes

在解释中找到这个:

可以使用不同的字体来设置文本框中部分文本的样式.方法如下:

It's possible to use different fonts to style parts of the text in the textbox. Here's how:

HSSFFont font = wb.createFont();
font.setItalic(true);
font.setUnderline(HSSFFont.U_DOUBLE);
HSSFRichTextString string = new HSSFRichTextString("Woo!!!");
string.applyFont(2,5,font);
textbox.setString(string );

这可能有用:http://apache-poi.1045710.n5.nabble.com/Multiple-text-styles-in-Excel-cell-td4922683.html

这篇关于使用 apache poi 将单元格内容的一部分设置为粗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆