1 19 20 package jxl.demo; 21 22 import java.io.File ; 23 import java.io.OutputStream ; 24 import java.io.OutputStreamWriter ; 25 import java.io.BufferedWriter ; 26 import java.io.IOException ; 27 import java.io.UnsupportedEncodingException ; 28 29 import java.util.ArrayList ; 30 import java.util.Iterator ; 31 32 import jxl.Workbook; 33 import jxl.Sheet; 34 import jxl.Cell; 35 import jxl.CellFeatures; 36 import jxl.CellReferenceHelper; 37 38 42 public class Features 43 { 44 53 public Features(Workbook w, OutputStream out, String encoding) 54 throws IOException 55 { 56 if (encoding == null || !encoding.equals("UnicodeBig")) 57 { 58 encoding = "UTF8"; 59 } 60 61 try 62 { 63 OutputStreamWriter osw = new OutputStreamWriter (out, encoding); 64 BufferedWriter bw = new BufferedWriter (osw); 65 66 ArrayList parseErrors = new ArrayList (); 67 68 for (int sheet = 0; sheet < w.getNumberOfSheets(); sheet++) 69 { 70 Sheet s = w.getSheet(sheet); 71 72 bw.write(s.getName()); 73 bw.newLine(); 74 75 Cell[] row = null; 76 Cell c = null; 77 78 for (int i = 0 ; i < s.getRows() ; i++) 79 { 80 row = s.getRow(i); 81 82 for (int j = 0; j < row.length; j++) 83 { 84 c = row[j]; 85 if (c.getCellFeatures() != null) 86 { 87 CellFeatures features = c.getCellFeatures(); 88 StringBuffer sb = new StringBuffer (); 89 CellReferenceHelper.getCellReference 90 (c.getColumn(), c.getRow(), sb); 91 92 bw.write("Cell " + sb.toString() + 93 " contents: " + c.getContents()); 94 bw.flush(); 95 bw.write(" comment: " + features.getComment()); 96 bw.flush(); 97 bw.newLine(); 98 } 99 } 100 } 101 } 102 bw.flush(); 103 bw.close(); 104 } 105 catch (UnsupportedEncodingException e) 106 { 107 System.err.println(e.toString()); 108 } 109 } 110 111 } 112 113 | Popular Tags |