本文整理汇总了Java中jxl.write.Label类的典型用法代码示例。如果您正苦于以下问题:Java Label类的具体用法?Java Label怎么用?Java Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Label类属于jxl.write包,在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setExcelListTitle
import jxl.write.Label; //导入依赖的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: readExcel
import jxl.write.Label; //导入依赖的package包/类
public static void readExcel(String inputfileName, String outputfileName) throws BiffException, IOException , RowsExceededException, WriteException{
Workbook wb=Workbook.getWorkbook(new File(inputfileName));
Sheet sheet = wb.getSheet(0); //get sheet(0)
WritableWorkbook wwb = Workbook.createWorkbook(new File(outputfileName));
WritableSheet ws = wwb.createSheet("topicName", 0);
//traversal
for(int i=0; i<sheet.getRows(); i++)
{
String content = sheet.getCell(0,i).getContents();
String[] words = content.split("\\(");
content = words[0];
content = content.toLowerCase();
content = content.replaceAll("_", " ");
content = content.replaceAll("-", " ");
content = content.replaceAll("\\s+", " ");
if(content.contains("data structure") && !content.trim().equals("data structure"))
content = content.replaceAll("data structure", "");
Label labelC = new Label(0, i, content.trim());
ws.addCell(labelC);
}
wwb.write();
wwb.close();
}
示例3: ExportTLDToXLS
import jxl.write.Label; //导入依赖的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);
}
}
示例4: ExportCertToXLS
import jxl.write.Label; //导入依赖的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);
}
}
示例5: setReportTitle
import jxl.write.Label; //导入依赖的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();
}
}
示例6: setExcelListTitle
import jxl.write.Label; //导入依赖的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();
}
}
示例7: addColumnName
import jxl.write.Label; //导入依赖的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);
}
}
示例8: addMultipleLabelsWrap
import jxl.write.Label; //导入依赖的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));
}
}
示例9: getContentLabel
import jxl.write.Label; //导入依赖的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;
}
示例10: toWritableCell
import jxl.write.Label; //导入依赖的package包/类
/**
* Create a WritableCell (DateTime or Label for the given value
* @param aColumnNumber the column number
* @param aRowNumber the row number
* @param aValue the value
* @return the format excel cell
*/
private static WritableCell toWritableCell(int aColumnNumber, int aRowNumber, Object aValue)
{
if(aValue == null)
{
return new Label(aColumnNumber,aRowNumber,"");
}
else if(aValue instanceof Date)
{
return new DateTime(aColumnNumber,aRowNumber,(Date)aValue);
}
else if (aValue instanceof Cell)
{
return new Label(aColumnNumber,aRowNumber,((Cell)aValue).getContents());
}
else
{
return new Label(aColumnNumber,aRowNumber,aValue.toString());
}
}
示例11: writeList
import jxl.write.Label; //导入依赖的package包/类
public void writeList(String[] data) throws FileNotFoundException,
IOException,
WriteException {
//Blank workbook
WritableWorkbook workbook = Workbook.createWorkbook(excelFile);
//Create a blank sheet
WritableSheet sheet = workbook.createSheet("defaut sheet", 0);
//Iterate over data and write to sheet
int rownum = 0;
for (String str : data) {
// create a colum cell
Label label0 = new Label(0, rownum, Paths.get(str).getFileName().toString());
sheet.addCell(label0);
Label label1 = new Label(1, rownum, str);
sheet.addCell(label1);
}
//Write the workbook in file system
workbook.write();
// close the file
workbook.close();
}
示例12: addCell
import jxl.write.Label; //导入依赖的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++;
// }
}
}
}
示例13: writeCell
import jxl.write.Label; //导入依赖的package包/类
/**
* @param columnPosition - column to place new cell in
* @param rowPosition - row to place new cell in
* @param contents - string value to place in cell
* @param headerCell - whether to give this cell special formatting
* @param sheet - WritableSheet to place cell in
* @throws RowsExceededException - thrown if adding cell exceeds .xls row limit
* @throws WriteException - Idunno, might be thrown
*/
public void writeCell(int columnPosition, int rowPosition, String contents, boolean headerCell,
WritableSheet sheet) throws RowsExceededException, WriteException{
//create a new cell with contents at position
Label newCell = new Label(columnPosition,rowPosition,contents);
if (headerCell){
//give header cells size 10 Arial bolded
WritableFont headerFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD);
WritableCellFormat headerFormat = new WritableCellFormat(headerFont);
//center align the cells' contents
headerFormat.setAlignment(Alignment.CENTRE);
newCell.setCellFormat(headerFormat);
}
sheet.addCell(newCell);
}
示例14: addValue
import jxl.write.Label; //导入依赖的package包/类
/**
* 新增一个数据
*/
static WritableSheet addValue(HashMap modelData,int startRow,int rangeMuch,WritableSheet doSheet,int strnum){
for(int r=startRow;r<startRow+rangeMuch;r++){
Cell[] cells=doSheet.getRow(r);
for(int c=0;c<cells.length;c++){
WritableCell cell = doSheet.getWritableCell(c,r);
if(cell.getType()==CellType.EMPTY)continue;
Label lb = (Label) cell;
String signal=cell.getContents();
if(signal.equals(ROW_NUM)){
lb.setString(strnum+"");continue;
}
if(signal.length()>2) //去掉前后的 % 号
signal=signal.substring(1,signal.length()-1);
if(modelData.containsKey(signal)){
signal=(modelData.get(signal)==null?"":modelData.get(signal).toString());
}else signal=cell.getContents();
lb.setString(signal);
}
}
return doSheet;
}
示例15: ExportForwardLookupsToXLS
import jxl.write.Label; //导入依赖的package包/类
public static void ExportForwardLookupsToXLS(String filename, List<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("Forward lookups", 0);
sheet.addCell(new Label(0, 0, "Domain name", titleformat));
sheet.addCell(new Label(1, 0, "Host name", titleformat));
sheet.addCell(new Label(2, 0, "IP address", titleformat));
sheet.addCell(new Label(3, 0, "Type", titleformat));
int nextRow = 1;
Iterator i = data.iterator();
while (i.hasNext()) {
ForwardLookupResult res = (ForwardLookupResult) i.next();
sheet.addCell(new Label(0, nextRow, res.getDomainName()));
sheet.addCell(new Label(1, nextRow, res.getHostName()));
sheet.addCell(new Label(2, nextRow, res.getIpAddress()));
sheet.addCell(new Label(3, nextRow, res.getLookupType()));
nextRow++;
}
workbook.write();
workbook.close();
} catch (WriteException ex) {
Logger.getLogger("resultExport.ExportForwardLookupsToXLS").log(Level.SEVERE, null, ex);
}
}