本文整理匯總了Java中jxl.write.Label.setString方法的典型用法代碼示例。如果您正苦於以下問題:Java Label.setString方法的具體用法?Java Label.setString怎麽用?Java Label.setString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jxl.write.Label
的用法示例。
在下文中一共展示了Label.setString方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: setFile
import jxl.write.Label; //導入方法依賴的package包/類
/**
* Sets the file activated by this hyperlink
*
* @param file the file
*/
public void setFile(File file)
{
linkType = fileLink;
url = null;
location = null;
contents = null;
this.file = file;
modified = true;
if (sheet == null)
{
// hyperlink has not been added to the sheet yet, so simply return
return;
}
// Change the label on the sheet
WritableCell wc = sheet.getWritableCell(firstColumn, firstRow);
Assert.verify(wc.getType() == CellType.LABEL);
Label l = (Label) wc;
l.setString(file.toString());
}
示例3: setURL
import jxl.write.Label; //導入方法依賴的package包/類
/**
* Sets the URL of this hyperlink
*
* @param url the url
*/
public void setURL(URL url)
{
URL prevurl = this.url;
linkType = urlLink;
file = null;
location = null;
contents = null;
this.url = url;
modified = true;
if (sheet == null)
{
// hyperlink has not been added to the sheet yet, so simply return
return;
}
// Change the label on the sheet if it was a string representation of the
// URL
WritableCell wc = sheet.getWritableCell(firstColumn, firstRow);
if (wc.getType() == CellType.LABEL)
{
Label l = (Label) wc;
String prevurlString = prevurl.toString();
String prevurlString2 = "";
if (prevurlString.charAt(prevurlString.length() - 1) == '/' ||
prevurlString.charAt(prevurlString.length() - 1) == '\\')
{
prevurlString2 = prevurlString.substring(0,
prevurlString.length() - 1);
}
if (l.getString().equals(prevurlString) ||
l.getString().equals(prevurlString2))
{
l.setString(url.toString());
}
}
}
示例4: setLocation
import jxl.write.Label; //導入方法依賴的package包/類
/**
* Sets the location of the cells to be linked to within this workbook
*
* @param desc the label describing the link
* @param sheet the sheet containing the cells to be linked to
* @param destcol the column number of the first destination linked cell
* @param destrow the row number of the first destination linked cell
* @param lastdestcol the column number of the last destination linked cell
* @param lastdestrow the row number of the last destination linked cell
*/
protected void setLocation(String desc,
WritableSheet sheet,
int destcol, int destrow,
int lastdestcol, int lastdestrow)
{
linkType = workbookLink;
url = null;
file = null;
modified = true;
contents = desc;
setLocation(sheet, destcol, destrow, lastdestcol, lastdestrow);
if (sheet == null)
{
// hyperlink has not been added to the sheet yet, so simply return
return;
}
// Change the label on the sheet
WritableCell wc = sheet.getWritableCell(firstColumn, firstRow);
Assert.verify(wc.getType() == CellType.LABEL);
Label l = (Label) wc;
l.setString(desc);
}
示例5: exportExcelByModulex11
import jxl.write.Label; //導入方法依賴的package包/類
/**
* @deprecated
* @param dataMap
* @param outExcelName
* @param url
* @return
*/
public File exportExcelByModulex11(HashMap dataMap, String outExcelName,
String url) {
File f = new File(outExcelName);//模板路徑
try {
Workbook workbook = Workbook.getWorkbook(new File(url));//獲取操作Workbook
WritableWorkbook excelbook = Workbook.createWorkbook(f, workbook);//編輯模板
WritableSheet sheet2 = excelbook.getSheet(0);
int controlNo = 0;
int startNo = -1;
String mapString = "";
for (int r = 0; r < sheet2.getRows(); r++) {
for (int c = 0; c < sheet2.getColumns(); c++) {
// System.out.println(" (r,c): -- "+"(r="+r+" c="+c+")");
WritableCell cell = sheet2.getWritableCell(c, r);//可編輯單元格
if (cell.getType() == CellType.EMPTY)
continue;
Label lb = (Label) cell;
String signName = lb.getString().trim();
// System.out.println("-signName- > : "+signName);
if (dataMap.containsKey(signName)
&& signName.indexOf("AGGREGATE_START") > -1) {
controlNo++;
startNo = r;
mapString = signName;
} else if (dataMap.containsKey(signName)) {
controlNo++;
lb.setString(dataMap.get(signName).toString());
}
if (controlNo == dataMap.size()) {
r = sheet2.getRows();
c = sheet2.getColumns();
} else if (cell.getContents().equals("[ORVER]")) {
r = sheet2.getRows();
c = sheet2.getColumns();
lb.setString("");
}
}
}
// ArrayList ma = (ArrayList) dataMap.get(mapString);
// if (ma != null && ma.size() > 0 && !mapString.equals(""))
// sheet2 = this.autoAddRowExcel2_XX(sheet2, ma, startNo, 5);
// else if (startNo > -1)
// sheet2.removeRow(startNo);
excelbook.write();
excelbook.close();
} catch (Exception e) {
throw new RuntimeException("寫入文件失敗。", e);
} finally {
//System.out.println("導出完成---Excel");
}
return f;
}
示例6: exportExcelByModulex11
import jxl.write.Label; //導入方法依賴的package包/類
public File exportExcelByModulex11(HashMap dataMap, String outExcelName,
String url) {
File f = new File(outExcelName);//模板路徑
try {
Workbook workbook = Workbook.getWorkbook(new File(url));//獲取操作Workbook
WritableWorkbook excelbook = Workbook.createWorkbook(f, workbook);//編輯模板
WritableSheet sheet2 = excelbook.getSheet(0);
int controlNo = 0;
int startNo = -1;
String mapString = "";
for (int r = 0; r < sheet2.getRows(); r++) {
for (int c = 0; c < sheet2.getColumns(); c++) {
// System.out.println(" (r,c): -- "+"(r="+r+" c="+c+")");
WritableCell cell = sheet2.getWritableCell(c, r);//可編輯單元格
if (cell.getType() == CellType.EMPTY)
continue;
Label lb = (Label) cell;
String signName = lb.getString().toUpperCase().trim();
// System.out.println("-signName- > : "+signName);
if (dataMap.containsKey(signName)
&& signName.indexOf("AGGREGATE_START") > -1) {
controlNo++;
startNo = r;
mapString = signName;
} else if (dataMap.containsKey(signName)) {
controlNo++;
lb.setString(dataMap.get(signName).toString());
}
if (controlNo == dataMap.size()) {
r = sheet2.getRows();
c = sheet2.getColumns();
} else if (cell.getContents().equals("[ORVER]")) {
r = sheet2.getRows();
c = sheet2.getColumns();
lb.setString("");
}
}
}
ArrayList ma = (ArrayList) dataMap.get(mapString);
if (ma != null && ma.size() > 0 && !mapString.equals(""))
sheet2 = this.autoAddRowExcel2_XX(sheet2, ma, startNo, 5);
else if (startNo > -1)
sheet2.removeRow(startNo);
excelbook.write();
excelbook.close();
} catch (Exception e) {
throw new RuntimeException("寫入文件失敗。", e);
} finally {
//System.out.println("導出完成---Excel");
}
return f;
}