package jxl; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import jxl.read.biff.BiffException; import jxl.read.biff.File; import jxl.read.biff.PasswordException; import jxl.read.biff.WorkbookParser; import jxl.write.WritableWorkbook; import jxl.write.biff.WritableWorkbookImpl; public abstract class Workbook { private static final String version = "2.5.9"; public abstract Sheet[] getSheets(); public abstract String[] getSheetNames(); public abstract Sheet getSheet(int paramInt) throws IndexOutOfBoundsException; public abstract Sheet getSheet(String paramString); public static String getVersion() { return "2.5.9"; } public abstract int getNumberOfSheets(); public abstract Cell findCellByName(String paramString); public abstract Cell getCell(String paramString); public abstract Range[] findByName(String paramString); public abstract String[] getRangeNames(); public abstract boolean isProtected(); protected abstract void parse() throws BiffException, PasswordException; public abstract void close(); public static Workbook getWorkbook(File file) throws IOException, BiffException { return getWorkbook(file, new WorkbookSettings()); } public static Workbook getWorkbook(File file, WorkbookSettings ws) throws IOException, BiffException { FileInputStream fis = new FileInputStream(file); File dataFile = null; try { dataFile = new File(fis, ws); } catch (IOException e) { fis.close(); throw e; } catch (BiffException e) { fis.close(); throw e; } fis.close(); WorkbookParser workbookParser = new WorkbookParser(dataFile, ws); workbookParser.parse(); return (Workbook)workbookParser; } public static Workbook getWorkbook(InputStream is) throws IOException, BiffException { return getWorkbook(is, new WorkbookSettings()); } public static Workbook getWorkbook(InputStream is, WorkbookSettings ws) throws IOException, BiffException { File dataFile = new File(is, ws); WorkbookParser workbookParser = new WorkbookParser(dataFile, ws); workbookParser.parse(); return (Workbook)workbookParser; } public static WritableWorkbook createWorkbook(File file) throws IOException { return createWorkbook(file, new WorkbookSettings()); } public static WritableWorkbook createWorkbook(File file, WorkbookSettings ws) throws IOException { FileOutputStream fos = new FileOutputStream(file); return (WritableWorkbook)new WritableWorkbookImpl(fos, true, ws); } public static WritableWorkbook createWorkbook(File file, Workbook in) throws IOException { return createWorkbook(file, in, new WorkbookSettings()); } public static WritableWorkbook createWorkbook(File file, Workbook in, WorkbookSettings ws) throws IOException { FileOutputStream fos = new FileOutputStream(file); return (WritableWorkbook)new WritableWorkbookImpl(fos, in, true, ws); } public static WritableWorkbook createWorkbook(OutputStream os, Workbook in) throws IOException { return createWorkbook(os, in, ((WorkbookParser)in).getSettings()); } public static WritableWorkbook createWorkbook(OutputStream os, Workbook in, WorkbookSettings ws) throws IOException { return (WritableWorkbook)new WritableWorkbookImpl(os, in, false, ws); } public static WritableWorkbook createWorkbook(OutputStream os) throws IOException { return createWorkbook(os, new WorkbookSettings()); } public static WritableWorkbook createWorkbook(OutputStream os, WorkbookSettings ws) throws IOException { return (WritableWorkbook)new WritableWorkbookImpl(os, false, ws); } }