public void TestExtraStringRecord_bug46213()
        {
            FormulaRecord fr = new FormulaRecord();
            fr.Value = (2.0);
            StringRecord sr = new StringRecord();
            sr.String = ("NA");
            SharedValueManager svm = SharedValueManager.CreateEmpty();
            FormulaRecordAggregate fra;

            try
            {
                fra = new FormulaRecordAggregate(fr, sr, svm);
            }
            catch (RecordFormatException e)
            {
                if ("String record was  supplied but formula record flag is not  set".Equals(e.Message))
                {
                    throw new AssertionException("Identified bug 46213");
                }
                throw e;
            }
            TestCases.HSSF.UserModel.RecordInspector.RecordCollector rc = new TestCases.HSSF.UserModel.RecordInspector.RecordCollector();
            fra.VisitContainedRecords(rc);
            Record[] vraRecs = rc.Records;
            Assert.AreEqual(1, vraRecs.Length);
            Assert.AreEqual(fr, vraRecs[0]);
        }
示例#2
0
        public void TestExtraStringRecord_bug46213()
        {
            FormulaRecord fr = new FormulaRecord();

            fr.Value = (2.0);
            StringRecord sr = new StringRecord();

            sr.String = ("NA");
            SharedValueManager     svm = SharedValueManager.CreateEmpty();
            FormulaRecordAggregate fra;

            try
            {
                fra = new FormulaRecordAggregate(fr, sr, svm);
            }
            catch (RecordFormatException e)
            {
                if ("String record was  supplied but formula record flag is not  set".Equals(e.Message))
                {
                    throw new AssertionException("Identified bug 46213");
                }
                throw e;
            }
            TestCases.HSSF.UserModel.RecordInspector.RecordCollector rc = new TestCases.HSSF.UserModel.RecordInspector.RecordCollector();
            fra.VisitContainedRecords(rc);
            Record[] vraRecs = rc.Records;
            Assert.AreEqual(1, vraRecs.Length);
            Assert.AreEqual(fr, vraRecs[0]);
        }
示例#3
0
        public void TestProtectSheetRecordOrder_bug47363a()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFSheet    s  = (HSSFSheet)wb.CreateSheet();

            s.ProtectSheet("secret");
            TestCases.HSSF.UserModel.RecordInspector.RecordCollector rc = new TestCases.HSSF.UserModel.RecordInspector.RecordCollector();
            s.Sheet.VisitContainedRecords(rc, 0);
            Record[] recs  = rc.Records;
            int      nRecs = recs.Length;

            if (recs[nRecs - 2] is PasswordRecord && recs[nRecs - 5] is DimensionsRecord)
            {
                throw new AssertionException("Identified bug 47363a - PASSWORD after DIMENSION");
            }
            // Check that protection block is together, and before DIMENSION
            //ConfirmRecordClass(recs, nRecs - 4, typeof(DimensionsRecord));
            //ConfirmRecordClass(recs, nRecs - 9, typeof(ProtectRecord));
            //ConfirmRecordClass(recs, nRecs - 8, typeof(ObjectProtectRecord));
            //ConfirmRecordClass(recs, nRecs - 7, typeof(ScenarioProtectRecord));
            //ConfirmRecordClass(recs, nRecs - 6, typeof(PasswordRecord));

            ConfirmRecordClass(recs, nRecs - 5, typeof(DimensionsRecord));
            ConfirmRecordClass(recs, nRecs - 10, typeof(ProtectRecord));
            ConfirmRecordClass(recs, nRecs - 9, typeof(ObjectProtectRecord));
            ConfirmRecordClass(recs, nRecs - 8, typeof(ScenarioProtectRecord));
            ConfirmRecordClass(recs, nRecs - 7, typeof(PasswordRecord));
        }
示例#4
0
        public void TestCloneMulBlank_bug46776()
        {
            Record[] recs =
            {
                InternalSheet.CreateBOF(),
                new DimensionsRecord(),
                new RowRecord(1),
                new MulBlankRecord(1, 3, new short[] { 0x0F, 0x0F, 0x0F, }),
                new RowRecord(2),
                CreateWindow2Record(),
                EOFRecord.instance,
            };

            InternalSheet sheet = CreateSheet(recs.ToList());

            InternalSheet sheet2;

            try
            {
                sheet2 = sheet.CloneSheet();
            }
            catch (Exception e)
            {
                if (e.Message.Equals("The class org.apache.poi.hssf.record.MulBlankRecord needs to define a clone method"))
                {
                    throw new AssertionException("Identified bug 46776");
                }
                throw e;
            }

            TestCases.HSSF.UserModel.RecordInspector.RecordCollector rc = new TestCases.HSSF.UserModel.RecordInspector.RecordCollector();
            sheet2.VisitContainedRecords(rc, 0);
            Record[] clonedRecs = rc.Records;
            Assert.AreEqual(recs.Length + 2, clonedRecs.Length); // +2 for INDEX and DBCELL
        }
示例#5
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);
        }
示例#6
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);
            Sheet sheet;

            try
            {
                sheet = CreateSheet(inRecs);
            }
            catch (Exception e)
            {
                if ("DimensionsRecord was not found".Equals(e.Message))
                {
                    throw new AssertFailedException("Identified bug 46206");
                }
                throw e;
            }

            TestCases.HSSF.UserModel.RecordInspector.RecordCollector rv = new TestCases.HSSF.UserModel.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);
        }
示例#7
0
        public void TestLateMargins_bug47199()
        {
            NPOI.HSSF.Record.Record[] recs =
            {
                BOFRecord.CreateSheetBOF(),
                new HeaderRecord("&LSales Figures"),
                new FooterRecord("&LJanuary"),
                new DimensionsRecord(),
                CreateBottomMargin(0.787F),
                new WindowTwoRecord(),
                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 47199a - failed to process late margings records");
                }
                throw e;
            }

            TestCases.HSSF.UserModel.RecordInspector.RecordCollector rv = new TestCases.HSSF.UserModel.RecordInspector.RecordCollector();
            sheet.VisitContainedRecords(rv, 0);
            NPOI.HSSF.Record.Record[] outRecs = rv.Records;
            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(DimensionsRecord), outRecs[5].GetType());
            Assert.AreEqual(typeof(WindowTwoRecord), outRecs[6].GetType());
            Assert.AreEqual(typeof(EOFRecord), outRecs[7].GetType());
        }
示例#8
0
文件: TestSheet.cs 项目: 89sos98/npoi
        public void TestCloneMulBlank_bug46776()
        {
            Record[] recs = {
				InternalSheet.CreateBOF(),
				new DimensionsRecord(),
				new RowRecord(1),
				new MulBlankRecord(1, 3, new short[] { 0x0F, 0x0F, 0x0F, } ),
				new RowRecord(2),
				CreateWindow2Record(),
				EOFRecord.instance,
		};

            InternalSheet sheet = CreateSheet(NPOI.Util.Arrays.AsList(recs));

            InternalSheet sheet2;
            try
            {
                sheet2 = sheet.CloneSheet();
            }
            catch (Exception e)
            {
                if (e.Message.Equals("The class org.apache.poi.hssf.record.MulBlankRecord needs to define a clone method"))
                {
                    throw new AssertionException("Identified bug 46776");
                }
                throw e;
            }

            TestCases.HSSF.UserModel.RecordInspector.RecordCollector rc = new TestCases.HSSF.UserModel.RecordInspector.RecordCollector();
            sheet2.VisitContainedRecords(rc, 0);
            Record[] clonedRecs = rc.Records;
            Assert.AreEqual(recs.Length + 2, clonedRecs.Length); // +2 for INDEX and DBCELL
        }
示例#9
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);
        }
示例#10
0
        public void TestLateMargins_bug47199()
        {

            NPOI.HSSF.Record.Record[] recs = {
				BOFRecord.CreateSheetBOF(),
				new HeaderRecord("&LSales Figures"),
				new FooterRecord("&LJanuary"),
				new DimensionsRecord(),
				CreateBottomMargin(0.787F),
				new WindowTwoRecord(),
				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 47199a - failed to process late margings records");
                }
                throw e;
            }

            TestCases.HSSF.UserModel.RecordInspector.RecordCollector rv = new TestCases.HSSF.UserModel.RecordInspector.RecordCollector();
            sheet.VisitContainedRecords(rv, 0);
            NPOI.HSSF.Record.Record[] outRecs = rv.Records;
            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(DimensionsRecord), outRecs[5].GetType());
            Assert.AreEqual(typeof(WindowTwoRecord), outRecs[6].GetType());
            Assert.AreEqual(typeof(EOFRecord), outRecs[7].GetType());
        }
示例#11
0
        public void TestProtectSheetRecordOrder_bug47363a()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFSheet s = (HSSFSheet)wb.CreateSheet();
            s.ProtectSheet("secret");
            TestCases.HSSF.UserModel.RecordInspector.RecordCollector rc = new TestCases.HSSF.UserModel.RecordInspector.RecordCollector();
            s.Sheet.VisitContainedRecords(rc, 0);
            Record[] recs = rc.Records;
            int nRecs = recs.Length;
            if (recs[nRecs - 2] is PasswordRecord && recs[nRecs - 5] is DimensionsRecord)
            {
                throw new AssertionException("Identified bug 47363a - PASSWORD after DIMENSION");
            }
            // Check that protection block is together, and before DIMENSION
            //ConfirmRecordClass(recs, nRecs - 4, typeof(DimensionsRecord));
            //ConfirmRecordClass(recs, nRecs - 9, typeof(ProtectRecord));
            //ConfirmRecordClass(recs, nRecs - 8, typeof(ObjectProtectRecord));
            //ConfirmRecordClass(recs, nRecs - 7, typeof(ScenarioProtectRecord));
            //ConfirmRecordClass(recs, nRecs - 6, typeof(PasswordRecord));

            ConfirmRecordClass(recs, nRecs - 5, typeof(DimensionsRecord));
            ConfirmRecordClass(recs, nRecs - 10, typeof(ProtectRecord));
            ConfirmRecordClass(recs, nRecs - 9, typeof(ObjectProtectRecord));
            ConfirmRecordClass(recs, nRecs - 8, typeof(ScenarioProtectRecord));
            ConfirmRecordClass(recs, nRecs - 7, typeof(PasswordRecord));
        }