本文整理匯總了Java中jxl.write.WritableWorkbook.close方法的典型用法代碼示例。如果您正苦於以下問題:Java WritableWorkbook.close方法的具體用法?Java WritableWorkbook.close怎麽用?Java WritableWorkbook.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jxl.write.WritableWorkbook
的用法示例。
在下文中一共展示了WritableWorkbook.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readExcel
import jxl.write.WritableWorkbook; //導入方法依賴的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();
}
示例2: printRows
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
private long printRows(XlsExporterContext context, RowWriter writer) throws Throwable {
jobOutput.println("writing to file " + context.getFileName());
try {
WritableWorkbook workbook;
WorkbookSettings workbookSettings = writer.getWorkbookSettings();
if (workbookSettings != null) {
workbook = Workbook.createWorkbook(new File(context.getFileName()), workbookSettings);
} else {
workbook = Workbook.createWorkbook(new File(context.getFileName()));
}
context.setWorkbook(workbook);
writer.init();
writer.printRows();
workbook.write();
workbook.close();
} catch (Exception e) {
throw new IllegalArgumentException("row " + (writer.getLineCount() + 1) + ": error writing row", e);
}
jobOutput.println(writer.getLineCount() + " rows exported");
return writer.getLineCount();
}
示例3: ExportTLDToXLS
import jxl.write.WritableWorkbook; //導入方法依賴的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);
}
}
示例4: ExportCertToXLS
import jxl.write.WritableWorkbook; //導入方法依賴的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);
}
}
示例5: export
import jxl.write.WritableWorkbook; //導入方法依賴的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();
}
示例6: writeList
import jxl.write.WritableWorkbook; //導入方法依賴的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();
}
示例7: exportXls
import jxl.write.WritableWorkbook; //導入方法依賴的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());
}
}
示例8: exportExcelByModulex1
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
public File exportExcelByModulex1( String outExcelName,
String url) {
File f = new File(outExcelName);//輸出文件
try {
Workbook workbook = Workbook.getWorkbook(new File(url));//獲取模板
WritableWorkbook excelbook = Workbook.createWorkbook(f, workbook);//編輯模板
WritableSheet sheet2 = excelbook.getSheet(0);//編輯第一個Sheet
//sheet2 = this.copyExcelRows(sheet2,12,10,2,2);
sheet2 = this.copyExcelRows(sheet2,12,10,2,1);
excelbook.write();
excelbook.close();
} catch (Exception e) {
throw new RuntimeException("寫入文件失敗。", e);
} finally {
//System.out.println("導出完成---Excel");
}
return f;
}
示例9: ExportForwardLookupsToXLS
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
public static void ExportForwardLookupsToXLS(String filename, List<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("Forward lookups", 0);
sheet.addCell(new Label(0, 0, "Domain name", titleformat));
sheet.addCell(new Label(1, 0, "Host name", titleformat));
sheet.addCell(new Label(2, 0, "IP address", titleformat));
sheet.addCell(new Label(3, 0, "Type", titleformat));
int nextRow = 1;
Iterator i = data.iterator();
while (i.hasNext()) {
ForwardLookupResult res = (ForwardLookupResult) i.next();
sheet.addCell(new Label(0, nextRow, res.getDomainName()));
sheet.addCell(new Label(1, nextRow, res.getHostName()));
sheet.addCell(new Label(2, nextRow, res.getIpAddress()));
sheet.addCell(new Label(3, nextRow, res.getLookupType()));
nextRow++;
}
workbook.write();
workbook.close();
} catch (WriteException ex) {
Logger.getLogger("resultExport.ExportForwardLookupsToXLS").log(Level.SEVERE, null, ex);
}
}
示例10: ExportReverseToXLS
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
public static void ExportReverseToXLS(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("Bing IP search", 0);
sheet.addCell(new Label(0, 0, "IP address", titleformat));
sheet.addCell(new Label(1, 0, "Domain name", titleformat));
sheet.addCell(new Label(2, 0, "Host name", titleformat));
int nextRow = 1;
Iterator i = data.iterator();
while (i.hasNext()) {
ReverseLookupResult res = (ReverseLookupResult) i.next();
sheet.addCell(new Label(0, nextRow, res.getIpAddress()));
sheet.addCell(new Label(1, nextRow, res.getDomainName()));
sheet.addCell(new Label(2, nextRow, res.getHostName()));
nextRow++;
}
workbook.write();
workbook.close();
} catch (WriteException ex) {
Logger.getLogger("resultExport.ExportReverseToXLS").log(Level.SEVERE, null, ex);
}
}
示例11: write
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
/**
* Writes the example set into a excel file with XLS format.
* If you want to write it in XLSX format use {@link #writeXLSX(ExampleSet, String, String, String, OutputStream)}
*/
public static void write(ExampleSet exampleSet, Charset encoding, OutputStream out) throws IOException, WriteException {
try {
// .xls files can only store up to 256 columns, so throw error in case of more
if (exampleSet.getAttributes().allSize() > 256) {
throw new IllegalArgumentException(I18N.getMessage(I18N.getErrorBundle(), "export.excel.excel_xls_file_exceeds_column_limit"));
}
WorkbookSettings ws = new WorkbookSettings();
ws.setEncoding(encoding.name());
ws.setLocale(Locale.US);
WritableWorkbook workbook = Workbook.createWorkbook(out, ws);
WritableSheet s = workbook.createSheet(RAPID_MINER_DATA, 0);
writeDataSheet(s, exampleSet);
workbook.write();
workbook.close();
} finally {
try {
out.close();
} catch (Exception e) {
// silent. exception will trigger warning anyway
}
}
}
示例12: writeErrorAnnotatedWorkbook
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
public WritableWorkbook writeErrorAnnotatedWorkbook(File out)
{
if (_errors.getHasErrors()) {
try {
WritableWorkbook errorAnnotatedWorkbook = _errors.getErrorAnnotatedWorkbook();
errorAnnotatedWorkbook.setOutputFile(out);
errorAnnotatedWorkbook.write();
errorAnnotatedWorkbook.close();
return errorAnnotatedWorkbook;
}
catch (Exception e) {
log.error("could not write error annotated workbook: " + e.getMessage());
}
}
return null;
}
示例13: testImageExport
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
/** Requires manual inspection to verify success */
public void testImageExport() throws Exception
{
try {
File file = File.createTempFile("testImageExport", ".xls");
OutputStream out = new FileOutputStream(file);
WritableWorkbook workbook = Workbook.createWorkbook(out);
WritableSheet sheet = workbook.createSheet("sheet1", 0);
InputStream imageIn = Workbook2UtilsTest.class.getResourceAsStream("arrow-first.png");
byte[] imageData = IOUtils.toByteArray(imageIn);
Workbook2Utils.writeCell(sheet, 1, 0, "image:");
Workbook2Utils.writeImage(sheet, 1, 1, imageData);
workbook.write();
workbook.close();
log.warn("must manually verify that image was exported to workbook " + file);
} catch (Exception e) {
// prefer not to maintain this type of test, so allow the error to go to console -sde4
e.printStackTrace();
}
}
示例14: exportTableTo
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
/**
* Exports a {@link JTable} to an excel file. If the file does not exists,
* creates one.
*
* @param table table to export
* @param file destination file
* @throws IOException thrown when export can not be completed (Ex.
* FileNotFound)
*/
public static void exportTableTo(JTable table, File file) throws IOException {
try {
Logging.log("Exporting table to " + file.getPath());
Files.createNewFileWithParents(file);
WritableWorkbook workbook = Workbook.createWorkbook(file);
WritableSheet sheet = workbook.createSheet("First Sheet", 0);
TableModel model = table.getModel();
for (int i = 0; i < model.getRowCount(); i++) {
for (int j = 0; j < model.getColumnCount(); j++) {
Label cell = new Label(j, i, String.valueOf(model.getValueAt(i, j)));
sheet.addCell(cell);
}
}
workbook.write();
workbook.close();
} catch (WriteException ex) {
throw new IOException();
}
}
示例15: readWrite
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
/**
* Reads in the inputFile and creates a writable copy of it called outputFile
*
* @exception IOException
* @exception BiffException
*/
public void readWrite() throws IOException, BiffException, WriteException
{
logger.info("Reading...");
Workbook w1 = Workbook.getWorkbook(inputWorkbook);
logger.info("Copying...");
WritableWorkbook w2 = Workbook.createWorkbook(outputWorkbook, w1);
if (inputWorkbook.getName().equals("jxlrwtest.xls"))
{
modify(w2);
}
w2.write();
w2.close();
logger.info("Done");
}