Exemplo n.º 1
0
        public void AddMultipleBlanks(MulBlankRecord mbr)
        {
            for (int j = 0; j < mbr.NumColumns; j++)
            {
                BlankRecord br = new BlankRecord();

                br.Column = j + mbr.FirstColumn;
                br.Row = mbr.Row;
                br.XFIndex = (mbr.GetXFAt(j));
                InsertCell(br);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the cell type. The SetValue flag indicates whether to bother about
        /// trying to preserve the current value in the new record if one is Created.
        /// The SetCellValue method will call this method with false in SetValue
        /// since it will overWrite the cell value later
        /// </summary>
        /// <param name="cellType">Type of the cell.</param>
        /// <param name="setValue">if set to <c>true</c> [set value].</param>
        /// <param name="row">The row.</param>
        /// <param name="col">The col.</param>
        /// <param name="styleIndex">Index of the style.</param>
        private void SetCellType(CellType cellType, bool setValue, int row, int col, short styleIndex)
        {
            if (cellType > CellType.ERROR)
            {
                throw new Exception("I have no idea what type that Is!");
            }
            switch (cellType)
            {

                case CellType.FORMULA:
                    FormulaRecordAggregate frec = null;

                    if (cellType != this.cellType)
                    {
                        frec = sheet.Sheet.RowsAggregate.CreateFormula(row, col);
                    }
                    else
                    {
                        frec = (FormulaRecordAggregate)record;
                    }
                    frec.Column = col;
                    if (setValue)
                    {
                        frec.FormulaRecord.Value = NumericCellValue;
                    }
                    frec.XFIndex = styleIndex;
                    frec.Row = row;
                    record = frec;
                    break;

                case CellType.NUMERIC:
                    NumberRecord nrec = null;

                    if (cellType != this.cellType)
                    {
                        nrec = new NumberRecord();
                    }
                    else
                    {
                        nrec = (NumberRecord)record;
                    }
                    nrec.Column = col;
                    if (setValue)
                    {
                        nrec.Value = NumericCellValue;
                    }
                    nrec.XFIndex = styleIndex;
                    nrec.Row = row;
                    record = nrec;
                    break;

                case CellType.STRING:
                    LabelSSTRecord lrec = null;

                    if (cellType != this.cellType)
                    {
                        lrec = new LabelSSTRecord();
                    }
                    else
                    {
                        lrec = (LabelSSTRecord)record;
                    }
                    lrec.Column = col;
                    lrec.Row = row;
                    lrec.XFIndex = styleIndex;
                    if (setValue)
                    {
                        String str = ConvertCellValueToString();
                        int sstIndex = book.Workbook.AddSSTString(new UnicodeString(str));
                        lrec.SSTIndex = (sstIndex);
                        UnicodeString us = book.Workbook.GetSSTString(sstIndex);
                        stringValue = new HSSFRichTextString();
                        stringValue.UnicodeString = us;
                    }
                    record = lrec;
                    break;

                case CellType.BLANK:
                    BlankRecord brec = null;

                    if (cellType != this.cellType)
                    {
                        brec = new BlankRecord();
                    }
                    else
                    {
                        brec = (BlankRecord)record;
                    }
                    brec.Column = col;

                    // During construction the cellStyle may be null for a Blank cell.
                    brec.XFIndex = styleIndex;
                    brec.Row = row;
                    record = brec;
                    break;

                case CellType.BOOLEAN:
                    BoolErrRecord boolRec = null;

                    if (cellType != this.cellType)
                    {
                        boolRec = new BoolErrRecord();
                    }
                    else
                    {
                        boolRec = (BoolErrRecord)record;
                    }
                    boolRec.Column = col;
                    if (setValue)
                    {
                        boolRec.SetValue(ConvertCellValueToBoolean());
                    }
                    boolRec.XFIndex = styleIndex;
                    boolRec.Row = row;
                    record = boolRec;
                    break;

                case CellType.ERROR:
                    BoolErrRecord errRec = null;

                    if (cellType != this.cellType)
                    {
                        errRec = new BoolErrRecord();
                    }
                    else
                    {
                        errRec = (BoolErrRecord)record;
                    }
                    errRec.Column = col;
                    if (setValue)
                    {
                        errRec.SetValue((byte)HSSFErrorConstants.ERROR_VALUE);
                    }
                    errRec.XFIndex = styleIndex;
                    errRec.Row = row;
                    record = errRec;
                    break;
            }
            if (cellType != this.cellType &&
                this.cellType != CellType.Unknown)  // Special Value to indicate an Uninitialized Cell
            {
                sheet.Sheet.ReplaceValueRecord(record);
            }
            this.cellType = cellType;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a BLANK record (does not Add it to the records contained in this sheet)
        /// </summary>
        /// <param name="row">the row the BlankRecord is a member of</param>
        /// <param name="col">the column the BlankRecord is a member of</param>
        /// <returns></returns>
        public BlankRecord CreateBlank(int row, short col)
        {
            //log.LogFormatted(POILogger.DEBUG, "Create blank row,col %,%", new int[]
            //{
            //    row, col
            //});
            BlankRecord rec = new BlankRecord();

            rec.Row = row;
            rec.Column = col;
            rec.XFIndex = (short)0x0f;
            return rec;
        }
Exemplo n.º 4
0
        /**
         * Converts a {@link MulBlankRecord} into an equivalent array of {@link BlankRecord}s
         */
        public static BlankRecord[] ConvertBlankRecords(MulBlankRecord mbk)
        {
            BlankRecord[] mulRecs = new BlankRecord[mbk.NumColumns];
            for (int k = 0; k < mbk.NumColumns; k++)
            {
                BlankRecord br = new BlankRecord();

                br.Column = k + mbk.FirstColumn;
                br.Row = mbk.Row;
                br.XFIndex = mbk.GetXFAt(k);
                mulRecs[k] = br;
            }
            return mulRecs;
        }
Exemplo n.º 5
0
 public override Object Clone()
 {
     BlankRecord rec = new BlankRecord();
     rec.field_1_row = field_1_row;
     rec.field_2_col = field_2_col;
     rec.field_3_xf = field_3_xf;
     return rec;
 }