本文整理匯總了Java中jxl.write.WritableCellFormat類的典型用法代碼示例。如果您正苦於以下問題:Java WritableCellFormat類的具體用法?Java WritableCellFormat怎麽用?Java WritableCellFormat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WritableCellFormat類屬於jxl.write包,在下文中一共展示了WritableCellFormat類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setExcelListTitle
import jxl.write.WritableCellFormat; //導入依賴的package包/類
/**
* 設置報表內容頭
*
* @param listTitle
* 報表頭
* @throws IOException
* @throws WriteException
*/
@Deprecated
public void setExcelListTitle(String[] listTitle) throws WriteException, IOException {
try {
irow++;
long start = System.currentTimeMillis();
wfont = new WritableFont(WritableFont.createFont("宋體"), 10, WritableFont.BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
wcfFC = new WritableCellFormat(wfont);
wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM);
wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
for (int i = icol; i < listTitle.length; i++) {
wsheet.addCell(new Label(i, irow, listTitle[i], wcfFC));
}
trow = irow;
logger.info("title use time:" + (System.currentTimeMillis() - start));
} catch (Exception e) {
this.close();
}
}
示例2: ExportTLDToXLS
import jxl.write.WritableCellFormat; //導入依賴的package包/類
public static void ExportTLDToXLS(String filename, ArrayList<Object> data) throws IOException {
try {
WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, true);
WritableCellFormat titleformat = new WritableCellFormat(titleFont);
WritableWorkbook workbook = Workbook.createWorkbook(new File(filename));
WritableSheet sheet = workbook.createSheet("TLD Expand", 0);
sheet.addCell(new Label(0, 0, "Domain name", titleformat));
sheet.addCell(new Label(1, 0, "Name server", titleformat));
sheet.addCell(new Label(2, 0, "Admin name", titleformat));
sheet.addCell(new Label(3, 0, "Registrant", titleformat));
int nextRow = 1;
Iterator i = data.iterator();
while (i.hasNext()) {
DomainResult res = (DomainResult) i.next();
sheet.addCell(new Label(0, nextRow, res.getDomainName()));
sheet.addCell(new Label(1, nextRow, res.getNameServer()));
sheet.addCell(new Label(2, nextRow, res.getAdminName()));
sheet.addCell(new Label(3, nextRow, res.getRegistrant()));
nextRow++;
}
workbook.write();
workbook.close();
} catch (WriteException ex) {
Logger.getLogger("resultExport.ExportForwardLookupsToXLS").log(Level.SEVERE, null, ex);
}
}
示例3: ExportCertToXLS
import jxl.write.WritableCellFormat; //導入依賴的package包/類
public static void ExportCertToXLS(String filename, ArrayList<Object> data) throws IOException {
try {
WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, true);
WritableCellFormat titleformat = new WritableCellFormat(titleFont);
WritableWorkbook workbook = Workbook.createWorkbook(new File(filename));
WritableSheet sheet = workbook.createSheet("SSLCert CN", 0);
sheet.addCell(new Label(0, 0, "IP address", titleformat));
sheet.addCell(new Label(1, 0, "Host name", titleformat));
sheet.addCell(new Label(2, 0, "Domain name", titleformat));
int nextRow = 1;
Iterator i = data.iterator();
while (i.hasNext()) {
CertResult res = (CertResult) i.next();
sheet.addCell(new Label(0, nextRow, res.getIpAddress()));
sheet.addCell(new Label(1, nextRow, res.getHostName()));
sheet.addCell(new Label(2, nextRow, res.getDomainName()));
nextRow++;
}
workbook.write();
workbook.close();
} catch (WriteException ex) {
Logger.getLogger("resultExport.ExportForwardLookupsToXLS").log(Level.SEVERE, null, ex);
}
}
示例4: setReportTitle
import jxl.write.WritableCellFormat; //導入依賴的package包/類
/**
* 設置報表標題
*
* @param reportTitle
* 報表標題
* @throws IOException
* @throws WriteException
* @throws WriteException
*/
public void setReportTitle(String reportTitle) throws WriteException, IOException {
try {
irow++;
wfont = new WritableFont(WritableFont.createFont("宋體"), 12, WritableFont.BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
wcfFC = new WritableCellFormat(wfont);
wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
// wcfFC.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW);// 背景色
wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
// wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM,
// Colour.BLACK);//
// 邊框
wsheet.addCell(new Label(icol, irow, reportTitle, wcfFC));
trow = irow;
} catch (Exception e) {
this.close();
}
}
示例5: setExcelListTitle
import jxl.write.WritableCellFormat; //導入依賴的package包/類
/**
* 設置報表內容頭
*
* @param listTitle
* 報表頭
* @throws IOException
* @throws WriteException
*/
@Deprecated
public void setExcelListTitle(String[] listTitle) throws WriteException, IOException {
try {
irow++;
long start = System.currentTimeMillis();
wfont = new WritableFont(WritableFont.createFont("宋體"), 10, WritableFont.BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
wcfFC = new WritableCellFormat(wfont);
wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM);
wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
for (int i = icol; i < listTitle.length; i++) {
wsheet.addCell(new Label(i, irow, listTitle[i], wcfFC));
}
trow = irow;
log.info("title use time:" + (System.currentTimeMillis() - start));
} catch (Exception e) {
this.close();
}
}
示例6: format
import jxl.write.WritableCellFormat; //導入依賴的package包/類
/**
* 單元格的格式設置 字體大小 顏色 對齊方式、背景顏色等...
*/
public static void format() {
try {
arial14font = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD);
arial14font.setColour(jxl.format.Colour.LIGHT_BLUE);
arial14format = new WritableCellFormat(arial14font);
arial14format.setAlignment(jxl.format.Alignment.CENTRE);
arial14format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
arial14format.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW);
arial10font = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD);
arial10format = new WritableCellFormat(arial10font);
arial10format.setAlignment(jxl.format.Alignment.CENTRE);
arial10format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
arial10format.setBackground(Colour.GRAY_25);
arial12font = new WritableFont(WritableFont.ARIAL, 10);
arial12format = new WritableCellFormat(arial12font);
arial10format.setAlignment(jxl.format.Alignment.CENTRE);//對齊格式
arial12format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN); //設置邊框
} catch (WriteException e) {
e.printStackTrace();
}
}
示例7: format
import jxl.write.WritableCellFormat; //導入依賴的package包/類
public static void format() {
try {
arial14font = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD);
arial14font.setColour(jxl.format.Colour.LIGHT_BLUE);
arial14format = new WritableCellFormat(arial14font);
arial14format.setAlignment(jxl.format.Alignment.CENTRE);
arial14format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
arial14format.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW);
arial10font = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD);
arial10format = new WritableCellFormat(arial10font);
arial10format.setAlignment(jxl.format.Alignment.CENTRE);
arial10format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
arial10format.setBackground(jxl.format.Colour.LIGHT_BLUE);
arial12font = new WritableFont(WritableFont.ARIAL, 12);
arial12format = new WritableCellFormat(arial12font);
arial12format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
} catch (WriteException e) {
e.printStackTrace();
}
}
示例8: writeFieldRow
import jxl.write.WritableCellFormat; //導入依賴的package包/類
private void writeFieldRow(WritableSheet spreadSheet, HashMap<String, Object> fieldRow, int maxIndexedColumnIndex, int r, ExcelCellFormat f,
HashMap<String, WritableCellFormat> cellFormats) throws Exception {
if (fieldRow != null && distinctColumnNames != null && distinctColumnNames.size() > 0) {
int c = maxIndexedColumnIndex;
for (int d = 0; d < distinctColumnNames.size(); d++) {
String columnName = distinctColumnNames.get(d);
Object fieldValue = fieldRow.get(columnName);
Integer columnIndex = getColumnIndex(columnName);
if (columnIndex == null) {
c++;
columnIndex = c;
}
if (fieldValue != null) {
ExcelUtil.writeCell(spreadSheet, columnIndex.intValue(), r, fieldValue.getClass(), fieldValue, f, cellFormats);
} else {
ExcelUtil.writeCell(spreadSheet, columnIndex.intValue(), r, String.class, null, f, cellFormats);
}
}
}
}
示例9: getHeader
import jxl.write.WritableCellFormat; //導入依賴的package包/類
public static WritableCellFormat getHeader() {
WritableFont font = new WritableFont(WritableFont.TIMES, 10,
WritableFont.BOLD);// 定義字體
try {
font.setColour(Colour.BLUE);// 藍色字體
} catch (WriteException e1) {
e1.printStackTrace();
}
WritableCellFormat format = new WritableCellFormat(font);
try {
format.setAlignment(jxl.format.Alignment.CENTRE);// 左右居中
format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);// 上下居中
// format.setBorder(Border.ALL, BorderLineStyle.THIN,
// Colour.BLACK);// 黑色邊框
// format.setBackground(Colour.YELLOW);// 黃色背景
} catch (WriteException e) {
e.printStackTrace();
}
return format;
}
示例10: addColumnName
import jxl.write.WritableCellFormat; //導入依賴的package包/類
public void addColumnName(String... columnNames) throws WriteException {
int columnCount = this.sheet.getColumns();
// System.err.println("columnCount:" + columnCount);
for (int i = 0; i < columnNames.length; i++) {
// 通過函數WritableFont()設置字體樣式
// 第一個參數表示所選字體
// 第二個參數表示字體大小
// 第三個參數表示粗體樣式,有BOLD和NORMAL兩種樣式
// 第四個參數表示是否斜體,此處true表示為斜體
// 第五個參數表示下劃線樣式
// 第六個參數表示顏色樣式,此處為Red
WritableFont wf = new WritableFont(WritableFont.TIMES, 11, WritableFont.BOLD);
CellFormat cf = new WritableCellFormat(wf);
Label label = new Label(i + columnCount, 0, columnNames[i], cf);
sheet.addCell(label);
}
}
示例11: addMultipleLabelsWrap
import jxl.write.WritableCellFormat; //導入依賴的package包/類
private void addMultipleLabelsWrap(WritableSheet sheet, int col, int row, String s[], WritableCellFormat format) throws RowsExceededException, WriteException {
if (sheet==null || s==null)
return;
if (s.length==0)
return;
if (s.length==1)
sheet.addCell(new Label(col,row,s[0],format));
else {
String result = s[0];
for (int i=1; i<s.length; i++)
//result = result + ", " + s[i];
result = result + "\n" + s[i];
sheet.addCell(new Label(col,row,result,format));
}
}
示例12: addNumber
import jxl.write.WritableCellFormat; //導入依賴的package包/類
private void addNumber(WritableSheet sheet, int col, int row, String s[], int index, WritableCellFormat format) throws RowsExceededException, WriteException {
if (sheet==null || s==null)
return;
if (index>=s.length)
return;
double d;
try {
d = Double.parseDouble(s[index]);
// Only keep 2 digits: avoid rounding errors
d = 1d*(int)(d*100)/100;
sheet.addCell(new Number(col,row,d,format));
} catch (NumberFormatException nfe) {}
}
示例13: addNumberDiv1024
import jxl.write.WritableCellFormat; //導入依賴的package包/類
private void addNumberDiv1024(WritableSheet sheet, int col, int row, String s[], int index, WritableCellFormat format) throws RowsExceededException, WriteException {
if (sheet==null || s==null)
return;
if (index>=s.length)
return;
double d;
try {
d = Double.parseDouble(s[index]);
d = d / 1024;
// Only keep 2 digits: avoid rounding errors
d = 1d*(int)(d*100)/100;
sheet.addCell(new Number(col,row,d,format));
} catch (NumberFormatException nfe) {}
}
示例14: getContentLabel
import jxl.write.WritableCellFormat; //導入依賴的package包/類
/**
* 每個單元格的內容及格式
*
* @param col
* @param row
* @param field
* @param content
* @return
*/
protected Label getContentLabel(int col, int row, Field field, Object content) {
WritableCellFormat cellFormat = contentCenterFormat;
String contentStr = "";
contentStr = null != content ? content.toString() : "";
// 將數字轉變成千分位格式
String numberStr = getNumbericValue(contentStr);
// numberStr不為空,說明是數字類型。
if (null != numberStr && !numberStr.trim().equals("")) {
contentStr = numberStr;
// 數字要右對齊
cellFormat = contentRightFormat;
} else {
// 如果是時間類型。要格式化成標準時間格式
String timeStr = getTimeFormatValue(field, content);
// timeStr不為空,說明是時間類型
if (null != timeStr && !timeStr.trim().equals("")) {
contentStr = timeStr;
}
}
Label label = new Label(col, row, contentStr, cellFormat);
return label;
}
示例15: addCell
import jxl.write.WritableCellFormat; //導入依賴的package包/類
/**
* (導出)Excel內容填充(從第三行開始)
*
* @param Info
* @param ws
* @param format
* @param rowscount
* @throws Exception
*/
private void addCell(ExcelModel eModel, Object obj, WritableSheet ws,
WritableCellFormat format, int rowscount) throws Exception {
if (obj != null) {
int cols = 0;
ExcelColumn ec = null;
// List ecList =
// HibDb.queryHQL("from ExGroupCode ec where ec.status='A' and ec.exGroup.excel.code='"+code+"'");
int count = 0;
for (int i = 0; i < eModel.getEcList().size(); i++) {
ec = (ExcelColumn) eModel.getEcList().get(i);
// if(ec.getCols()>=0){
ws.addCell(new Label(i - count, rowscount, this.getValue(eModel, obj, ec.getCols(), ec.getCode()), format));
cols++;
// }
}
}
}