Example #1
0
    /**
     * Create a new Table of the given number of rows and columns
     *
     * @param numrows the number of rows
     * @param numcols the number of columns
     */
    public Table(int numrows, int numcols) {
        base();

        if(numrows < 1) throw new ArgumentException("The number of rows must be greater than 1");
        if(numcols < 1) throw new ArgumentException("The number of columns must be greater than 1");

        int x=0, y=0, tblWidth=0, tblHeight=0;
        cells = new TableCell[numrows][numcols];
        for (int i = 0; i < cells.Length; i++) {
            x = 0;
            for (int j = 0; j < cells[i].Length; j++) {
                cells[i][j] = new TableCell(this);
                Rectangle anchor = new Rectangle(x, y, TableCell.DEFAULT_WIDTH, TableCell.DEFAULT_HEIGHT);
                cells[i][j].SetAnchor(anchor);
                x += TableCell.DEFAULT_WIDTH;
            }
            y += TableCell.DEFAULT_HEIGHT;
        }
        tblWidth = x;
        tblHeight = y;
        SetAnchor(new Rectangle(0, 0, tblWidth, tblHeight));

        EscherContainerRecord spCont = (EscherContainerRecord) GetSpContainer().GetChild(0);
        EscherOptRecord opt = new EscherOptRecord();
        opt.SetRecordId((short)0xF122);
        opt.AddEscherProperty(new EscherSimpleProperty((short)0x39F, 1));
        EscherArrayProperty p = new EscherArrayProperty((short)0x43A0, false, null);
        p.SetSizeOfElements(0x0004);
        p.SetNumberOfElementsInArray(numrows);
        p.SetNumberOfElementsInMemory(numrows);
        opt.AddEscherProperty(p);
        List<EscherRecord> lst = spCont.GetChildRecords();
        lst.Add(lst.Count-1, opt);
        spCont.SetChildRecords(lst);
    }