HSSFRow row = sheet.getRow(0);

成都創(chuàng)新互聯(lián)于2013年創(chuàng)立,先為贛州等服務建站,贛州等地企業(yè),進行企業(yè)商務咨詢服務。為贛州企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務解決您的所有建站問題。
HSSFCell cell = row.getCell((short)0);//修改就可以得到其他格
HSSFCellStyle cellStyle = cell.getCellStyle();
HSSFFont font = cellStyle.getFont(workbook);
font = getColor();
random.nextInt(256)隨機產生一個256以內的整數(shù) ,
Integer.toHexString()將整數(shù)轉換成16進制表示,返回的是一個String類型
toUpperCase()是將一個String字符串轉換成大寫表示
例如 26——"1a"——"1A"
r =( ( r.length() == 1 )?( "0" + r) : r );這句的意思是如果r的長度為1,則前面補個"0",長度不是1,則返回r(三元表達式),如 r="2",就變成r="02"
int rgbR;
int rgbG;
int rgbB;
int minx = 0;
int miny = 0;
try {
File file = new File("E:\\dd.png");
BufferedImage image = ImageIO.read(file);
int width = image.getWidth();//圖片寬度
int height = image.getHeight();//圖片高度
for (int i = minx; i width; i++) {
for (int j = miny; j height; j++) {
int pixel = image.getRGB(i, j); // 下面三行代碼將一個數(shù)字轉換為RGB數(shù)字
rgbR = (pixel 0xff0000) 16;
rgbG = (pixel 0xff00) 8;
rgbB = (pixel 0xff);
System.out.println("i=" + i + ",j=" + j + ":(" + rgbR + "," + rgbG + "," + rgbB + ")");
}
}
System.out.println("圖片寬度為:"+width+",高度為:"+height);
} catch (IOException e) {
System.out.println("讀取文件出錯");
e.printStackTrace();
}
/**?
*?獲取十六進制的顏色代碼.例如??"#6E36B4"?,?For?HTML?,?
*?@return?String?
*/??
public?static?String?getRandColorCode(){??
String?r,g,b;??
Random?random?=?new?Random();??
r?=?Integer.toHexString(random.nextInt(256)).toUpperCase();??
g?=?Integer.toHexString(random.nextInt(256)).toUpperCase();??
b?=?Integer.toHexString(random.nextInt(256)).toUpperCase();??
r?=?r.length()==1???"0"?+?r?:?r?;??
g?=?g.length()==1???"0"?+?g?:?g?;??
b?=?b.length()==1???"0"?+?b?:?b?;??
return?r+g+b;??
}
java.awt.Color 類用于封裝默認 sRGB 顏色空間中的顏色,或者用于封裝由 ColorSpace
標識的任意顏色空間中的顏色。每種顏色都有一個隱式的 alpha 值 1.0,或者有一個在構造方法中提供的顯式的 alpha 值。alpha
值定義了顏色的透明度,可用一個在 0.0 - 1.0 或 0 - 255 范圍內的浮點值表示它。alpha 值為 1.0 或 255
則意味著顏色完全是不透明的,alpha 值為 0 或 0.0 則意味著顏色是完全透明的。在使用顯式的 alpha 值構造 Color
時,或者在獲取某個 Color 的顏色/alpha 分量時,從不將顏色分量預乘 alpha 分量。
希望可以幫助到你.
試試這個
int r=182;
int g=169;
int b=48;
textArea.setForeground(new Color(r,g,b));
分享名稱:java讀取全部顏色代碼,java顏色類怎么寫
本文網(wǎng)址:http://chinadenli.net/article41/dsecdhd.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供、網(wǎng)站維護、網(wǎng)站設計、虛擬主機、定制網(wǎng)站、關鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)