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


Java WritableSheet类代码示例

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


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

示例1: readExcel

import jxl.write.WritableSheet; //导入依赖的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();
}
 
开发者ID:guozhaotong,项目名称:FacetExtract,代码行数:24,代码来源:TopicNameProcess.java

示例2: ExportTLDToXLS

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

示例3: ExportCertToXLS

import jxl.write.WritableSheet; //导入依赖的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);
    }
}
 
开发者ID:sensepost,项目名称:yeti,代码行数:25,代码来源:ResultExport.java

示例4: getExternalSheetName

import jxl.write.WritableSheet; //导入依赖的package包/类
/**
 * Gets the name of the external sheet specified by the index
 *
 * @param index the external sheet index
 * @return the name of the external sheet
 */
public String getExternalSheetName(int index)
{
  int supbookIndex = externSheet.getSupbookIndex(index);
  SupbookRecord sr = (SupbookRecord) supbooks.get(supbookIndex);
  
  int firstTab = externSheet.getFirstTabIndex(index);
  
  if (sr.getType() == SupbookRecord.INTERNAL)
  {
    // It's an internal reference - get the name from the sheets list
    WritableSheet ws = getSheet(firstTab);

    return ws.getName();
  }
  else if (sr.getType() == SupbookRecord.EXTERNAL)
  {
    String name = sr.getFileName() + sr.getSheetName(firstTab);
    return name;
  }
  
  // An unknown supbook - return unkown
  logger.warn("Unknown Supbook 1");
  return "[UNKNOWN]";
}
 
开发者ID:loginus,项目名称:jexcelapi,代码行数:31,代码来源:WritableWorkbookImpl.java

示例5: applySpreadsheetSettings

import jxl.write.WritableSheet; //导入依赖的package包/类
@Override
public void applySpreadsheetSettings(WritableSheet spreadSheet, int sheetIndex) throws Exception {
	Integer scaleFactor;
	switch (sheetIndex) {
		case 0:
			scaleFactor = Settings.getIntNullable(AuditTrailExcelSettingCodes.AUDIT_TRAIL_SCALE_FACTOR, Bundle.AUDIT_TRAIL_EXCEL,
					AuditTrailExcelDefaultSettings.AUDIT_TRAIL_SCALE_FACTOR);
			if (Settings.getBoolean(AuditTrailExcelSettingCodes.AUDIT_TRAIL_APPEND_HEADER_FOOTER, Bundle.AUDIT_TRAIL_EXCEL,
					AuditTrailExcelDefaultSettings.AUDIT_TRAIL_APPEND_HEADER_FOOTER)) {
				appendHeaderFooter(spreadSheet.getSettings().getHeader(), spreadSheet.getSettings().getFooter());
			}
			break;
		default:
			scaleFactor = Settings.getIntNullable(AuditTrailExcelSettingCodes.ECRF_FIELD_STATUS_SCALE_FACTOR, Bundle.AUDIT_TRAIL_EXCEL,
					AuditTrailExcelDefaultSettings.ECRF_FIELD_STATUS_SCALE_FACTOR);
			if (Settings.getBoolean(AuditTrailExcelSettingCodes.ECRF_FIELD_STATUS_APPEND_HEADER_FOOTER, Bundle.AUDIT_TRAIL_EXCEL,
					AuditTrailExcelDefaultSettings.ECRF_FIELD_STATUS_APPEND_HEADER_FOOTER)) {
				appendHeaderFooter(spreadSheet.getSettings().getHeader(), spreadSheet.getSettings().getFooter());
			}
			break;
	}
	if (scaleFactor != null && scaleFactor.intValue() > 0) {
		spreadSheet.getSettings().setScaleFactor(scaleFactor);
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:26,代码来源:AuditTrailExcelWriter.java

示例6: writeFieldRow

import jxl.write.WritableSheet; //导入依赖的package包/类
private void writeFieldRow(WritableSheet spreadSheet, HashMap<String, Object> fieldRow, int maxIndexedColumnIndex, int r, ExcelCellFormat f,
		HashMap<String, WritableCellFormat> cellFormats) throws Exception {
	if (fieldRow != null && distinctColumnNames != null && distinctColumnNames.size() > 0) {
		int c = maxIndexedColumnIndex;
		for (int d = 0; d < distinctColumnNames.size(); d++) {
			String columnName = distinctColumnNames.get(d);
			Object fieldValue = fieldRow.get(columnName);
			Integer columnIndex = getColumnIndex(columnName);
			if (columnIndex == null) {
				c++;
				columnIndex = c;
			}
			if (fieldValue != null) {
				ExcelUtil.writeCell(spreadSheet, columnIndex.intValue(), r, fieldValue.getClass(), fieldValue, f, cellFormats);
			} else {
				ExcelUtil.writeCell(spreadSheet, columnIndex.intValue(), r, String.class, null, f, cellFormats);
			}
		}
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:21,代码来源:SpreadSheetWriter.java

示例7: addMultipleLabelsWrap

import jxl.write.WritableSheet; //导入依赖的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));
	}
}
 
开发者ID:vagfed,项目名称:hmcScanner,代码行数:19,代码来源:Loader.java

示例8: addNumber

import jxl.write.WritableSheet; //导入依赖的package包/类
private void addNumber(WritableSheet sheet, int col, int row, String s[], int index, WritableCellFormat format) throws RowsExceededException, WriteException {		
	if (sheet==null || s==null)
		return;
	
	if (index>=s.length)
		return;
	
	double d; 
	
	try {
		d = Double.parseDouble(s[index]);
		
		// Only keep 2 digits: avoid rounding errors
		d = 1d*(int)(d*100)/100;
		
		sheet.addCell(new Number(col,row,d,format));
	} catch (NumberFormatException nfe) {}	
}
 
开发者ID:vagfed,项目名称:hmcScanner,代码行数:19,代码来源:Loader.java

示例9: addNumberDiv1024

import jxl.write.WritableSheet; //导入依赖的package包/类
private void addNumberDiv1024(WritableSheet sheet, int col, int row, String s[], int index, WritableCellFormat format) throws RowsExceededException, WriteException {		
	if (sheet==null || s==null)
		return;
	
	if (index>=s.length)
		return;
	
	double d; 
	
	try {
		d = Double.parseDouble(s[index]);
		d = d / 1024;
		
		// Only keep 2 digits: avoid rounding errors
		d = 1d*(int)(d*100)/100;
		
		sheet.addCell(new Number(col,row,d,format));
	} catch (NumberFormatException nfe) {}	
}
 
开发者ID:vagfed,项目名称:hmcScanner,代码行数:20,代码来源:Loader.java

示例10: export

import jxl.write.WritableSheet; //导入依赖的package包/类
/**
 * @param parameter
 * @param stream
 * @throws IOException 
 * @throws WriteException 
 */
public void export(CalculationParameter a_objParameter, ByteArrayOutputStream a_objStream) throws IOException, WriteException 
{
    this.m_objParameter = a_objParameter;
    WritableWorkbook t_objWorkbook = Workbook.createWorkbook(a_objStream);
    WritableSheet t_objSheet = t_objWorkbook.createSheet("Settings", 0);
    this.formatSettingsPage(t_objSheet);
    this.createSettingSheet(t_objSheet);

    t_objSheet = t_objWorkbook.createSheet("Results", 1);
    this.formatResultPage(t_objSheet);
    this.createResultSheet(t_objSheet);
    t_objSheet.setPageSetup(PageOrientation.LANDSCAPE);

    t_objWorkbook.write();
    t_objWorkbook.close();        
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:23,代码来源:XLSExporter.java

示例11: writeList

import jxl.write.WritableSheet; //导入依赖的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();
}
 
开发者ID:smileboywtu,项目名称:CS-FileTransfer,代码行数:22,代码来源:SyncListIO.java

示例12: exportXls

import jxl.write.WritableSheet; //导入依赖的package包/类
public static void exportXls(SortedMap<java.lang.Number, java.lang.Number> data, String filePath) {
	File file = new File(filePath);
	WorkbookSettings workBookSettings = new WorkbookSettings();
	workBookSettings.setLocale(LOCALE);

	try {
		WritableWorkbook workbook = Workbook.createWorkbook(file, workBookSettings);
		workbook.createSheet("Exported data", 0);
		WritableSheet sheet = workbook.getSheet(0);

		fillSheet(sheet, data);

		workbook.write();
		workbook.close();
	} catch (IOException | WriteException exception) {
		System.err.println(exception.getMessage());
	}
}
 
开发者ID:tesis-dynaware,项目名称:fancy-chart,代码行数:19,代码来源:XlsDao.java

示例13: addCell

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

		}
	}
 
开发者ID:jview,项目名称:jtools,代码行数:30,代码来源:ExcelBizImpl.java

示例14: writeCell

import jxl.write.WritableSheet; //导入依赖的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);
}
 
开发者ID:jonathanbsilva,项目名称:Phonegap-XLS-Plugin,代码行数:26,代码来源:Xls.java

示例15: 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


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