1 16 17 18 package org.apache.poi.hssf.usermodel; 19 20 import org.apache.poi.hssf.record.FooterRecord; 21 22 34 public class HSSFFooter extends Object { 35 36 FooterRecord footerRecord; 37 String left; 38 String center; 39 String right; 40 41 45 protected HSSFFooter(FooterRecord footerRecord) { 46 this.footerRecord = footerRecord; 47 String foot = footerRecord.getFooter(); 48 while (foot != null && foot.length() > 1) { 49 int pos = foot.length(); 50 switch (foot.substring(1, 2).charAt(0)) { 51 case 'L' : 52 if (foot.indexOf("&C") >= 0) { 53 pos = Math.min(pos, foot.indexOf("&C")); 54 } 55 if (foot.indexOf("&R") >= 0) { 56 pos = Math.min(pos, foot.indexOf("&R")); 57 } 58 left = foot.substring(2, pos); 59 foot = foot.substring(pos); 60 break; 61 case 'C' : 62 if (foot.indexOf("&L") >= 0) { 63 pos = Math.min(pos, foot.indexOf("&L")); 64 } 65 if (foot.indexOf("&R") >= 0) { 66 pos = Math.min(pos, foot.indexOf("&R")); 67 } 68 center = foot.substring(2, pos); 69 foot = foot.substring(pos); 70 break; 71 case 'R' : 72 if (foot.indexOf("&C") >= 0) { 73 pos = Math.min(pos, foot.indexOf("&C")); 74 } 75 if (foot.indexOf("&L") >= 0) { 76 pos = Math.min(pos, foot.indexOf("&L")); 77 } 78 right = foot.substring(2, pos); 79 foot = foot.substring(pos); 80 break; 81 default : foot = null; 82 } 83 } 84 } 85 86 90 public String getLeft() { 91 return left; 92 } 93 94 98 public void setLeft(String newLeft) { 99 left = newLeft; 100 createFooterString(); 101 } 102 103 107 public String getCenter() { 108 return center; 109 } 110 111 115 public void setCenter(String newCenter) { 116 center = newCenter; 117 createFooterString(); 118 } 119 120 124 public String getRight() { 125 return right; 126 } 127 128 132 public void setRight(String newRight) { 133 right = newRight; 134 createFooterString(); 135 } 136 137 141 private void createFooterString() { 142 footerRecord.setFooter( 143 "&C" + (center == null ? "" : center) + 144 "&L" + (left == null ? "" : left) + 145 "&R" + (right == null ? "" : right)); 146 footerRecord.setFooterLength((byte)footerRecord.getFooter().length()); 147 } 148 149 154 public static String fontSize(short size) { 155 return "&" + size; 156 } 157 158 164 public static String font(String font, String style) { 165 return "&\"" + font + "," + style + "\""; 166 } 167 168 172 public static String page() { 173 return "&P"; 174 } 175 176 180 public static String numPages() { 181 return "&N"; 182 } 183 184 188 public static String date() { 189 return "&D"; 190 } 191 192 196 public static String time() { 197 return "&T"; 198 } 199 200 204 public static String file() { 205 return "&F"; 206 } 207 208 212 public static String tab() { 213 return "&A"; 214 } 215 } 216 217 | Popular Tags |