当前位置: 首页>>代码示例>>Java>>正文


Java WritableSheet.getWritableCell方法代码示例

本文整理汇总了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;
}
 
开发者ID:dipoo,项目名称:arong,代码行数:25,代码来源:ExcelUitl.java

示例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;
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:29,代码来源:WritableWorkbookImpl.java

示例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);
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:38,代码来源:HyperlinkRecord.java

示例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;
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:52,代码来源:TableOutputter.java

示例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;
		}
 
开发者ID:dipoo,项目名称:arong,代码行数:60,代码来源:ExcelUitl.java

示例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;
}
 
开发者ID:dipoo,项目名称:arong,代码行数:53,代码来源:ExcelCommonMethod.java

示例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);
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:15,代码来源:WritableWorkbookImpl.java


注:本文中的jxl.write.WritableSheet.getWritableCell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。