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


Java WritableCell类代码示例

本文整理汇总了Java中jxl.write.WritableCell的典型用法代码示例。如果您正苦于以下问题:Java WritableCell类的具体用法?Java WritableCell怎么用?Java WritableCell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WritableCell类属于jxl.write包,在下文中一共展示了WritableCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toWritableCell

import jxl.write.WritableCell; //导入依赖的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());
   }
}
 
开发者ID:nyla-solutions,项目名称:nyla,代码行数:27,代码来源:Excel.java

示例2: addValue

import jxl.write.WritableCell; //导入依赖的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

示例3: setFile

import jxl.write.WritableCell; //导入依赖的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());
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:29,代码来源:HyperlinkRecord.java

示例4: findCellByName

import jxl.write.WritableCell; //导入依赖的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

示例5: writeCell

import jxl.write.WritableCell; //导入依赖的package包/类
public static void writeCell(WritableSheet spreadSheet, int c, int r, Class returnType, Object value, ExcelCellFormat f, HashMap<String, WritableCellFormat> cellFormats)
		throws Exception {
	if (spreadSheet != null) {
		WritableCell cell = createCell(returnType, c, r, value, f, cellFormats);
		addCell(cell, spreadSheet, c, r, f);
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:8,代码来源:ExcelUtil.java

示例6: writeHead

import jxl.write.WritableCell; //导入依赖的package包/类
public static void writeHead(WritableSheet spreadSheet, int c, int r, String columnName, ExcelCellFormat f, HashMap<String, WritableCellFormat> cellFormats) throws Exception {
	if (spreadSheet != null) {
		WritableCell cell;
		if (f.isOverrideFormat()) {
			cell = new jxl.write.Label(c, r, columnName, getHeadCellFormat(f, cellFormats));
		} else {
			cell = new jxl.write.Label(c, r, columnName);
		}
		addCell(cell, spreadSheet, c, r, f);
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:12,代码来源:ExcelUtil.java

示例7: addData

import jxl.write.WritableCell; //导入依赖的package包/类
public void addData(int date, double bid, double ask) {

        String tmp;
        WritableCell cell;
        if (nrows == 1) {
            if (bid == 0) {
                list_data.add(new Number(0, 1, date));
                list_data.add(new Number(1, 1, ask));
                list_data.add(new Number(2, 1, ask));
                last_bid = ask;
                last_ask = ask;
            } else {
                list_data.add(new Number(0, 1, date));
                list_data.add(new Number(1, 1, bid));
                list_data.add(new Number(2, 1, bid));
                last_bid = bid;
                last_ask = bid;
            }
        } else {
            if (bid == 0) {
                list_data.add(new Number(0, nrows, date));
                list_data.add(new Number(1, nrows, last_bid));
                list_data.add(new Number(2, nrows, ask));
                last_ask = ask;
            } else {
                list_data.add(new Number(0, nrows, date));
                list_data.add(new Number(1, nrows, bid));
                list_data.add(new Number(2, nrows, last_ask));
                last_bid = bid;
            }
        }
        nrows++;

    }
 
开发者ID:NicolasGriere,项目名称:High-Frequency-Data-Order-Book-Analyser,代码行数:35,代码来源:ExportChart.java

示例8: setURL

import jxl.write.WritableCell; //导入依赖的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());
    }
  }   
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:45,代码来源:HyperlinkRecord.java

示例9: setLocation

import jxl.write.WritableCell; //导入依赖的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

示例10: textVertical

import jxl.write.WritableCell; //导入依赖的package包/类
private WritableCell textVertical(WritableCell cell) throws WriteException {
	WritableCellFormat format = new WritableCellFormat(cell.getCellFormat());
	format.setOrientation(Orientation.PLUS_90);
	cell.setCellFormat(format);
	return cell;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:7,代码来源:ExcelReport.java

示例11: center

import jxl.write.WritableCell; //导入依赖的package包/类
private WritableCell center(WritableCell cell) throws WriteException {
	WritableCellFormat format = new WritableCellFormat(cell.getCellFormat());
	format.setAlignment(Alignment.CENTRE);
	cell.setCellFormat(format);
	return cell;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:7,代码来源:ExcelReport.java

示例12: outputDataHeadings

import jxl.write.WritableCell; //导入依赖的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

示例13: exportToExcel

import jxl.write.WritableCell; //导入依赖的package包/类
@Override
  public void exportToExcel(File f) {
      WorkbookSettings wbSettings = new WorkbookSettings();
      wbSettings.setLocale(new Locale("en", "EN"));
      
      /* Gather data */
      Set<WritableCell> exportValues = new HashSet<WritableCell>();
      Map<Integer, Map<Double, Double>> data = new TreeMap<Integer, Map<Double, Double>>();
      
      // Keep track of the timepoints
      List<Double> timepoints = new ArrayList<Double>();     	
      Collections.sort(timepoints);
      
      for (int seriesIndex=0; seriesIndex<this.dataset.getSeriesCount(); seriesIndex++) {			
	Map<Double, Double> seriesMap = new TreeMap<Double, Double>();
	
	for (int i=0; i<this.dataset.getItemCount(seriesIndex); i++) {				
		Number x = this.dataset.getX(seriesIndex, i);
		Number y = this.dataset.getY(seriesIndex, i);
		
		seriesMap.put(x.doubleValue(), y.doubleValue());
		timepoints.add(x.doubleValue());
	}
	
	data.put(seriesIndex, seriesMap);
}
      
      /* Convert data */
      for (int timeIndex=0; timeIndex<timepoints.size(); timeIndex++) {		       	
      	Double timepoint = timepoints.get(timeIndex);
      	
      	/* Add information about timepoint */
	exportValues.add(new Label(0, timeIndex+1, timepoint.toString())); // INDEX SHIFT
	
	/* Add information per timepoint */
	for(int seriesIndex=0; seriesIndex<data.size(); seriesIndex++) {
		Map<Double, Double> seriesData = data.get(seriesIndex);
		Double value = seriesData.get(timepoint);
		
		if (value != null) {
			exportValues.add(new Label(seriesIndex+1, timeIndex+1, value.toString())); // INDEX SHIFT
		} else {
			exportValues.add(new Label(seriesIndex+1, timeIndex+1, "")); // INDEX SHIFT
		}
	}
}
          
      /*
       * Export data
       */
      WritableWorkbook workbook;
try {
	workbook = Workbook.createWorkbook(f, wbSettings);
	
	/* Create sheet in workbook */
	String chartTitle = this.chart.getTitle().getText();   			
	WritableSheet excelSheet = workbook.createSheet(chartTitle, 0);
       
	/* Generate header */
       excelSheet.addCell(new Label(0, 0, "Time"));
       for (int seriesIndex=0; seriesIndex<this.dataset.getSeriesCount(); seriesIndex++) {
		Comparable seriesKey = this.dataset.getSeriesKey(seriesIndex);
		
		if (seriesKey instanceof String) {					
			excelSheet.addCell(new Label(seriesIndex+1, 0, (String) seriesKey));
		}
	}  
       
       /* Write data */
       for (WritableCell c : exportValues) {
		excelSheet.addCell(c);
       }
       
       workbook.write();
       workbook.close();
} catch (IOException ioException) {
	logger.error("", ioException);
} catch (WriteException writeException) {
	logger.error("", writeException);
}
  }
 
开发者ID:modsim,项目名称:vizardous,代码行数:82,代码来源:TraceChart2D.java

示例14: exportToExcel

import jxl.write.WritableCell; //导入依赖的package包/类
@Override
  public void exportToExcel(File f) {
      WorkbookSettings wbSettings = new WorkbookSettings();
      wbSettings.setLocale(new Locale("en", "EN"));
      
      /* Gather data */
      Set<WritableCell> exportValues = new HashSet<WritableCell>();
      
      /* Gather data */
Map<Comparable, Collection<? extends Number>> data = getData();

for (int seriesIndex=0; seriesIndex<histogramDataset.getSeriesCount(); seriesIndex++) {			
	Collection<? extends Number> datapoints = data.get(seriesIndex);			
	
	/* Convert data */
	int datapointIndex = 1; // Index shift because of the row title
	for (Number datapoint : datapoints) {			
		/* Add information per datapoint */			
		exportValues.add(new Label(seriesIndex, datapointIndex, datapoint.toString()));
		datapointIndex++;
	}
}
          
      /*
       * Export data
       */
      WritableWorkbook workbook;
try {
	workbook = Workbook.createWorkbook(f, wbSettings);
	
	/* Create sheet in workbook */
	String chartTitle = this.chart.getTitle().getText();   			
	WritableSheet excelSheet = workbook.createSheet(chartTitle, 0);
       
	/* Generate header */
       for (int seriesIndex=0; seriesIndex<this.histogramDataset.getSeriesCount(); seriesIndex++) {
		Comparable seriesKey = this.histogramDataset.getSeriesKey(seriesIndex);
					
		excelSheet.addCell(new Label(seriesIndex, 0, seriesKey.toString()));
	}  
       
       /* Write data */
       for (WritableCell c : exportValues) {
		excelSheet.addCell(c);
       }
       
       workbook.write();
       workbook.close();
} catch (IOException ioException) {
	logger.error("", ioException);
} catch (WriteException writeException) {
	logger.error("", writeException);
}
  }
 
开发者ID:modsim,项目名称:vizardous,代码行数:55,代码来源:DistributionChart2D.java

示例15: exportExcelByModulex11

import jxl.write.WritableCell; //导入依赖的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


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