× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



This code only works with the latest beta versions of POI. Try changing the
line to:

HSSFColor color = (HSSFColor) HSSFColor.getIndexHash().get(colorIndex);

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-
bounces@xxxxxxxxxxxx] On Behalf Of Peter Dow
Sent: Monday, July 18, 2011 12:16 PM
To: Java Programming on and around the iSeries / AS400
Subject: Incompatible types error from getIndexHash()

IANAJP (I am not a Java programmer), so please don't expect much, i.e.
it may be a totally obvious error.

I get the following error when compiling a java program I'm trying to
use to figure out how to get the color of text in a cell.

testjava.java:33: incompatible types
found : java.lang.Object
required: org.apache.poi.hssf.util.HSSFColor
HSSFColor color = HSSFColor.getIndexHash().get(colorIndex);
^
1 error

Here's the entire program:

import java.io.*;
import java.util.Map;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

public class testjava {

public static void main () {

FileInputStream in = new FileInputStream("/home/pdow/test.xls");
POIFSFileSystem fs = new POIFSFileSystem(in);
HSSFWorkbook wb = new HSSFWorkbook(fs);

// The following code is from this thread:
//
http://apache-poi.1045710.n5.nabble.com/hssf-and-multiple-colors-per-
cell-td3425176.html


HSSFRichTextString str =
wb.getSheetAt(1).getRow(3).getCell(0).getRichStringCellValue();
for(int i = 0; i < str.numFormattingRuns(); i++){
short fontIndex = str.getFontOfFormattingRun(i);
HSSFFont font = wb.getFontAt(fontIndex);
int colorIndex = font.getColor();
HSSFColor color = HSSFColor.getIndexHash().get(colorIndex);
System.out.println(color);
}
}

I'm hoping it's something totally obvious to someone!

--*
Peter Dow*/
Dow Software Services, Inc.
909 793-9050
pdow@xxxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxxx>

/

--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing
list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.