1 16 17 package org.apache.poi.hssf.dev; 18 19 import java.io.FileInputStream ; 20 import java.io.InputStream ; 21 import java.io.IOException ; 22 23 import org.apache.poi.poifs.filesystem.POIFSFileSystem; 24 import org.apache.poi.hssf.eventmodel.*; 25 import org.apache.poi.hssf.eventusermodel.*; 26 import org.apache.poi.hssf.record.Record; 27 28 import org.apache.poi.hssf.eventusermodel.HSSFRequest; 29 import org.apache.poi.hssf.eventusermodel.HSSFListener; 30 import org.apache.poi.hssf.eventusermodel.HSSFEventFactory; 31 32 36 37 public class EFBiffViewer 38 { 39 String file; 40 41 42 43 public EFBiffViewer() 44 { 45 } 46 47 public void run() 48 throws IOException 49 { 50 FileInputStream fin = new FileInputStream (file); 51 POIFSFileSystem poifs = new POIFSFileSystem(fin); 52 InputStream din = poifs.createDocumentInputStream("Workbook"); 53 HSSFRequest req = new HSSFRequest(); 54 55 req.addListenerForAllRecords(new HSSFListener() 56 { 57 public void processRecord(Record rec) 58 { 59 System.out.println(rec.toString()); 60 } 61 }); 62 HSSFEventFactory factory = new HSSFEventFactory(); 63 64 factory.processEvents(req, din); 65 } 66 67 public void setFile(String file) 68 { 69 this.file = file; 70 } 71 72 public static void main(String [] args) 73 { 74 if ((args.length == 1) && !args[ 0 ].equals("--help")) 75 { 76 try 77 { 78 EFBiffViewer viewer = new EFBiffViewer(); 79 80 viewer.setFile(args[ 0 ]); 81 viewer.run(); 82 } 83 catch (IOException e) 84 { 85 e.printStackTrace(); 86 } 87 } 88 else 89 { 90 System.out.println("EFBiffViewer"); 91 System.out.println( 92 "Outputs biffview of records based on HSSFEventFactory"); 93 System.out 94 .println("usage: java org.apache.poi.hssf.dev.EBBiffViewer " 95 + "filename"); 96 } 97 } 98 } 99 | Popular Tags |