POI 设置字体多种颜色
来源:互联网 发布:粒子群优化算法 编辑:程序博客网 时间:2024/05/22 13:50
import java.io.File;import java.io.FileOutputStream;import org.apache.poi.hssf.util.HSSFColor;import org.apache.poi.xssf.usermodel.XSSFCell;import org.apache.poi.xssf.usermodel.XSSFCellStyle;import org.apache.poi.xssf.usermodel.XSSFFont;import org.apache.poi.xssf.usermodel.XSSFRichTextString;import org.apache.poi.xssf.usermodel.XSSFRow;import org.apache.poi.xssf.usermodel.XSSFSheet;import org.apache.poi.xssf.usermodel.XSSFWorkbook;//学习地址:http://www.yiibai.com/apache_poi/apache_poi_cells.html//http://www.ithao123.cn/content-9901497.html//SXSSFWorkbook CellStyle 如何更改背景色://http://blog.csdn.net/downkang/article/details/14164811public class TestColor {public static void main(String[] args) throws Exception { XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet spreadsheet = workbook.createSheet("Fontstyle"); //数字2的意思是第2行 XSSFRow row = spreadsheet.createRow(2); //设置字体 XSSFFont font = workbook.createFont(); font.setFontHeightInPoints((short) 30); font.setFontName("IMPACT"); font.setItalic(true); font.setColor(HSSFColor.GREEN.index); //设置样式 XSSFCellStyle style = workbook.createCellStyle(); style.setFont(font); //5的意思是第5列 XSSFCell cell = row.createCell(5); XSSFRichTextString richString = new XSSFRichTextString( "asdfxghijkadfasdfad" ); //对"Hello,"设置redFont字体 richString.applyFont( 4, 8, font ); //设置单元格中的数据 cell.setCellValue(richString); //将样式给了单元格 cell.setCellStyle(style); //输出文件 FileOutputStream out = new FileOutputStream(new File("fontstyle.xlsx")); workbook.write(out); //关闭流文件 workbook.close(); out.close(); System.out.println("Excel生成成功,点击工程目录中查看...");}}
0 0
- POI 设置字体多种颜色
- UILabel设置多种字体、颜色
- UILabel设置多种字体、颜色
- UILabel设置多种字体、颜色
- UILabel设置多种字体、颜色
- UILabel设置多种字体、颜色
- UILable 设置多种字体颜色
- iOS 设置字体颜色和多种字体
- UILabel设置多种字体、颜色 (NSMutableAttributedString)
- UILabel设置多种字体、颜色(文本中字体不同颜色)
- android TextView的字体颜色设置的多种方法
- TextView的字体颜色设置的多种方法
- android TextView的字体颜色设置的多种方法
- TextView的字体颜色设置的多种方法
- 【Android基础】TextView的字体颜色设置的多种方法
- android TextView的字体颜色设置的多种方法
- TextView的字体颜色设置的多种方法
- textview设置多种不同的字体颜色和点击事件
- GLSL 内建变量
- 设计模式_桥接模式
- 什么是EPEL 及 Centos上安装EPEL
- comboBox&listBox
- 栈实现迷宫
- POI 设置字体多种颜色
- [BZOJ1029][JSOI2007]建筑抢修(贪心+堆)
- mac下安装使用gdb调试
- phoneline
- 垃圾回收机制
- php四种基础排序(基础算法)----①冒泡排序法
- 数据访问层
- 函数调用—sqrt函数
- windows2008服务器优化学习