1 19 20 package jxl.demo; 21 22 import java.io.BufferedWriter ; 23 import java.io.FileInputStream ; 24 import java.io.IOException ; 25 26 import jxl.WorkbookSettings; 27 import jxl.biff.Type; 28 import jxl.biff.StringHelper; 29 import jxl.read.biff.File; 30 import jxl.read.biff.BiffRecordReader; 31 import jxl.read.biff.BiffException; 32 import jxl.read.biff.Record; 33 34 37 class WriteAccess 38 { 39 private BiffRecordReader reader; 40 41 public WriteAccess(java.io.File file) 42 throws IOException , BiffException 43 { 44 WorkbookSettings ws = new WorkbookSettings(); 45 FileInputStream fis = new FileInputStream (file); 46 File f = new File(fis, ws); 47 reader = new BiffRecordReader(f); 48 49 display(ws); 50 fis.close(); 51 } 52 53 56 private void display(WorkbookSettings ws) throws IOException 57 { 58 Record r = null; 59 boolean found = false; 60 while (reader.hasNext() && !found) 61 { 62 r = reader.next(); 63 if (r.getType() == Type.WRITEACCESS) 64 { 65 found = true; 66 } 67 } 68 69 if (!found) 70 { 71 System.err.println("Warning: could not find write access record"); 72 return; 73 } 74 75 byte[] data = r.getData(); 76 77 String s = null; 78 79 s = StringHelper.getString(data, data.length, 0, ws); 80 81 System.out.println(s); 82 } 83 } 84 | Popular Tags |