GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||
GeezerVison is showing en.wikipedia.org — Java Excel API - Wikipedia
Java Excel API (a.k.a. JXL API) allows users to read, write, create, and modify sheets in an Excel (.xls) workbook at runtime. It does not support .xlsx format.[2] Microsoft Excel supportJava Excel API supports Excel documents with versions Excel 95, 97, 2000, XP, and 2003. These documents hold the extension .xls.[2] UsageJava Excel API is widely used with Selenium. ExampleSample code to write to an Excel file might look like as follows: import java.io.File; import jxl.Workbook; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import jxl.write.Label; import jxl.write.WriteException; public class DataSheet { private Workbook wbook; private WritableWorkbook wwbCopy; private WritableSheet shSheet; public void readExcel() { try { wbook = Workbook.getWorkbook(new File("path/testSampleData.xls")); wwbCopy = Workbook.createWorkbook(new File("path/testSampleDataCopy.xls"), wbook); shSheet = wwbCopy.getSheet(0); } catch (Exception e) { e.printStackTrace(); } } public void setValueIntoCell(String strSheetName, int iColumnNumber, int iRowNumber, String strData) throws WriteException { WritableSheet wshTemp = wwbCopy.getSheet(strSheetName); Label labTemp = new Label(iColumnNumber, iRowNumber, strData); try { wshTemp.addCell(labTemp); } catch (Exception e) { e.printStackTrace(); } } public void closeFile() { try { // Closing the writable work book wwbCopy.write(); wwbCopy.close(); // Closing the original work book wbook.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) throws WriteException { DataSheet ds = new DataSheet(); ds.readExcel(); ds.setValueIntoCell("sheet1", 5, 1, "PASS"); ds.setValueIntoCell("sheet1", 5, 2, "FAIL"); ds.setValueIntoCell("sheet1", 5, 3, "PASS"); ds.closeFile(); } } See alsoReferencesExternal links | ||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | ||||||||||||||||||||||