Exemplo n.º 1
0
        public virtual void ExcelService_AddValidations_LotsOfItems()
        {
            var oldNames = new[]
            {
                new NamedRange
                {
                    Name  = "testName3",
                    Range = new Range(0, 99, 0, 0, "testName4")
                }
            };

            var oldValidations = new[]
            {
                new DataValidation
                {
                    Name  = "testName3",
                    Type  = DataValidationType.Formula,
                    Range = new Range()
                }
            };

            ExcelService.AddNames(MemoryToDiskObject, _version, oldNames);
            ExcelService.AddValidations(MemoryToDiskObject, "testSheet5", _version, oldValidations);
            ExcelService.SaveWorkbook(MemoryToDiskObject, _newFileName);
            var newWorkbook    = ExcelService.ReadWorkbook(_newFileName);
            var newNames       = newWorkbook.Names;
            var newValidations = newWorkbook.Worksheets.First().Validations;

            AssertHelper.AreDeeplyEqual(oldNames, newNames);
            AssertHelper.AreDeeplyEqual(oldValidations, newValidations);
        }
Exemplo n.º 2
0
        public void ExcelHelper_ParseRange_Max_Xlsx()
        {
            var expected = new Range(2, null, 5, null, "testSheet34");

            var actual = ExcelHelper.ParseRange("testSheet34!$F$3:$XFD$1048576", ExcelVersion.Xlsx);

            AssertHelper.AreDeeplyEqual(expected, actual);
        }
Exemplo n.º 3
0
        public void ExcelHelper_ParseRange_DetectAllColumns_Xlsx()
        {
            var expected = new Range(64, 343, null, null, "testSheet34");

            var actual = ExcelHelper.ParseRange("testSheet34!$A$65:$XFD$344", ExcelVersion.Xlsx);

            AssertHelper.AreDeeplyEqual(expected, actual);
        }
Exemplo n.º 4
0
        public void ExcelHelper_ParseRange_DetectAllRows_Xlsx()
        {
            var expected = new Range(null, null, 2, 7, "testSheet34");

            var actual = ExcelHelper.ParseRange("testSheet34!$C1:$H1048576", ExcelVersion.Xlsx);

            AssertHelper.AreDeeplyEqual(expected, actual);
        }
Exemplo n.º 5
0
        public void ExcelHelper_ParseRange_NoRows()
        {
            var expected = new Range(null, null, 2, 7, "testSheet34");

            var actual = ExcelHelper.ParseRange("testSheet34!$C:$H", ExcelVersion.Xls);

            AssertHelper.AreDeeplyEqual(expected, actual);
        }
Exemplo n.º 6
0
        public void ExcelHelper_ParseRange_NoColumn()
        {
            var expected = new Range(6, 6, null, null);

            var actual = ExcelHelper.ParseRange("7", ExcelVersion.Xlsx);

            AssertHelper.AreDeeplyEqual(expected, actual);
        }
Exemplo n.º 7
0
        public void ExcelHelper_ParseRange_NoRow()
        {
            var expected = new Range(null, null, 24, 24);

            var actual = ExcelHelper.ParseRange("Y", ExcelVersion.Xls);

            AssertHelper.AreDeeplyEqual(expected, actual);
        }
Exemplo n.º 8
0
        public void ExcelHelper_ParseRange_IncludingSheetName()
        {
            var expected = new Range(33, 37, 2, 7, "testSheet34");

            var actual = ExcelHelper.ParseRange("testSheet34!$C$34:$H$38", ExcelVersion.Xls);

            AssertHelper.AreDeeplyEqual(expected, actual);
        }
Exemplo n.º 9
0
        public virtual void ExcelService_AddValidations_Hack()
        {
            ExcelService.AddValidations(MemoryToDiskObject, "testSheet5", _version, _validations);
            ExcelService.SaveWorkbook(MemoryToDiskObject, _newFileName);
            var newWorkbook    = ExcelService.ReadWorkbook(_newFileName);
            var newValidations = newWorkbook.Worksheets.First().Validations;

            AssertHelper.AreDeeplyEqual(_validations, newValidations);
        }
Exemplo n.º 10
0
        public void ExcelHelper_ParseRange_SingleCell()
        {
            var expected = new Range
            {
                RowStart    = 33,
                RowEnd      = 33,
                ColumnStart = 2,
                ColumnEnd   = 2
            };

            var actual = ExcelHelper.ParseRange("C34", ExcelVersion.Xlsx);

            AssertHelper.AreDeeplyEqual(expected, actual);
        }
Exemplo n.º 11
0
        public void ExcelHelper_ParseRange()
        {
            var expected = new Range
            {
                RowStart    = 33,
                RowEnd      = 37,
                ColumnStart = 0,
                ColumnEnd   = 7
            };

            var actual = ExcelHelper.ParseRange("A34:H38", ExcelVersion.Xls);

            AssertHelper.AreDeeplyEqual(expected, actual);
        }
Exemplo n.º 12
0
        public virtual void ExcelService_AddValidations()
        {
            var oldValidations = MemoryWorkbook.Worksheets.First().Validations;

            foreach (var validation in _validations)
            {
                oldValidations.Add(validation);
            }

            ExcelService.WriteWorkbook(MemoryWorkbook, _version, _newFileName);
            var newWorkbook    = ExcelService.ReadWorkbook(_newFileName);
            var newValidations = newWorkbook.Worksheets.First().Validations;

            AssertHelper.AreDeeplyEqual(oldValidations, newValidations);
        }