當前位置: 首頁>>代碼示例>>Java>>正文


Java WriteException類代碼示例

本文整理匯總了Java中jxl.write.WriteException的典型用法代碼示例。如果您正苦於以下問題:Java WriteException類的具體用法?Java WriteException怎麽用?Java WriteException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WriteException類屬於jxl.write包,在下文中一共展示了WriteException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeXLSX

import jxl.write.WriteException; //導入依賴的package包/類
/**
 * Writes the example set into a excel file with XLSX format. If you want to write it in XLS
 * format use {@link #write(ExampleSet, Charset, OutputStream)}.
 *
 * @param exampleSet
 *            the exampleSet to write
 * @param sheetName
 *            name of the excel sheet which will be created.
 * @param dateFormat
 *            a string which describes the format used for dates.
 * @param numberFormat
 *            a string which describes the format used for numbers.
 * @param outputStream
 *            the stream to write the file to
 * @param opProg
 *            increases the progress by the number of examples to provide a more detailed
 *            progress.
 */
public static void writeXLSX(ExampleSet exampleSet, String sheetName, String dateFormat, String numberFormat,
		OutputStream outputStream, OperatorProgress opProg) throws WriteException, IOException,
		ProcessStoppedException {
	// .xlsx files can only store up to 16384 columns, so throw error in case of more
	if (exampleSet.getAttributes().allSize() > 16384) {
		throw new IllegalArgumentException(I18N.getMessage(I18N.getErrorBundle(),
				"export.excel.excel_xlsx_file_exceeds_column_limit"));
	}

	try {
		XSSFWorkbook workbook = new XSSFWorkbook();

		Sheet sheet = workbook.createSheet(WorkbookUtil.createSafeSheetName(sheetName));
		dateFormat = dateFormat == null ? DEFAULT_DATE_FORMAT : dateFormat;

		numberFormat = numberFormat == null ? "#.0" : numberFormat;

		writeXLSXDataSheet(workbook, sheet, dateFormat, numberFormat, exampleSet, opProg);
		workbook.write(outputStream);
	} finally {
		outputStream.flush();
		outputStream.close();
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:43,代碼來源:ExcelExampleSetWriter.java

示例2: setExcelListTitle

import jxl.write.WriteException; //導入依賴的package包/類
/**
 * 設置報表內容頭
 * 
 * @param listTitle
 *            報表頭
 * @throws IOException
 * @throws WriteException
 */
@Deprecated
public void setExcelListTitle(String[] listTitle) throws WriteException, IOException {
    try {
        irow++;
        long start = System.currentTimeMillis();
        wfont = new WritableFont(WritableFont.createFont("宋體"), 10, WritableFont.BOLD, false,
            UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
        wcfFC = new WritableCellFormat(wfont);
        wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM);
        wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
        wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
        for (int i = icol; i < listTitle.length; i++) {
            wsheet.addCell(new Label(i, irow, listTitle[i], wcfFC));
        }
        trow = irow;
        logger.info("title use time:" + (System.currentTimeMillis() - start));
    } catch (Exception e) {
        this.close();
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:29,代碼來源:DownloadExcelUtil.java

示例3: readExcel

import jxl.write.WriteException; //導入依賴的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

示例4: ExportTLDToXLS

import jxl.write.WriteException; //導入依賴的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

示例5: ExportCertToXLS

import jxl.write.WriteException; //導入依賴的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

示例6: setReportTitle

import jxl.write.WriteException; //導入依賴的package包/類
/**
 * 設置報表標題
 * 
 * @param reportTitle
 *            報表標題
 * @throws IOException
 * @throws WriteException
 * @throws WriteException
 */
public void setReportTitle(String reportTitle) throws WriteException, IOException {
    try {
        irow++;
        wfont = new WritableFont(WritableFont.createFont("宋體"), 12, WritableFont.BOLD, false,
            UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
        wcfFC = new WritableCellFormat(wfont);
        wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
        // wcfFC.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW);// 背景色
        wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
        // wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM,
        // Colour.BLACK);//
        // 邊框
        wsheet.addCell(new Label(icol, irow, reportTitle, wcfFC));
        trow = irow;
    } catch (Exception e) {
        this.close();
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:28,代碼來源:DownloadExcelUtil.java

示例7: addRow

import jxl.write.WriteException; //導入依賴的package包/類
/**
 * 添加一行
 * 
 * @param strings
 *            該行數據
 * @throws IOException
 * @throws WriteException
 */
public void addRow(Object[] strings, CellType[] cellTypes, DisplayFormat... dFormat)
    throws WriteException, IOException {
    try {
        irow++;
        DisplayFormat format = null;
        for (int i = 0; i < strings.length; i++) {
            if (dFormat != null) {
                if (dFormat.length > i) {
                    format = dFormat[i];
                } else if (dFormat.length > 0) {
                    format = dFormat[0];
                }
            }
            addCell(i, irow, strings[i] == null ? "" : strings[i].toString(), cellTypes[i], format, false,
                i + 1 == strings.length);
        }
    } catch (Exception e) {
        logger.error("", e);
        this.close();
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:30,代碼來源:DownloadExcelUtil.java

示例8: setExcelListTitle

import jxl.write.WriteException; //導入依賴的package包/類
/**
 * 設置報表內容頭
 * 
 * @param listTitle
 *            報表頭
 * @throws IOException
 * @throws WriteException
 */
@Deprecated
public void setExcelListTitle(String[] listTitle) throws WriteException, IOException {
    try {
        irow++;
        long start = System.currentTimeMillis();
        wfont = new WritableFont(WritableFont.createFont("宋體"), 10, WritableFont.BOLD, false,
            UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
        wcfFC = new WritableCellFormat(wfont);
        wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM);
        wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
        wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
        for (int i = icol; i < listTitle.length; i++) {
            wsheet.addCell(new Label(i, irow, listTitle[i], wcfFC));
        }
        trow = irow;
        log.info("title use time:" + (System.currentTimeMillis() - start));
    } catch (Exception e) {
        this.close();
    }
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:29,代碼來源:DownloadExcelUtil.java

示例9: addRow

import jxl.write.WriteException; //導入依賴的package包/類
/**
 * 添加一行
 * 
 * @param strings
 *            該行數據
 * @throws IOException
 * @throws WriteException
 */
public void addRow(Object[] strings, CellType[] cellTypes, DisplayFormat... dFormat)
                                                                                    throws WriteException,
                                                                                    IOException {
    try {
        irow++;
        DisplayFormat format = null;
        for (int i = 0; i < strings.length; i++) {
            if (dFormat != null) {
                if (dFormat.length > i) {
                    format = dFormat[i];
                } else if (dFormat.length > 0) {
                    format = dFormat[0];
                }
            }
            addCell(i, irow, strings[i] == null ? "" : strings[i].toString(), cellTypes[i],
                format, false, i + 1 == strings.length);
        }
    } catch (Exception e) {
        log.error(e);
        this.close();
    }
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:31,代碼來源:DownloadExcelUtil.java

示例10: format

import jxl.write.WriteException; //導入依賴的package包/類
/**
 * 單元格的格式設置 字體大小 顏色 對齊方式、背景顏色等...
 */
public static void format() {
    try {
        arial14font = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD);
        arial14font.setColour(jxl.format.Colour.LIGHT_BLUE);
        arial14format = new WritableCellFormat(arial14font);
        arial14format.setAlignment(jxl.format.Alignment.CENTRE);
        arial14format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
        arial14format.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW);

        arial10font = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD);
        arial10format = new WritableCellFormat(arial10font);
        arial10format.setAlignment(jxl.format.Alignment.CENTRE);
        arial10format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
        arial10format.setBackground(Colour.GRAY_25);

        arial12font = new WritableFont(WritableFont.ARIAL, 10);
        arial12format = new WritableCellFormat(arial12font);
        arial10format.setAlignment(jxl.format.Alignment.CENTRE);//對齊格式
        arial12format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN); //設置邊框

    } catch (WriteException e) {
        e.printStackTrace();
    }
}
 
開發者ID:HowieTianDev,項目名稱:ChenYan,代碼行數:28,代碼來源:ExcelUtils.java

示例11: format

import jxl.write.WriteException; //導入依賴的package包/類
public static void format() {
    try {
        arial14font = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD);
        arial14font.setColour(jxl.format.Colour.LIGHT_BLUE);
        arial14format = new WritableCellFormat(arial14font);
        arial14format.setAlignment(jxl.format.Alignment.CENTRE);
        arial14format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
        arial14format.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW);
        arial10font = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD);
        arial10format = new WritableCellFormat(arial10font);
        arial10format.setAlignment(jxl.format.Alignment.CENTRE);
        arial10format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
        arial10format.setBackground(jxl.format.Colour.LIGHT_BLUE);
        arial12font = new WritableFont(WritableFont.ARIAL, 12);
        arial12format = new WritableCellFormat(arial12font);
        arial12format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
    } catch (WriteException e) {

        e.printStackTrace();
    }
}
 
開發者ID:qiu-yongheng,項目名稱:Bluetooth_BLE,代碼行數:22,代碼來源:ExcelUtils.java

示例12: getHeader

import jxl.write.WriteException; //導入依賴的package包/類
public static WritableCellFormat getHeader() {
	WritableFont font = new WritableFont(WritableFont.TIMES, 10,
			WritableFont.BOLD);// 定義字體
	try {
		font.setColour(Colour.BLUE);// 藍色字體
	} catch (WriteException e1) {
		e1.printStackTrace();
	}
	WritableCellFormat format = new WritableCellFormat(font);
	try {
		format.setAlignment(jxl.format.Alignment.CENTRE);// 左右居中
		format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);// 上下居中
		// format.setBorder(Border.ALL, BorderLineStyle.THIN,
		// Colour.BLACK);// 黑色邊框
		// format.setBackground(Colour.YELLOW);// 黃色背景
	} catch (WriteException e) {
		e.printStackTrace();
	}
	return format;
}
 
開發者ID:reallin,項目名稱:Android_Excel,代碼行數:21,代碼來源:ExcelUtil.java

示例13: addColumnName

import jxl.write.WriteException; //導入依賴的package包/類
public void addColumnName(String... columnNames) throws WriteException {
	int columnCount = this.sheet.getColumns();
	// System.err.println("columnCount:" + columnCount);
	for (int i = 0; i < columnNames.length; i++) {
		// 通過函數WritableFont()設置字體樣式
		// 第一個參數表示所選字體
		// 第二個參數表示字體大小
		// 第三個參數表示粗體樣式,有BOLD和NORMAL兩種樣式
		// 第四個參數表示是否斜體,此處true表示為斜體
		// 第五個參數表示下劃線樣式
		// 第六個參數表示顏色樣式,此處為Red
		WritableFont wf = new WritableFont(WritableFont.TIMES, 11, WritableFont.BOLD);
		CellFormat cf = new WritableCellFormat(wf);
		Label label = new Label(i + columnCount, 0, columnNames[i], cf);
		sheet.addCell(label);
	}
}
 
開發者ID:tanhaichao,項目名稱:leopard,代碼行數:18,代碼來源:ExcelView.java

示例14: setActions

import jxl.write.WriteException; //導入依賴的package包/類
private WikiPane setActions() {
  fileName.textProperty().addListener((observable, oldValue, newValue) -> {
    createButton.setDisable(newValue.isEmpty());
  });

  createButton.setOnAction(event -> {
    try {
      createSpreadsheet();
      showOpenFileButton();
      Settings.saveProperties();
    } catch (IOException | BiffException | WriteException ex) {
      addElement(new WikiLabel("create-file-error"));
      LOGGER.log(Level.WARNING, 
          "Error occurred during creation of spreadsheet file: {0}",
          new String[]{ex.getLocalizedMessage()}
      );
    }
  });

  return this;
}
 
開發者ID:yarl,項目名稱:pattypan,代碼行數:22,代碼來源:CreateFilePane.java

示例15: addMultipleLabelsWrap

import jxl.write.WriteException; //導入依賴的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


注:本文中的jxl.write.WriteException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。