(六)POI-操作Excel的poi的字體設置


原文鏈接:https://blog.csdn.net/class157/article/details/92817286

package com.java.poi;
 
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
 
import java.io.FileOutputStream;
 
/**
 * @program: IdeaProjects
 * @description:
 * @author: Lxy
 * @create: 2019-06-19 09:45
 **/
public class Test7 {
    public static void main(String[] args) throws Exception {
 
        Workbook wb=new HSSFWorkbook();
        Sheet sheet = wb.createSheet("sheet頁");
        Row row=sheet.createRow(1);
 
        //創建一個字體
        Font font=wb.createFont();
        font.setFontHeightInPoints((short) 24);
        font.setFontName("Courier New ");
        font.setItalic(true);
        font.setStrikeout(true);
 
        CellStyle style=wb.createCellStyle();
        style.setFont(font);
 
        Cell cell = row.createCell((short) 1);
        cell.setCellValue("this is test of fonts");
        cell.setCellStyle(style);
 
        FileOutputStream is=new FileOutputStream("D:\\3.xls");
        wb.write(is);
        is.close();
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM