Esempio n. 1
0
        public override object Clone()
        {
            NumberRecord rec = new NumberRecord();

            CopyBaseFields(rec);
            rec.field_4_value = field_4_value;
            return(rec);
        }
Esempio n. 2
0
        /// <summary>
        /// RK record is a slightly smaller alternative to NumberRecord
        /// POI likes NumberRecord better
        /// </summary>
        /// <param name="rk">The rk.</param>
        /// <returns></returns>
        public static NumberRecord ConvertToNumberRecord(RKRecord rk)
        {
            NumberRecord num = new NumberRecord();

            num.Column  = (rk.Column);
            num.Row     = (rk.Row);
            num.XFIndex = (rk.XFIndex);
            num.Value   = (rk.RKNumber);
            return(num);
        }
Esempio n. 3
0
        /// <summary>
        /// Converts a MulRKRecord into an equivalent array of NumberRecords
        /// </summary>
        /// <param name="mrk">The MRK.</param>
        /// <returns></returns>
        public static NumberRecord[] ConvertRKRecords(MulRKRecord mrk)
        {
            NumberRecord[] mulRecs = new NumberRecord[mrk.NumColumns];
            for (int k = 0; k < mrk.NumColumns; k++)
            {
                NumberRecord nr = new NumberRecord();

                nr.Column  = ((short)(k + mrk.FirstColumn));
                nr.Row     = (mrk.Row);
                nr.XFIndex = (mrk.GetXFAt(k));
                nr.Value   = (mrk.GetRKNumberAt(k));
                mulRecs[k] = nr;
            }
            return(mulRecs);
        }
Esempio n. 4
0
        public void TestHeaderFooter_bug46840()
        {

            int rowIx = 5;
            int colIx = 6;
            NumberRecord nr = new NumberRecord();
            nr.Row = (rowIx);
            nr.Column = ((short)colIx);
            nr.Value = (3.0);

            NPOI.HSSF.Record.Record[] recs = {
				BOFRecord.CreateSheetBOF(),
				new HeaderRecord("&LSales Figures"),
				new FooterRecord("&LJanuary"),
				new HeaderFooterRecord(HexRead.ReadFromString("9C 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C4 60 00 00 00 00 00 00 00 00")),
				new DimensionsRecord(),
				new WindowTwoRecord(),
				new UserSViewBegin(HexRead.ReadFromString("ED 77 3B 86 BC 3F 37 4C A9 58 60 23 43 68 54 4B 01 00 00 00 64 00 00 00 40 00 00 00 02 00 00 00 3D 80 04 00 00 00 00 00 00 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F0 3F FF FF 01 00")),
				new HeaderRecord("&LSales Figures"),
				new FooterRecord("&LJanuary"),
				new HeaderFooterRecord(HexRead.ReadFromString("9C 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C4 60 00 00 00 00 00 00 00 00")),
				new UserSViewEnd(HexRead.ReadFromString("01, 00")),

				EOFRecord.instance,
		};
            RecordStream rs = new RecordStream(Arrays.AsList(recs), 0);
            InternalSheet sheet;
            try
            {
                sheet = InternalSheet.CreateSheet(rs);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("two Page Settings Blocks found in the same sheet"))
                {
                    throw new AssertionException("Identified bug 46480");
                }
                throw e;
            }

            TestCases.HSSF.UserModel.RecordInspector.RecordCollector rv = new TestCases.HSSF.UserModel.RecordInspector.RecordCollector();
            sheet.VisitContainedRecords(rv, rowIx);
            NPOI.HSSF.Record.Record[] outRecs = rv.Records;
            Assert.AreEqual(13, outRecs.Length);
        }
Esempio n. 5
0
        public void TestMissingDims()
        {

            int rowIx = 5;
            int colIx = 6;
            NumberRecord nr = new NumberRecord();
            nr.Row = (rowIx);
            nr.Column = ((short)colIx);
            nr.Value = (3.0);

            ArrayList inRecs = new ArrayList();
            inRecs.Add(BOFRecord.CreateSheetBOF());
            inRecs.Add(new RowRecord(rowIx));
            inRecs.Add(nr);
            inRecs.Add(CreateWindow2Record());
            inRecs.Add(EOFRecord.instance);
            InternalSheet sheet;
            try
            {
                sheet = CreateSheet(inRecs);
            }
            catch (Exception e)
            {
                if ("DimensionsRecord was not found".Equals(e.Message))
                {
                    throw new AssertionException("Identified bug 46206");
                }
                throw e;
            }

            RecordInspector.RecordCollector rv = new RecordInspector.RecordCollector();
            sheet.VisitContainedRecords(rv, rowIx);
            Record[] outRecs = rv.Records;
            Assert.AreEqual(8, outRecs.Length);
            DimensionsRecord dims = (DimensionsRecord)outRecs[5];
            Assert.AreEqual(rowIx, dims.FirstRow);
            Assert.AreEqual(rowIx, dims.LastRow);
            Assert.AreEqual(colIx, dims.FirstCol);
            Assert.AreEqual(colIx, dims.LastCol);
        }
Esempio n. 6
0
 public override object Clone()
 {
     NumberRecord rec = new NumberRecord();
     CopyBaseFields(rec);
     rec.field_4_value = field_4_value;
     return rec;
 }
Esempio n. 7
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;
        }
Esempio n. 8
0
        /// <summary>
        /// Create a NUMBER Record (does not Add it to the records contained in this sheet)
        /// </summary>
        /// <param name="row">the row the NumberRecord is a member of</param>
        /// <param name="col">the column the NumberRecord defines</param>
        /// <param name="value">value for the number record</param>
        /// <returns>NumberRecord for that row, col containing that value as Added to the sheet</returns>
        public NumberRecord CreateNumber(int row, short col, double value)
        {
            //log.LogFormatted(POILogger.DEBUG, "Create number row,col,value %,%,%",
            //                 new double[]
            //{
            //    row, col, value
            //});
            NumberRecord rec = new NumberRecord();

            rec.Row = row;
            rec.Column = col;
            rec.Value = value;
            rec.XFIndex = (short)0x0f;
            return rec;
        }
Esempio n. 9
0
        /// <summary>
        /// Converts a MulRKRecord into an equivalent array of NumberRecords
        /// </summary>
        /// <param name="mrk">The MRK.</param>
        /// <returns></returns>
        public static NumberRecord[] ConvertRKRecords(MulRKRecord mrk)
        {

            NumberRecord[] mulRecs = new NumberRecord[mrk.NumColumns];
            for (int k = 0; k < mrk.NumColumns; k++)
            {
                NumberRecord nr = new NumberRecord();

                nr.Column = ((short)(k + mrk.FirstColumn));
                nr.Row = (mrk.Row);
                nr.XFIndex = (mrk.GetXFAt(k));
                nr.Value = (mrk.GetRKNumberAt(k));
                mulRecs[k] = nr;
            }
            return mulRecs;
        }
Esempio n. 10
0
        /// <summary>
        /// RK record is a slightly smaller alternative to NumberRecord
        /// POI likes NumberRecord better
        /// </summary>
        /// <param name="rk">The rk.</param>
        /// <returns></returns>
        public static NumberRecord ConvertToNumberRecord(RKRecord rk)
        {
            NumberRecord num = new NumberRecord();

            num.Column = (rk.Column);
            num.Row = (rk.Row);
            num.XFIndex = (rk.XFIndex);
            num.Value = (rk.RKNumber);
            return num;
        }
Esempio n. 11
0
        public void TestLateHeaderFooter_bug46953()
        {

            int rowIx = 5;
            int colIx = 6;
            NumberRecord nr = new NumberRecord();
            nr.Row = (rowIx);
            nr.Column = ((short)colIx);
            nr.Value = (3.0);

            NPOI.HSSF.Record.Record[] recs = {
				BOFRecord.CreateSheetBOF(),
				new HeaderRecord("&LSales Figures"),
				new FooterRecord("&LJanuary"),
				new DimensionsRecord(),
				new WindowTwoRecord(),
				new HeaderFooterRecord(HexRead.ReadFromString("9C 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C4 60 00 00 00 00 00 00 00 00")),
				EOFRecord.instance,
		};
            RecordStream rs = new RecordStream(Arrays.AsList(recs), 0);
            InternalSheet sheet = InternalSheet.CreateSheet(rs);

            RecordInspector.RecordCollector rv = new RecordInspector.RecordCollector();
            sheet.VisitContainedRecords(rv, 0);
            NPOI.HSSF.Record.Record[] outRecs = rv.Records;
            if (outRecs[4] == EOFRecord.instance)
            {
                throw new AssertionException("Identified bug 46953 - EOF incorrectly Appended to PSB");
            }
            Assert.AreEqual(recs.Length + 1, outRecs.Length); // +1 for index record

            Assert.AreEqual(typeof(BOFRecord), outRecs[0].GetType());
            Assert.AreEqual(typeof(IndexRecord), outRecs[1].GetType());
            Assert.AreEqual(typeof(HeaderRecord), outRecs[2].GetType());
            Assert.AreEqual(typeof(FooterRecord), outRecs[3].GetType());
            Assert.AreEqual(typeof(HeaderFooterRecord), outRecs[4].GetType());
            Assert.AreEqual(typeof(DimensionsRecord), outRecs[5].GetType());
            Assert.AreEqual(typeof(WindowTwoRecord), outRecs[6].GetType());
            Assert.AreEqual(typeof(EOFRecord), outRecs[7].GetType());
        }
Esempio n. 12
0
//temporarily just constructs a new number record and returns its value
    public override int Serialize(int offset, byte [] data)
    {
        NumberRecord rec = new NumberRecord();

        rec.Column=Column;
        rec.Row=Row;
        rec.Value=RKNumber;
        rec.XFIndex=XFIndex;
        return rec.Serialize(offset, data);
    }