本文整理汇总了Java中jxl.write.WritableSheet.getWritableCell方法的典型用法代码示例。如果您正苦于以下问题:Java WritableSheet.getWritableCell方法的具体用法?Java WritableSheet.getWritableCell怎么用?Java WritableSheet.getWritableCell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jxl.write.WritableSheet
的用法示例。
在下文中一共展示了WritableSheet.getWritableCell方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addValue
import jxl.write.WritableSheet; //导入方法依赖的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: findCellByName
import jxl.write.WritableSheet; //导入方法依赖的package包/类
/**
* Gets the named cell from this workbook. If the name refers to a
* range of cells, then the cell on the top left is returned. If
* the name cannot be found, null is returned
*
* @param the name of the cell/range to search for
* @return the cell in the top left of the range if found, NULL
* otherwise
*/
public WritableCell findCellByName(String name)
{
NameRecord nr = (NameRecord) nameRecords.get(name);
if (nr == null)
{
return null;
}
NameRecord.NameRange[] ranges = nr.getRanges();
// Go and retrieve the first cell in the first range
int sheetIndex = getExternalSheetIndex(ranges[0].getExternalSheet());
WritableSheet s = getSheet(sheetIndex);
WritableCell cell = s.getWritableCell(ranges[0].getFirstColumn(),
ranges[0].getFirstRow());
return cell;
}
示例3: setLocation
import jxl.write.WritableSheet; //导入方法依赖的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);
}
示例4: outputDataHeadings
import jxl.write.WritableSheet; //导入方法依赖的package包/类
/**
* Outputs the data headings row.
*
* @param workSheet to add the row to
* @param table to fetch metadata from
* @param startRow to add the headings at
* @param helpTextRowNumbers - the map of column names to row index for each
* bit of help text
* @throws WriteException if any of the writes to workSheet failed
* @return the row to carry on inserting at
*/
private int outputDataHeadings(WritableSheet workSheet, Table table, final int startRow, final Map<String, Integer> helpTextRowNumbers) throws WriteException {
int currentRow = startRow;
int columnNumber = 0;
final WritableCellFormat columnHeadingFormat = getBoldFormat();
columnHeadingFormat.setBackground(Colour.VERY_LIGHT_YELLOW);
WritableFont font = new WritableFont(WritableFont.ARIAL, 8, WritableFont.BOLD);
font.setColour(Colour.BLUE);
font.setUnderlineStyle(UnderlineStyle.SINGLE);
columnHeadingFormat.setFont(font);
for (Column column : table.columns()) {
if(columnNumber < MAX_EXCEL_COLUMNS && !column.getName().equals("id") && !column.getName().equals("version")) {
// Data heading is a link back to the help text
WritableHyperlink linkToHelp = new WritableHyperlink(
columnNumber, currentRow,
spreadsheetifyName(column.getName()),
workSheet, 0, helpTextRowNumbers.get(column.getName()));
workSheet.addHyperlink(linkToHelp);
WritableCell label = workSheet.getWritableCell(columnNumber, currentRow);
label.setCellFormat(columnHeadingFormat);
// Update the help text such that it is a link to the heading
Cell helpCell = workSheet.getCell(0, helpTextRowNumbers.get(column.getName()));
WritableHyperlink linkFromHelp = new WritableHyperlink(
0, helpTextRowNumbers.get(column.getName()),
helpCell.getContents(),
workSheet, columnNumber, currentRow);
workSheet.addHyperlink(linkFromHelp);
columnNumber++;
}
}
currentRow++;
return currentRow;
}
示例5: exportExcelByModulex11
import jxl.write.WritableSheet; //导入方法依赖的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.WritableSheet; //导入方法依赖的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;
}
示例7: getWritableCell
import jxl.write.WritableSheet; //导入方法依赖的package包/类
/**
* Returns the cell for the specified location eg. "Sheet1!A4".
* This is identical to using the CellReferenceHelper with its
* associated performance overheads, consequently it should
* be use sparingly
*
* @param loc the cell to retrieve
* @return the cell at the specified location
*/
public WritableCell getWritableCell(String loc)
{
WritableSheet s = getSheet(CellReferenceHelper.getSheet(loc));
return s.getWritableCell(loc);
}