anahtar hücrenin değerini ayarlamak için HSSFRichTextString nesne kullanıyor. Bu nesne, bir startIndex, endingIndex ve bir Yazı tipi kabul eden bir applyFont yöntemine sahiptir. Böylece, istediğiniz renklere sahip yazı tipleri oluşturabilir, ardından bunları applyFont() kullanarak hücre değerinin bölümlerine uygulayabilirsiniz. İşte
ben birlikte kaldırımlı bazı örnek kodu (tamamen denenmemiş) 'dir:
// Set up a rudimentary worksheet with a cell in it
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet(“sheet1”);
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell(0);
// Set up fonts
HSSFFont blueFont = workbook.createFont();
blueFont.setColor(HSSFColor.BLUE.index);
HSSFFont greenFont = workbook.createFont();
greenFont.setColor(HSSFColor.GREEN.index);
// create a cell style and assign the first font to it
HSSFCellStyle style = workbook.createCellStyle();
style.setFont(blueFont);
// assign the style to the cell
cell.setCellStyle(style);
// override the parts of the text that you want to
// color differently by applying a different font.
HSSFRichTextString richString = new HSSFRichTextString("Hello, World!");
richString.applyFont(6, 13, greenFont);
cell.setCellValue(richString);
@BrianRogers sayesinde birden çok renk olabilir. –