1 19 20 package jxl.write.biff; 21 22 import java.util.ArrayList ; 23 import java.util.Iterator ; 24 25 import common.Assert; 26 import jxl.CellType; 27 import jxl.Range; 28 import jxl.Cell; 29 import jxl.write.Blank; 30 import jxl.write.WritableSheet; 31 import jxl.write.WritableCell; 32 import jxl.write.WritableHyperlink; 33 import jxl.write.WriteException; 34 import jxl.biff.IntegerHelper; 35 import jxl.biff.StringHelper; 36 import jxl.biff.CellReferenceHelper; 37 import jxl.biff.WritableRecordData; 38 import jxl.biff.Type; 39 import jxl.biff.SheetRangeImpl; 40 41 45 public class MergedCellsRecord extends WritableRecordData 46 { 47 50 private ArrayList ranges; 51 52 57 protected MergedCellsRecord(ArrayList mc) 58 { 59 super(Type.MERGEDCELLS); 60 61 ranges = mc; 62 } 63 64 69 public byte[] getData() 70 { 71 byte[] data = new byte[ranges.size() * 8 + 2]; 72 73 IntegerHelper.getTwoBytes(ranges.size(), data, 0); 75 76 int pos = 2; 77 Range range = null; 78 for (int i = 0; i < ranges.size() ; i++) 79 { 80 range = (Range) ranges.get(i); 81 82 Cell tl = range.getTopLeft(); 84 Cell br = range.getBottomRight(); 85 86 IntegerHelper.getTwoBytes(tl.getRow(), data, pos); 87 IntegerHelper.getTwoBytes(br.getRow(), data, pos+2); 88 IntegerHelper.getTwoBytes(tl.getColumn(), data, pos+4); 89 IntegerHelper.getTwoBytes(br.getColumn(), data, pos+6); 90 91 pos += 8; 92 } 93 94 return data; 95 } 96 97 } 98 99 100 101 102 103 104 105 | Popular Tags |