本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFFont.setColor方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFFont.setColor方法的具體用法?Java HSSFFont.setColor怎麽用?Java HSSFFont.setColor使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.hssf.usermodel.HSSFFont的用法示例。
在下文中一共展示了HSSFFont.setColor方法的41個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: createHSSFCellStyle
點讚 5
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private HSSFCellStyle createHSSFCellStyle(Workbook wb, int[] bgColor, int[] fontColor, int fontSize) {
HSSFWorkbook workbook = (HSSFWorkbook) wb;
HSSFPalette palette = workbook.getCustomPalette();
palette.setColorAtIndex((short) 9, (byte) fontColor[0], (byte) fontColor[1], (byte) fontColor[2]);
palette.setColorAtIndex((short) 10, (byte) bgColor[0], (byte) bgColor[1], (byte) bgColor[2]);
HSSFFont titleFont = workbook.createFont();
titleFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
titleFont.setFontName("宋體");
titleFont.setColor((short) 9);
titleFont.setBold(true);
titleFont.setFontHeightInPoints((short) fontSize);
HSSFCellStyle titleStyle = (HSSFCellStyle) createBorderCellStyle(workbook, true);
titleStyle.setFont(titleFont);
titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
titleStyle.setFillForegroundColor((short) 10);
titleStyle.setAlignment(HorizontalAlignment.CENTER);
titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
return titleStyle;
}
開發者ID:bsteker,項目名稱:bdf2,代碼行數:24,
示例2: createCellStyleForColumnHeading
點讚 4
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
public static HSSFCellStyle createCellStyleForColumnHeading(HSSFWorkbook workBook) {
HSSFCellStyle cellStyle = workBook.createCellStyle();
HSSFFont fontObj = workBook.createFont();
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setWrapText(true);
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setFillBackgroundColor(Short.valueOf("22").shortValue());
cellStyle.setFillPattern(FillPatternType.BIG_SPOTS);
cellStyle.setFillForegroundColor(Short.valueOf("22").shortValue());
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
fontObj.setFontName("Calibri");
fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
fontObj.setBold(true);
fontObj.setColor(Short.valueOf("8").shortValue());
cellStyle.setFont(fontObj);
return cellStyle;
}
開發者ID:siteadmin,項目名稱:CCDA-Score-CARD,代碼行數:21,
示例3: estiloCabecalho
點讚 4
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Estilo de cabecalho.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloCabecalho(HSSFWorkbook wb){
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THICK);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THICK);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THICK);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THICK);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//cellStyle.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
cellStyle.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = cellStyle.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
cellStyle.setFont(font);
return cellStyle;
}
開發者ID:darciopacifico,項目名稱:omr,代碼行數:30,
示例4: estiloDadosConsultado
點讚 4
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Estilo dos campos dos dados.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloDadosConsultado(HSSFWorkbook wb){
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
// plano de fundo - para que funcione deve se
// definido antes um padrao de preenchimento.
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//cellStyle.setFillForegroundColor(HSSFColor.AQUA.index);
cellStyle.setFillForegroundColor(HSSFColor.WHITE.index);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = cellStyle.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
cellStyle.setFont(font);
return cellStyle;
}
開發者ID:darciopacifico,項目名稱:omr,代碼行數:32,
示例5: estiloDadosRetorno
點讚 4
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Estilo dos campos dos dados.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloDadosRetorno(HSSFWorkbook wb){
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
// plano de fundo - para que funcione deve se
// definido antes um padrao de preenchimento.
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//cellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
cellStyle.setFillForegroundColor(HSSFColor.PALE_BLUE.index);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = cellStyle.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
cellStyle.setFont(font);
return cellStyle;
}
開發者ID:darciopacifico,項目名稱:omr,代碼行數:32,
示例6: estiloCabecalho
點讚 4
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Estilo de cabecalho.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloCabecalho(HSSFWorkbook wb){
if(this.estiloCabecalho==null){
this.estiloCabecalho = wb.createCellStyle();
this.estiloCabecalho.setBorderBottom(HSSFCellStyle.BORDER_THIN);
this.estiloCabecalho.setBorderRight(HSSFCellStyle.BORDER_THIN);
this.estiloCabecalho.setBorderLeft(HSSFCellStyle.BORDER_THIN);
this.estiloCabecalho.setBorderTop(HSSFCellStyle.BORDER_THIN);
this.estiloCabecalho.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//cellStyle.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
this.estiloCabecalho.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
this.estiloCabecalho.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = this.estiloCabecalho.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
this.estiloCabecalho.setFont(font);
}
return this.estiloCabecalho;
}
開發者ID:darciopacifico,項目名稱:omr,代碼行數:32,
示例7: addColourToFont
點讚 4
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
@Override
public void addColourToFont(Workbook workbook, Font font, String colour) {
if(colour == null) {
return ;
}
if(IStyle.TRANSPARENT_VALUE.equals(colour)) {
return ;
}
if(font instanceof HSSFFont) {
HSSFFont hFont = (HSSFFont)font;
short colourIndex = getHColour((HSSFWorkbook)workbook, colour);
if( colourIndex > 0 ) {
hFont.setColor(colourIndex);
}
}
}
開發者ID:eclipse,項目名稱:birt,代碼行數:17,
示例8: setHeaderStyle
點讚 4
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setHeaderStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
style.setWrapText(true);
headerStyle = style;
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:19,
示例9: setVerticalHeaderStyle
點讚 4
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setVerticalHeaderStyle(HSSFWorkbook wb) {
verticalHeaderStyle = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 8);
verticalHeaderStyle.setFont(font);
verticalHeaderStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
verticalHeaderStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
verticalHeaderStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
verticalHeaderStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
verticalHeaderStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
verticalHeaderStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
verticalHeaderStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
verticalHeaderStyle.setRotation((short) 90);
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:17,
示例10: setDoubleNegativeStyle
點讚 4
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setDoubleNegativeStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
style.setDataFormat(wb.createDataFormat().getFormat("#,##0.00"));
font.setColor(HSSFColor.RED.index);
doubleNegativeStyle = style;
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:12,
示例11: createHeader
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void createHeader(
HSSFWorkbook wb,
HSSFSheet sheet,
List informeCamps) {
HSSFFont bold;
bold = wb.createFont();
bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
bold.setColor(HSSFColor.WHITE.index);
HSSFCellStyle headerStyle;
headerStyle = wb.createCellStyle();
headerStyle.setFillPattern(HSSFCellStyle.FINE_DOTS);
headerStyle.setFillBackgroundColor(HSSFColor.GREY_80_PERCENT.index);
headerStyle.setFont(bold);
int rowNum = 0;
int colNum = 0;
// Capçalera
HSSFRow xlsRow = sheet.createRow(rowNum++);
HSSFCell cell;
cell = xlsRow.createCell(colNum++);
cell.setCellValue(new HSSFRichTextString(StringUtils.capitalize("Expedient")));
cell.setCellStyle(headerStyle);
for (TascaDadaDto camp : informeCamps) {
sheet.autoSizeColumn(colNum);
cell = xlsRow.createCell(colNum++);
cell.setCellValue(new HSSFRichTextString(StringUtils.capitalize(camp.getCampEtiqueta())));
cell.setCellStyle(headerStyle);
}
}
開發者ID:GovernIB,項目名稱:helium,代碼行數:29,
示例12: createCellStyleForComRepNotSetUp
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
public static HSSFCellStyle createCellStyleForComRepNotSetUp(HSSFWorkbook workBook) {
HSSFCellStyle cellStyle = workBook.createCellStyle();
HSSFFont fontObj = workBook.createFont();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
fontObj.setFontName("Calibri");
fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
fontObj.setBold(true);
fontObj.setColor((short) 10);
cellStyle.setFont(fontObj);
return cellStyle;
}
開發者ID:siteadmin,項目名稱:CCDA-Score-CARD,代碼行數:12,
示例13: createCellStyleForComRepSetUp
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
public static HSSFCellStyle createCellStyleForComRepSetUp(HSSFWorkbook workBook) {
HSSFCellStyle cellStyle = workBook.createCellStyle();
HSSFFont fontObj = workBook.createFont();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
fontObj.setFontName("Calibri");
fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
fontObj.setBold(true);
fontObj.setColor((short) 17);
cellStyle.setFont(fontObj);
return cellStyle;
}
開發者ID:siteadmin,項目名稱:CCDA-Score-CARD,代碼行數:12,
示例14: generateHeaderStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Description: 生成表格的 頭部的單元格樣式
* @param workbook
* @return
*
* @History
* 1. 2014-12-19 linwb 創建方法
*/
private HSSFCellStyle generateHeaderStyle(HSSFWorkbook workbook) {
//生成表格頭部標題欄樣式
HSSFCellStyle headerStyle = workbook.createCellStyle();
// 設置這些樣式
headerStyle.setFillForegroundColor(headerCellBackgroundColor);
headerStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
headerStyle.setBorderBottom(headerBorderBottom);
headerStyle.setBorderLeft(headerBorderLeft);
headerStyle.setBorderRight(headerBorderRight);
headerStyle.setBorderTop(headerBorderTop);
headerStyle.setAlignment(headerCellTextAlign);
headerStyle.setVerticalAlignment(headerCellVehicleAlign);
// 生成字體
HSSFFont font = workbook.createFont();
font.setColor(headerFontColor);
font.setFontHeightInPoints(headerFontHeight);
font.setBoldweight(headerFontWeight);
// 把字體應用到當前的樣式
headerStyle.setFont(font);
return headerStyle;
}
開發者ID:webinglin,項目名稱:excelExportor,代碼行數:35,
示例15: estiloDadosConsultado
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Estilo dos campos dos dados.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloDadosConsultado(HSSFWorkbook wb){
if(this.estiloDadoConsultado==null){
this.estiloDadoConsultado = wb.createCellStyle();
this.estiloDadoConsultado.setBorderBottom(HSSFCellStyle.BORDER_THIN);
this.estiloDadoConsultado.setBorderRight(HSSFCellStyle.BORDER_THIN);
this.estiloDadoConsultado.setBorderLeft(HSSFCellStyle.BORDER_THIN);
this.estiloDadoConsultado.setBorderTop(HSSFCellStyle.BORDER_THIN);
// plano de fundo - para que funcione deve se
// definido antes um padrao de preenchimento.
this.estiloDadoConsultado.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//cellStyle.setFillForegroundColor(HSSFColor.AQUA.index);
this.estiloDadoConsultado.setFillForegroundColor(HSSFColor.WHITE.index);
this.estiloDadoConsultado.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = this.estiloDadoConsultado.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
this.estiloDadoConsultado.setFont(font);
}
return this.estiloDadoConsultado;
}
開發者ID:darciopacifico,項目名稱:omr,代碼行數:34,
示例16: estiloDadosRetorno
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Estilo dos campos dos dados.
* @param wb
* @return retorna o estilo da celula.
* @author Ekler Paulino de Mattos.
*/
private HSSFCellStyle estiloDadosRetorno(HSSFWorkbook wb){
if(this.cellStyle==null){
this.cellStyle = wb.createCellStyle();
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
// plano de fundo - para que funcione deve se
// definido antes um padrao de preenchimento.
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//cellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
cellStyle.setFillForegroundColor(HSSFColor.PALE_BLUE.index);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFFont font = cellStyle.getFont(wb);
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
font.setColor(HSSFFont.COLOR_NORMAL);
font.setFontName(HSSFFont.FONT_ARIAL);
cellStyle.setFont(font);
}
return this.cellStyle;
}
開發者ID:darciopacifico,項目名稱:omr,代碼行數:33,
示例17: setHeaderStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Sets header style
* @param worksheet the worksheet
* @param fontName font name
* @param fontColor font color
* @param fontBoldweight font weight
*/
public static void setHeaderStyle(Worksheet worksheet, String fontName,
short fontColor, short fontBoldweight) {
HSSFWorkbook workbook = worksheet.getWorkbook();
HSSFFont font = workbook.createFont();
font.setFontName(fontName);
font.setColor(fontColor);
font.setBoldweight(fontBoldweight);
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFont(font);
worksheet.setCellStyle(cellStyle);
}
開發者ID:Impetus,項目名稱:jumbune,代碼行數:19,
示例18: postProcessXLS
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
public void postProcessXLS(Object document) {
HSSFWorkbook wb = (HSSFWorkbook) document;
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow header = sheet.getRow(0);
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.GREEN.index);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
for(int i=0; i < header.getPhysicalNumberOfCells();i++) {
HSSFCell cell = header.getCell(i);
cell.setCellStyle(cellStyle);
}
Row row=sheet.createRow((short)sheet.getLastRowNum()+3);
Cell cellDisclaimer = row.createCell(0);
HSSFFont customFont= wb.createFont();
customFont.setFontHeightInPoints((short)10);
customFont.setFontName("Arial");
customFont.setColor(IndexedColors.BLACK.getIndex());
customFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
customFont.setItalic(true);
cellDisclaimer.setCellValue("Disclaimer");
HSSFCellStyle cellStyleDisclaimer = wb.createCellStyle();
cellStyleDisclaimer.setFont(customFont);
cellDisclaimer.setCellStyle(cellStyleDisclaimer);
Row row1=sheet.createRow(sheet.getLastRowNum()+2);
Cell cellDisclaimerContent1 = row1.createCell(0);
cellDisclaimerContent1.setCellValue("The information contained in this website is for information purposes only, and does not constitute, nor is it intended to constitute, the provision of financial product advice.");
Row row2=sheet.createRow(sheet.getLastRowNum()+1);
Cell cellDisclaimerContent2 = row2.createCell(0);
cellDisclaimerContent2.setCellValue("This website is intended to track the investor account summary information,investments and transaction in a partcular period of time. ");
}
開發者ID:sudheerj,項目名稱:primefaces-blueprints,代碼行數:39,
示例19: postProcessXLS
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
public void postProcessXLS(Object document) {
HSSFWorkbook wb = (HSSFWorkbook) document;
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow header = sheet.getRow(0);
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.GREEN.index);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
for(int i=0; i < header.getPhysicalNumberOfCells();i++) {
HSSFCell cell = header.getCell(i);
cell.setCellStyle(cellStyle);
}
Row row=sheet.createRow((short)sheet.getLastRowNum()+3);
Cell cellDisclaimer = row.createCell(0);
HSSFFont customFont= wb.createFont();
customFont.setFontHeightInPoints((short)10);
customFont.setFontName("Arial");
customFont.setColor(IndexedColors.BLACK.getIndex());
customFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
customFont.setItalic(true);
cellDisclaimer.setCellValue("Disclaimer");
HSSFCellStyle cellStyleDisclaimer = wb.createCellStyle();
cellStyleDisclaimer.setFont(customFont);
cellDisclaimer.setCellStyle(cellStyleDisclaimer);
Row row1=sheet.createRow(sheet.getLastRowNum()+2);
Cell cellDisclaimerContent1 = row1.createCell(0);
cellDisclaimerContent1.setCellValue("The information contained in this website is for information purposes only, and does not constitute, nor is it intended to constitute, the provision of financial product advice.");
Row row2=sheet.createRow(sheet.getLastRowNum()+1);
Cell cellDisclaimerContent2 = row2.createCell(0);
cellDisclaimerContent2.setCellValue("This website is intended to track the investor account summary information,investments and transaction in a partcular period of time. ");
}
開發者ID:sudheerj,項目名稱:primefaces-blueprints,代碼行數:36,
示例20: postProcessXLS
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
public void postProcessXLS(Object document) {
HSSFWorkbook wb = (HSSFWorkbook) document;
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow header = sheet.getRow(0);
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.GREEN.index);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
for (int i = 0; i < header.getPhysicalNumberOfCells(); i++) {
HSSFCell cell = header.getCell(i);
cell.setCellStyle(cellStyle);
}
Row row = sheet.createRow((short) sheet.getLastRowNum() + 3);
Cell cellDisclaimer = row.createCell(0);
HSSFFont customFont = wb.createFont();
customFont.setFontHeightInPoints((short) 10);
customFont.setFontName("Arial");
customFont.setColor(IndexedColors.BLACK.getIndex());
customFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
customFont.setItalic(true);
cellDisclaimer.setCellValue("Disclaimer");
HSSFCellStyle cellStyleDisclaimer = wb.createCellStyle();
cellStyleDisclaimer.setFont(customFont);
cellDisclaimer.setCellStyle(cellStyleDisclaimer);
Row row1 = sheet.createRow(sheet.getLastRowNum() + 2);
Cell cellDisclaimerContent1 = row1.createCell(0);
cellDisclaimerContent1
.setCellValue("The information contained in this website is for information purposes only, and does not constitute, nor is it intended to constitute, the provision of financial product advice.");
Row row2 = sheet.createRow(sheet.getLastRowNum() + 1);
Cell cellDisclaimerContent2 = row2.createCell(0);
cellDisclaimerContent2
.setCellValue("This website is intended to track the investor account summary information,investments and transaction in a partcular period of time. ");
}
開發者ID:sudheerj,項目名稱:primefaces-blueprints,代碼行數:41,
示例21: createHeaderStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Templated method that is called for all header cells.
* @param wb
* @param headerCell
* @return
*/
public HSSFCellStyle createHeaderStyle(HSSFWorkbook wb, HeaderCell headerCell)
{
HSSFCellStyle headerStyle = getNewCellStyle();
headerStyle.setFillPattern(CellStyle.FINE_DOTS);
headerStyle.setFillBackgroundColor(HSSFColor.BLUE_GREY.index);
HSSFFont bold = wb.createFont();
bold.setBoldweight(Font.BOLDWEIGHT_BOLD);
bold.setColor(HSSFColor.WHITE.index);
headerStyle.setFont(bold);
return headerStyle;
}
開發者ID:webbfontaine,項目名稱:displaytag,代碼行數:20,
示例22: getHeadlineCellStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
protected HSSFCellStyle getHeadlineCellStyle(final HSSFSheet sheet) {
HSSFWorkbook workbook = sheet.getWorkbook();
HSSFCellStyle headlineCellStyle = workbook.createCellStyle();
HSSFFont font = workbook.createFont();
font.setColor(HSSFFont.COLOR_NORMAL);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
headlineCellStyle.setFont(font);
return headlineCellStyle;
}
開發者ID:Clemens85,項目名稱:runningdinner,代碼行數:10,
示例23: outputSummarySheet
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Output advance sample summary report, representing,
* bodyAdvancedSampleSearchResult.jsp
*
* @param searchBean
* @param wb
*/
private static void outputSummarySheet(AdvancedSampleSearchBean searchBean,
List sampleBeans, String viewSampleUrl,
HSSFWorkbook wb) throws IOException {
HSSFFont headerFont = wb.createFont();
headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
HSSFCellStyle headerStyle = wb.createCellStyle();
headerStyle.setFont(headerFont);
HSSFCellStyle hlinkStyle = wb.createCellStyle();
HSSFFont hlinkFont = wb.createFont();
hlinkFont.setUnderline(HSSFFont.U_SINGLE);
hlinkFont.setColor(HSSFColor.BLUE.index);
hlinkStyle.setFont(hlinkFont);
int rowIndex = 0;
HSSFSheet sheet = wb.createSheet("Advanced Sample Search Report");
// 1.Output Search Criteria. comment out as per Sharon.
// rowIndex = outputCriteria(searchBean, sheet, headerStyle, rowIndex);
// 2.Output table column headers.
rowIndex = outputHeader(sampleBeans.get(0), sheet, headerStyle,
rowIndex);
// 3.Output each table row.
for (AdvancedSampleBean sampleBean : sampleBeans) {
rowIndex = outputRow(sampleBean, viewSampleUrl, sheet, hlinkStyle,
rowIndex);
}
}
開發者ID:NCIP,項目名稱:cananolab,代碼行數:38,
示例24: outputSummarySheet
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Output sample Composition Summary report =>
* bodyCompositionSummaryView.jsp
*
* @param compBean
* @param wb
*/
private static void outputSummarySheet(CompositionBean compBean,
String downloadURL, HSSFWorkbook wb) throws IOException {
HSSFFont headerFont = wb.createFont();
headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
HSSFCellStyle headerStyle = wb.createCellStyle();
headerStyle.setFont(headerFont);
HSSFCellStyle hlinkStyle = wb.createCellStyle();
HSSFFont hlinkFont = wb.createFont();
hlinkFont.setUnderline(HSSFFont.U_SINGLE);
hlinkFont.setColor(HSSFColor.BLUE.index);
hlinkStyle.setFont(hlinkFont);
int entityCount = 1;
entityCount = outputNanomaterialEntities(compBean, wb, headerStyle,
hlinkStyle, entityCount, downloadURL);
entityCount = outputFunctionalEntities(compBean, wb, headerStyle,
hlinkStyle, entityCount, downloadURL);
entityCount = outputChemicalEntities(compBean, wb, headerStyle,
hlinkStyle, entityCount, downloadURL);
outputFilesEntities(compBean, wb, headerStyle, hlinkStyle, entityCount,
downloadURL);
}
開發者ID:NCIP,項目名稱:cananolab,代碼行數:34,
示例25: setTitleStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setTitleStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 10);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
titleStyle = style;
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:11,
示例26: setStringStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setStringStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
stringStyle = style;
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:10,
示例27: setDoubleStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setDoubleStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
style.setDataFormat(wb.createDataFormat().getFormat("#,##0.00"));
doubleStyle = style;
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:11,
示例28: setIntegerStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setIntegerStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setDataFormat(wb.createDataFormat().getFormat("0"));
integerStyle = style;
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:11,
示例29: setLabelStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setLabelStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
labelStyle = style;
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:11,
示例30: setValueStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setValueStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.BLACK.index);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
style.setWrapText(true);
valueStyle = style;
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:11,
示例31: setRedValueStyle
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setRedValueStyle(HSSFWorkbook wb) {
HSSFCellStyle style = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setColor(HSSFColor.RED.index);
font.setFontHeightInPoints((short) 8);
style.setFont(font);
style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
style.setWrapText(true);
redValueStyle = style;
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:11,
示例32: createHSSFCellStyles
點讚 3
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private Map createHSSFCellStyles(Workbook wb, int[] contextBgColor, int[] contextFontColor, int contextFontSize, int contextFontAlign, int[] headerBgColor,
int[] headerFontColor, int headerFontSize, int headerAlign) {
Map styles = new HashMap();
HSSFWorkbook workbook = (HSSFWorkbook) wb;
HSSFPalette palette = workbook.getCustomPalette();
palette.setColorAtIndex((short) 11, (byte) contextBgColor[0], (byte) contextBgColor[1], (byte) contextBgColor[2]);
palette.setColorAtIndex((short) 12, (byte) contextFontColor[0], (byte) contextFontColor[1], (byte) contextFontColor[2]);
palette.setColorAtIndex((short) 13, (byte) headerBgColor[0], (byte) headerBgColor[1], (byte) headerBgColor[2]);
palette.setColorAtIndex((short) 14, (byte) headerFontColor[0], (byte) headerFontColor[1], (byte) headerFontColor[2]);
HSSFFont headerFont = workbook.createFont();
headerFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
headerFont.setFontName("宋體");
headerFont.setColor((short) 14);
headerFont.setBold(true);
headerFont.setFontHeightInPoints((short) headerFontSize);
CellStyle headerStyle = this.createBorderCellStyle(workbook, true);
headerStyle.setFont(headerFont);
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
headerStyle.setFillForegroundColor((short) 13);
this.setCellStyleAligment(headerStyle, headerAlign);
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
styles.put(GridStyleType.headerStyle.name(), headerStyle);
HSSFFont dataFont = workbook.createFont();
dataFont.setColor((short) 12);
dataFont.setFontHeightInPoints((short) contextFontSize);
dataFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
dataFont.setFontName("宋體");
CellStyle dataAlignLeftStyle = this.createBorderCellStyle(workbook, true);
dataAlignLeftStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dataAlignLeftStyle.setFillForegroundColor((short) 11);
dataAlignLeftStyle.setFont(dataFont);
dataAlignLeftStyle.setVerticalAlignment(VerticalAlignment.CENTER);
dataAlignLeftStyle.setWrapText(true);
dataAlignLeftStyle.setAlignment(HorizontalAlignment.LEFT);
styles.put(GridStyleType.dataAlignLeftStyle.name(), dataAlignLeftStyle);
CellStyle dataAlignCenterStyle = this.createBorderCellStyle(workbook, true);
dataAlignCenterStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dataAlignCenterStyle.setFillForegroundColor((short) 11);
dataAlignCenterStyle.setFont(dataFont);
dataAlignCenterStyle.setVerticalAlignment(VerticalAlignment.CENTER);
dataAlignCenterStyle.setWrapText(true);
dataAlignCenterStyle.setAlignment(HorizontalAlignment.CENTER);
styles.put(GridStyleType.dataAlignCenterStyle.name(), dataAlignCenterStyle);
CellStyle dataAlignRightStyle = this.createBorderCellStyle(workbook, true);
dataAlignRightStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dataAlignRightStyle.setFillForegroundColor((short) 11);
dataAlignRightStyle.setFont(dataFont);
dataAlignRightStyle.setVerticalAlignment(VerticalAlignment.CENTER);
dataAlignRightStyle.setWrapText(true);
dataAlignRightStyle.setAlignment(HorizontalAlignment.RIGHT);
styles.put(GridStyleType.dataAlignRightStyle.name(), dataAlignRightStyle);
CellStyle dateStyle = this.createBorderCellStyle(workbook, true);
CreationHelper helper = workbook.getCreationHelper();
dateStyle.setDataFormat(helper.createDataFormat().getFormat("m/d/yy h:mm"));
dateStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
dateStyle.setFillForegroundColor((short) 11);
dateStyle.setFont(dataFont);
dateStyle.setVerticalAlignment(VerticalAlignment.CENTER);
this.setCellStyleAligment(dateStyle, contextFontAlign);
styles.put(GridStyleType.dateStyle.name(), dateStyle);
return styles;
}
開發者ID:bsteker,項目名稱:bdf2,代碼行數:72,
示例33: setIndexMatrixColor
點讚 2
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setIndexMatrixColor(final HSSFWorkbook workbook, final HSSFCellStyle indexStyle) {
indexStyle.setFillForegroundColor(HSSFColor.WHITE.index);
final HSSFFont font = workbook.getFontAt(indexStyle.getFontIndex());
font.setColor(HSSFColor.BLACK.index);
}
開發者ID:roundrop,項目名稱:ermasterr,代碼行數:6,
示例34: setIndexMatrixColor
點讚 2
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void setIndexMatrixColor(HSSFWorkbook workbook,
HSSFCellStyle indexStyle) {
indexStyle.setFillForegroundColor(HSSFColor.WHITE.index);
HSSFFont font = workbook.getFontAt(indexStyle.getFontIndex());
font.setColor(HSSFColor.BLACK.index);
}
開發者ID:kozake,項目名稱:ermaster-k,代碼行數:7,
示例35: initializeComponents
點讚 2
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Initialize components.
*/
public final void initializeComponents() {
HSSFFont fontHeading1;
HSSFFont fontHeading2;
HSSFFont fontHeading3;
HSSFFont greenFont;
HSSFFont yellowFont;
heading1Cs = wb.createCellStyle();
heading2Cs = wb.createCellStyle();
heading3Cs = wb.createCellStyle();
equalCs = wb.createCellStyle();
notEqualCs = wb.createCellStyle();
greenCs = wb.createCellStyle();
yellowCs = wb.createCellStyle();
fontHeading1 = wb.createFont();
fontHeading2 = wb.createFont();
fontHeading3 = wb.createFont();
greenFont = wb.createFont();
yellowFont = wb.createFont();
fontHeading1.setFontHeightInPoints(H1_SIZE);
fontHeading1.setItalic(true);
fontHeading1.setBoldweight(Font.BOLDWEIGHT_BOLD);
fontHeading1.setColor(IndexedColors.DARK_BLUE.getIndex());
heading1Cs.setFont(fontHeading1);
fontHeading2.setFontHeightInPoints(H2_SIZE);
fontHeading2.setItalic(true);
heading2Cs.setFont(fontHeading2);
fontHeading3.setFontHeightInPoints(H3_SIZE);
fontHeading3.setBoldweight(Font.BOLDWEIGHT_BOLD);
heading3Cs.setFont(fontHeading3);
heading3Cs.setBorderBottom((short) 1);
equalCs.setFillForegroundColor(IndexedColors.GREEN.getIndex());
equalCs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
notEqualCs.setFillForegroundColor(IndexedColors.RED.getIndex());
notEqualCs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
greenFont.setColor(IndexedColors.GREEN.getIndex());
greenCs.setFont(greenFont);
yellowFont.setColor(IndexedColors.DARK_YELLOW.getIndex());
yellowCs.setFont(yellowFont);
}
開發者ID:jwiesel,項目名稱:sfdcCommander,代碼行數:52,
示例36: exportRowDatas
點讚 2
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* @Description: 將數據集的每一個數據項寫到excel的每一行
* @param dataset
* @param workbook
* @param sheet
*
* @History
* 1. 2014-12-19 linwb 創建方法
*/
@SuppressWarnings({"unchecked" })
private void exportRowDatas(List dataset, HSSFWorkbook workbook, HSSFSheet sheet, int maxRows) {
//生成數據單元格的字體
HSSFFont contFont = workbook.createFont();
contFont.setColor(cellFontColor);
//生成文本單元格內容的樣式
HSSFCellStyle cellStyle = generateContStyle(workbook);
HSSFRow row;
//遍曆集合數據,產生數據行
Iterator it = dataset.iterator();
int index = maxRows;
boolean isErrorRow = false;
while (it.hasNext()) {
row = sheet.createRow(index++);
T rowData = (T) it.next();
isErrorRow = false;
//根據JavaBean屬性的先後順序,動態調用getXxx()方法得到屬性值
Field[] fields = rowData.getClass().getDeclaredFields();
for (int i = 0,colIndex=i, length=fields.length; i < length; i++) {
Field field = fields[i];
if(!isExcelExport(field.getAnnotations())){
continue ;
}
HSSFCell cell = row.createCell(colIndex++);
cell.setCellStyle(cellStyle);
String fieldName = field.getName();
String getMethodName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
try {
Class tCls = rowData.getClass();
Method getMethod = tCls.getMethod(getMethodName, new Class[] {});
getMethod.setAccessible(true);
Object value = getMethod.invoke(rowData, new Object[] {});
if(value == null){
value = "";
}
//類型轉換處理
String textValue = null;
if (value instanceof Date) {
Date date = (Date) value;
ExcelHeader excelHeader = headerMap.get(""+(colIndex-1));//因為colIndex第幾列已經增加過1了,所以此處減1獲取正確的列
SimpleDateFormat sdf = new SimpleDateFormat(excelHeader.getDatePattern());
textValue = sdf.format(date);
} else {
//其它數據類型都當作字符串簡單處理
textValue = value.toString();
//指定部分字體的顏色?
}
HSSFRichTextString richText = new HSSFRichTextString(textValue);
richText.applyFont(contFont);
cell.setCellValue(richText);
} catch (Exception e) {
e.printStackTrace();
logger.error("寫入excel表格時出錯", e);
isErrorRow = true;
break;
} finally {
//清理資源
}
}
if(isErrorRow){
errorDatas.add(rowData);
}
}
}
開發者ID:webinglin,項目名稱:excelExportor,代碼行數:82,
示例37: exportExcel
點讚 2
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
public InputStream exportExcel(String fileName, String[] headTitle,
List list) throws IOException {
Workbook wb = new HSSFWorkbook();
//FileOutputStream fileOut = new FileOutputStream(fileName);
HSSFCellStyle style = (HSSFCellStyle) wb.createCellStyle();
// 設置這些樣式
style.setFillForegroundColor(HSSFColor.SKY_BLUE.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
// 生成一個字體
HSSFFont font = (HSSFFont) wb.createFont();
font.setColor(HSSFColor.VIOLET.index);
font.setFontHeightInPoints((short) 12);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// 把字體應用到當前的樣式
style.setFont(font);
// 創建工作簿
Sheet sheet = wb.createSheet("sheet1");
// sheet.setDefaultColumnWidth((short)15);
// 創建頭部
Row row = sheet.createRow((short) 0);
for (int i = 0; i < headTitle.length; i++) {
row.createCell(i).setCellValue(headTitle[i]);
}
// 填充數據
for (int i = 0; i < list.size(); i++) {
Row r = sheet.createRow((short) (i + 1));
String[] strArray = list.get(i).split(",");
for (int j = 0; j < headTitle.length; j++) {
r.createCell(j).setCellValue(strArray[j]);
if (strArray[j].length()>3) {
sheet.setColumnWidth((short)j, 5000);
}
}
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
wb.write(baos);
} catch (IOException e) {
e.printStackTrace();
}
byte[] ba = baos.toByteArray();
ByteArrayInputStream excelStream = new ByteArrayInputStream(ba);
return excelStream;
}
開發者ID:dreajay,項目名稱:hrms,代碼行數:57,
示例38: apply
點讚 2
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public void apply(HSSFCell cell, HSSFCellStyle cellStyle, Map style) {
HSSFWorkbook workBook = cell.getSheet().getWorkbook();
HSSFFont font = null;
if (ITALIC.equals(style.get(FONT_STYLE))) {
font = getFont(cell, font);
font.setItalic(true);
}
int fontSize = CssUtils.getInt(style.get(FONT_SIZE));
if (fontSize > 0) {
font = getFont(cell, font);
font.setFontHeightInPoints((short) fontSize);
}
if (BOLD.equals(style.get(FONT_WEIGHT))) {
font = getFont(cell, font);
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
}
String fontFamily = style.get(FONT_FAMILY);
if (StringUtils.isNotBlank(fontFamily)) {
font = getFont(cell, font);
font.setFontName(fontFamily);
}
HSSFColor color = CssUtils.parseColor(workBook, style.get(COLOR));
if (color != null) {
if (color.getIndex() != BLACK.index) {
font = getFont(cell, font);
font.setColor(color.getIndex());
}
else {
log.info("Text Color [{}] Is Black Or Fimiliar To Black, Ignore.",
style.remove(COLOR));
}
}
// text-decoration
String textDecoration = style.get(TEXT_DECORATION);
if (UNDERLINE.equals(textDecoration)) {
font = getFont(cell, font);
font.setUnderline(Font.U_SINGLE);
}
if (font != null) {
cellStyle.setFont(font);
}
}
開發者ID:chyxion,項目名稱:table-to-xls,代碼行數:47,
示例39: outputSummarySheet
點讚 2
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
/**
* Output Sample Characterization Summary report (==>
* bodyCharacterizationSummaryPrintViewTable.jsp)
*
* @param summaryBean
* @param wb
* @throws IOException
*/
private static void outputSummarySheet(List charTypes,
CharacterizationSummaryViewBean summaryBean, String downloadURL,
HSSFWorkbook wb) throws IOException {
HSSFFont headerFont = wb.createFont();
headerFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
HSSFCellStyle headerStyle = wb.createCellStyle();
headerStyle.setFont(headerFont);
HSSFCellStyle hlinkStyle = wb.createCellStyle();
HSSFFont hlinkFont = wb.createFont();
hlinkFont.setUnderline(HSSFFont.U_SINGLE);
hlinkFont.setColor(HSSFColor.BLUE.index);
hlinkStyle.setFont(hlinkFont);
int charCount = 1;
Map> charBeanMap = summaryBean
.getType2Characterizations();
for (String type : charTypes) {
// Output data of report
SortedSet charBeans = charBeanMap.get(type);
if (charBeans != null && !charBeans.isEmpty()) {
for (CharacterizationBean charBean : charBeans) {
int rowIndex = 0;
// Create one work sheet for each Characterization.
HSSFSheet sheet = wb.createSheet(charCount++ + "."
+ charBean.getCharacterizationName());
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
// 1. Output Characterization type at (0, 0).
rowIndex = outputHeader(charBean, sheet, headerStyle,
rowIndex);
// 2. Output Assay Type (2, 0).
rowIndex = outputAssayType(charBean, sheet, headerStyle,
rowIndex);
// 3. Output POC at (3, 0).
rowIndex = outputPOC(charBean, sheet, headerStyle, rowIndex);
// 4. Output Characterization Date at (4, 0).
rowIndex = outputCharDate(charBean, sheet, headerStyle,
rowIndex);
// 5. Output Protocol at (5, 0).
rowIndex = outputProtocol(charBean, sheet, headerStyle,
rowIndex);
// 6. Output Properties at (6, 0).
rowIndex = outputProperties(charBean, sheet, headerStyle,
rowIndex);
// 7. Output Design Description at (7, 0).
rowIndex = outputDesignDescription(charBean, sheet,
headerStyle, rowIndex);
// 8. Output Technique and Instruments at (8, 0).
rowIndex = outputTechInstruments(charBean, sheet,
headerStyle, rowIndex);
// 9. Output Characterization Results at (9, 0).
rowIndex = outputCharResults(charBean, downloadURL, wb,
sheet, headerStyle, hlinkStyle, patriarch, rowIndex);
// 10.Output Analysis and Conclusion at (10, 0).
rowIndex = outputConclusion(charBean, sheet, headerStyle,
rowIndex);
}
}
}
}
開發者ID:NCIP,項目名稱:cananolab,代碼行數:71,
示例40: appendToStyle
點讚 2
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
@Override
protected void appendToStyle(HSSFWorkbook book, HSSFCellStyle style, HSSFFont font) {
font.setColor(color.getIndex());
}
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:5,
示例41: buildHeader
點讚 1
import org.apache.poi.hssf.usermodel.HSSFFont; //導入方法依賴的package包/類
private void buildHeader(HSSFWorkbook workbook, HSSFSheet sheet, HSSFCellStyle style, HSSFCellStyle style2,HSSFPatriarch patriarch,String title,String[] headers){
// 設置這些樣式
style.setFillForegroundColor(HSSFColor.SKY_BLUE.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
// 生成一個字體
HSSFFont font = workbook.createFont();
font.setColor(HSSFColor.VIOLET.index);
font.setFontHeightInPoints((short) 12);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// 把字體應用到當前的樣式
style.setFont(font);
// 生成並設置另一個樣式
style2 = workbook.createCellStyle();
style2.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style2.setBorderRight(HSSFCellStyle.BORDER_THIN);
style2.setBorderTop(HSSFCellStyle.BORDER_THIN);
style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
// 生成另一個字體
HSSFFont font2 = workbook.createFont();
font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
// 把字體應用到當前的樣式
style2.setFont(font2);
// 定義注釋的大小和位置,詳見文檔
HSSFComment comment = patriarch.createComment(new HSSFClientAnchor(0,
0, 0, 0, (short) 4, 2, (short) 6, 5));
// 設置注釋內容
comment.setString(new HSSFRichTextString("可以在POI中添加注釋!"));
// 設置注釋作者,當鼠標移動到單元格上是可以在狀態欄中看到該內容.
comment.setAuthor("leno");
// 產生表格標題行
HSSFRow row = sheet.createRow(0);
for (short i = 0; i < headers.length; i++) {
HSSFCell cell = row.createCell(i);
cell.setCellStyle(style);
HSSFRichTextString text = new HSSFRichTextString(headers[i]);
cell.setCellValue(headers[i]);
}
}
開發者ID:zhanggh,項目名稱:mtools,代碼行數:52,
注:本文中的org.apache.poi.hssf.usermodel.HSSFFont.setColor方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。