本文整理匯總了Java中jxl.write.WritableWorkbook.write方法的典型用法代碼示例。如果您正苦於以下問題:Java WritableWorkbook.write方法的具體用法?Java WritableWorkbook.write怎麽用?Java WritableWorkbook.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jxl.write.WritableWorkbook
的用法示例。
在下文中一共展示了WritableWorkbook.write方法的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: 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);
}
}
示例4: 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();
}
示例5: 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();
}
示例6: 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());
}
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: writeToExcel
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
/**
* 寫出到excel
*/
public String writeToExcel() {
String result = null;
//
WritableWorkbook workBook = null;
try {
String excelName = excelName(WuxingCollector.class);
File file = new File(excelName);
workBook = Workbook.createWorkbook(file);
// 資料
writeToSheet_0(workBook);
// 常數
writeToSheet_1(workBook);
//
workBook.write();
//
result = excelName;
} catch (Exception ex) {
throw new EditorException(ex);
} finally {
close(workBook);
}
//
return result;
}
示例10: writeToExcel
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
public String writeToExcel() {
String result = null;
//
WritableWorkbook workBook = null;
try {
String excelName = excelName(WuxingCollector.class);
File file = new File(excelName);
workBook = Workbook.createWorkbook(file);
// 資料
writeToSheet_0(workBook);
// 常數
writeToSheet_1(workBook);
//
workBook.write();
//
result = excelName;
} catch (Exception ex) {
throw new EditorException(ex);
} finally {
close(workBook);
}
//
return result;
}
示例11: writeToExcel
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
public String writeToExcel() {
String result = null;
//
WritableWorkbook workBook = null;
try {
String excelName = excelName(TrainCollector.class);
File file = new File(excelName);
workBook = Workbook.createWorkbook(file);
// 資料
writeToSheet_0(workBook);
// 常數
writeToSheet_1(workBook);
//
workBook.write();
//
result = excelName;
} catch (Exception ex) {
throw new EditorException(ex);
} finally {
close(workBook);
}
//
return result;
}
示例12: writeToExcel
import jxl.write.WritableWorkbook; //導入方法依賴的package包/類
public String writeToExcel() {
String result = null;
//
WritableWorkbook workBook = null;
try {
String excelName = excelName(SasangCollector.class);
File file = new File(excelName);
workBook = Workbook.createWorkbook(file);
// 資料
writeToSheet_0(workBook);
// 常數
writeToSheet_1(workBook);
//
workBook.write();
//
result = excelName;
} catch (Exception ex) {
throw new EditorException(ex);
} finally {
close(workBook);
}
//
return result;
}
示例13: 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
}
}
}
示例14: 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;
}
示例15: 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();
}
}