当前位置: 首页>>代码示例>>C#>>正文


C# XSSFWorkbook.Close方法代码示例

本文整理汇总了C#中NPOI.XSSF.UserModel.XSSFWorkbook.Close方法的典型用法代码示例。如果您正苦于以下问题:C# XSSFWorkbook.Close方法的具体用法?C# XSSFWorkbook.Close怎么用?C# XSSFWorkbook.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NPOI.XSSF.UserModel.XSSFWorkbook的用法示例。


在下文中一共展示了XSSFWorkbook.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: XSSFTextParagraph_


//.........这里部分代码省略.........
                text.BulletFontSize = (/*setter*/-9.0);
                Assert.AreEqual(-9.0, text.BulletFontSize, 0.01);

                Assert.AreEqual(0.0, text.Indent, 0.01);
                text.Indent = (/*setter*/2.0);
                Assert.AreEqual(2.0, text.Indent, 0.01);
                text.Indent = (/*setter*/-1.0);
                Assert.AreEqual(0.0, text.Indent, 0.01);
                text.Indent = (/*setter*/-1.0);
                Assert.AreEqual(0.0, text.Indent, 0.01);

                Assert.AreEqual(0.0, text.LeftMargin, 0.01);
                text.LeftMargin = (/*setter*/3.0);
                Assert.AreEqual(3.0, text.LeftMargin, 0.01);
                text.LeftMargin = (/*setter*/-1.0);
                Assert.AreEqual(0.0, text.LeftMargin, 0.01);
                text.LeftMargin = (/*setter*/-1.0);
                Assert.AreEqual(0.0, text.LeftMargin, 0.01);

                Assert.AreEqual(0.0, text.RightMargin, 0.01);
                text.RightMargin = (/*setter*/4.5);
                Assert.AreEqual(4.5, text.RightMargin, 0.01);
                text.RightMargin = (/*setter*/-1.0);
                Assert.AreEqual(0.0, text.RightMargin, 0.01);
                text.RightMargin = (/*setter*/-1.0);
                Assert.AreEqual(0.0, text.RightMargin, 0.01);

                Assert.AreEqual(0.0, text.DefaultTabSize, 0.01);

                Assert.AreEqual(0.0, text.GetTabStop(0), 0.01);
                text.AddTabStop(3.14);
                Assert.AreEqual(3.14, text.GetTabStop(0), 0.01);

                Assert.AreEqual(100.0, text.LineSpacing, 0.01);
                text.LineSpacing = (/*setter*/3.15);
                Assert.AreEqual(3.15, text.LineSpacing, 0.01);
                text.LineSpacing = (/*setter*/-2.13);
                Assert.AreEqual(-2.13, text.LineSpacing, 0.01);

                Assert.AreEqual(0.0, text.SpaceBefore, 0.01);
                text.SpaceBefore = (/*setter*/3.17);
                Assert.AreEqual(3.17, text.SpaceBefore, 0.01);
                text.SpaceBefore = (/*setter*/-4.7);
                Assert.AreEqual(-4.7, text.SpaceBefore, 0.01);

                Assert.AreEqual(0.0, text.SpaceAfter, 0.01);
                text.SpaceAfter = (/*setter*/6.17);
                Assert.AreEqual(6.17, text.SpaceAfter, 0.01);
                text.SpaceAfter = (/*setter*/-8.17);
                Assert.AreEqual(-8.17, text.SpaceAfter, 0.01);

                Assert.AreEqual(0, text.Level);
                text.Level = (/*setter*/1);
                Assert.AreEqual(1, text.Level);
                text.Level = (/*setter*/4);
                Assert.AreEqual(4, text.Level);

                Assert.IsTrue(text.IsBullet);
                Assert.IsFalse(text.IsBulletAutoNumber);
                text.IsBullet = (false);
                text.IsBullet = (false);
                Assert.IsFalse(text.IsBullet);
                Assert.IsFalse(text.IsBulletAutoNumber);
                text.IsBullet = (true);
                Assert.IsTrue(text.IsBullet);
                Assert.IsFalse(text.IsBulletAutoNumber);
                Assert.AreEqual(0, text.BulletAutoNumberStart);
                Assert.AreEqual(ListAutoNumber.ARABIC_PLAIN, text.BulletAutoNumberScheme);

                text.IsBullet = (false);
                Assert.IsFalse(text.IsBullet);
                text.SetBullet(ListAutoNumber.CIRCLE_NUM_DB_PLAIN);
                Assert.IsTrue(text.IsBullet);
                Assert.IsTrue(text.IsBulletAutoNumber);
                
                //Assert.AreEqual(0, text.BulletAutoNumberStart);
                //This value should be 1, see CT_TextAutonumberBullet.startAt, default value is 1;
                Assert.AreEqual(1, text.BulletAutoNumberStart);


                Assert.AreEqual(ListAutoNumber.CIRCLE_NUM_DB_PLAIN, text.BulletAutoNumberScheme);
                text.IsBullet = (false);
                Assert.IsFalse(text.IsBullet);
                Assert.IsFalse(text.IsBulletAutoNumber);
                text.SetBullet(ListAutoNumber.CIRCLE_NUM_WD_BLACK_PLAIN, 10);
                Assert.IsTrue(text.IsBullet);
                Assert.IsTrue(text.IsBulletAutoNumber);
                Assert.AreEqual(10, text.BulletAutoNumberStart);
                Assert.AreEqual(ListAutoNumber.CIRCLE_NUM_WD_BLACK_PLAIN, text.BulletAutoNumberScheme);


                Assert.IsNotNull(text.ToString());

                new XSSFTextParagraph(text.GetXmlObject(), shape.GetCTShape());
            }
            finally
            {
                wb.Close();
            }
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:101,代码来源:TestXSSFTextParagraph.cs

示例2: TestBug56835CellComment

        public void TestBug56835CellComment()
        {
            XSSFWorkbook wb = new XSSFWorkbook();
            try
            {
                XSSFSheet sheet = wb.CreateSheet() as XSSFSheet;
                XSSFDrawing Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;

                // first comment works
                IClientAnchor anchor = new XSSFClientAnchor(1, 1, 2, 2, 3, 3, 4, 4);
                XSSFComment comment = Drawing.CreateCellComment(anchor) as XSSFComment;
                Assert.IsNotNull(comment);

                try
                {
                    Drawing.CreateCellComment(anchor);
                    Assert.Fail("Should fail if we try to add the same comment for the same cell");
                }
                catch (ArgumentException e)
                {
                    // expected
                }
            }
            finally
            {
                wb.Close();
            }
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:28,代码来源:TestXSSFDrawing.cs

示例3: TestListOfCustomProperties

        public void TestListOfCustomProperties()
        {
            FileInfo inp = POIDataSamples.GetSpreadSheetInstance().GetFileInfo("ExcelWithAttachments.xlsm");
            OPCPackage pkg = OPCPackage.Open(inp, PackageAccess.READ);
            XSSFWorkbook wb = new XSSFWorkbook(pkg);

            Assert.IsNotNull(wb.GetProperties());
            Assert.IsNotNull(wb.GetProperties().CustomProperties);

            foreach (CT_Property prop in wb.GetProperties().CustomProperties.GetUnderlyingProperties().GetPropertyList())
            {
                Assert.IsNotNull(prop);
            }

            wb.Close();
            pkg.Close();
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:17,代码来源:TestPackageCoreProperties.cs

示例4: Bug57880

        public void Bug57880()
        {
            Console.WriteLine("long time test, run over 1 minute.");
            int numStyles = 33000;
            XSSFWorkbook wb = new XSSFWorkbook();
            XSSFSheet s = wb.CreateSheet("TestSheet") as XSSFSheet;
            XSSFDataFormat fmt = wb.GetCreationHelper().CreateDataFormat() as XSSFDataFormat;
            for (int i = 1; i < numStyles; i++)
            {
                short df = fmt.GetFormat("test" + i);
                // Format indexes will be wrapped beyond 32,676
                Assert.AreEqual(164 + i, df & 0xffff);
                // Create a style and use it
                XSSFCellStyle style = wb.CreateCellStyle() as XSSFCellStyle;
                Assert.AreEqual(i, style.UIndex);
                style.DataFormat = (/*setter*/df);
                XSSFCell c = s.CreateRow(i).CreateCell(0, CellType.Numeric) as XSSFCell;
                c.CellStyle = (/*setter*/style);
                c.SetCellValue(i);
            }

            //wb = XSSFTestDataSamples.WriteOutAndReadBack(wb) as XSSFWorkbook;
            // using temp file instead of ByteArrayOutputStream because of OOM in gump run
            FileInfo tmp = TempFile.CreateTempFile("poi-test", ".bug57880");
            FileStream fos = new FileStream(tmp.FullName, FileMode.Create, FileAccess.ReadWrite);
            wb.Write(fos);
            fos.Close();

            wb.Close();
            fmt = null; s = null; wb = null;
            // System.gc();

            wb = new XSSFWorkbook(tmp.FullName);
            fmt = wb.GetCreationHelper().CreateDataFormat() as XSSFDataFormat;
            s = wb.GetSheetAt(0) as XSSFSheet;
            for (int i = 1; i < numStyles; i++)
            {
                XSSFCellStyle style = wb.GetCellStyleAt((short)i) as XSSFCellStyle;
                Assert.IsNotNull(style);
                Assert.AreEqual(i, style.UIndex);
                Assert.AreEqual(164 + i, style.DataFormat & 0xffff);
                Assert.AreEqual("test" + i, style.GetDataFormatString());
            }

            wb.Close();
            tmp.Delete();
        }
开发者ID:runningwater,项目名称:npoi,代码行数:47,代码来源:TestXSSFBugs.cs

示例5: TestXSSFTextParagraph


//.........这里部分代码省略.........
                Assert.IsNotNull(run.GetRPr());

                Assert.AreEqual(Color.FromArgb(0, 0, 0), run.FontColor);

                Color color = Color.FromArgb(0, 255, 255);
                run.FontColor = (/*setter*/color);
                Assert.AreEqual(color, run.FontColor);

                Assert.AreEqual(11.0, run.FontSize, 0.01);
                run.FontSize = (/*setter*/12.32);
                Assert.AreEqual(12.32, run.FontSize, 0.01);
                run.FontSize = (/*setter*/-1.0);
                Assert.AreEqual(11.0, run.FontSize, 0.01);
                run.FontSize = (/*setter*/-1.0);
                Assert.AreEqual(11.0, run.FontSize, 0.01);
                try
                {
                    run.FontSize = (/*setter*/0.9);
                    Assert.Fail("Should fail");
                }
                catch (ArgumentException e)
                {
                    Assert.IsTrue(e.Message.Contains("0.9"));
                }
                Assert.AreEqual(11.0, run.FontSize, 0.01);

                Assert.AreEqual(0.0, run.CharacterSpacing, 0.01);
                run.CharacterSpacing = (/*setter*/12.31);
                Assert.AreEqual(12.31, run.CharacterSpacing, 0.01);
                run.CharacterSpacing = (/*setter*/0.0);
                Assert.AreEqual(0.0, run.CharacterSpacing, 0.01);
                run.CharacterSpacing = (/*setter*/0.0);
                Assert.AreEqual(0.0, run.CharacterSpacing, 0.01);

                Assert.AreEqual("Calibri", run.FontFamily);
                run.SetFontFamily("Arial", (byte)1, (byte)1, false);
                Assert.AreEqual("Arial", run.FontFamily);
                run.SetFontFamily("Arial", unchecked((byte)-1), (byte)1, false);
                Assert.AreEqual("Arial", run.FontFamily);
                run.SetFontFamily("Arial", (byte)1, unchecked((byte)-1), false);
                Assert.AreEqual("Arial", run.FontFamily);
                run.SetFontFamily("Arial", (byte)1, (byte)1, true);
                Assert.AreEqual("Arial", run.FontFamily);
                run.SetFontFamily(null, (byte)1, (byte)1, false);
                Assert.AreEqual("Calibri", run.FontFamily);
                run.SetFontFamily(null, (byte)1, (byte)1, false);
                Assert.AreEqual("Calibri", run.FontFamily);

                run.SetFont("Arial");
                Assert.AreEqual("Arial", run.FontFamily);

                Assert.AreEqual((byte)0, run.PitchAndFamily);
                run.SetFont(null);
                Assert.AreEqual((byte)0, run.PitchAndFamily);

                Assert.IsFalse(run.IsStrikethrough);
                run.IsStrikethrough = (/*setter*/true);
                Assert.IsTrue(run.IsStrikethrough);
                run.IsStrikethrough = (/*setter*/false);
                Assert.IsFalse(run.IsStrikethrough);

                Assert.IsFalse(run.IsSuperscript);
                run.IsSuperscript = (/*setter*/true);
                Assert.IsTrue(run.IsSuperscript);
                run.IsSuperscript = (/*setter*/false);
                Assert.IsFalse(run.IsSuperscript);

                Assert.IsFalse(run.IsSubscript);
                run.IsSubscript = (/*setter*/true);
                Assert.IsTrue(run.IsSubscript);
                run.IsSubscript = (/*setter*/false);
                Assert.IsFalse(run.IsSubscript);

                Assert.AreEqual(TextCap.NONE, run.TextCap);

                Assert.IsFalse(run.IsBold);
                run.IsBold = (/*setter*/true);
                Assert.IsTrue(run.IsBold);
                run.IsBold = (/*setter*/false);
                Assert.IsFalse(run.IsBold);

                Assert.IsFalse(run.IsItalic);
                run.IsItalic = (/*setter*/true);
                Assert.IsTrue(run.IsItalic);
                run.IsItalic = (/*setter*/false);
                Assert.IsFalse(run.IsItalic);

                Assert.IsFalse(run.IsUnderline);
                run.IsUnderline = (/*setter*/true);
                Assert.IsTrue(run.IsUnderline);
                run.IsUnderline = (/*setter*/false);
                Assert.IsFalse(run.IsUnderline);

                Assert.IsNotNull(run.ToString());
            }
            finally
            {
                wb.Close();
            }
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:101,代码来源:TestXSSFTextRun.cs

示例6: TestBug55843

        public void TestBug55843()
        {
            XSSFWorkbook wb = new XSSFWorkbook();
            try
            {
                XSSFSheet sheet = wb.CreateSheet("test") as XSSFSheet;
                XSSFRow row = sheet.CreateRow(0) as XSSFRow;
                XSSFRow row2 = sheet.CreateRow(1) as XSSFRow;
                XSSFCell cellA2 = row2.CreateCell(0, CellType.Formula) as XSSFCell;
                XSSFCell cellB1 = row.CreateCell(1, CellType.Numeric) as XSSFCell;
                cellB1.SetCellValue(10);
                XSSFFormulaEvaluator formulaEvaluator = wb.GetCreationHelper().CreateFormulaEvaluator() as XSSFFormulaEvaluator;
                cellA2.SetCellFormula("IF(B1=0,\"\",((ROW()-ROW(A$1))*12))");
                CellValue Evaluate = formulaEvaluator.Evaluate(cellA2);
                System.Console.WriteLine(Evaluate);
                Assert.AreEqual("12", Evaluate.FormatAsString());

                cellA2.CellFormula = (/*setter*/"IF(NOT(B1=0),((ROW()-ROW(A$1))*12),\"\")");
                CellValue EvaluateN = formulaEvaluator.Evaluate(cellA2);
                System.Console.WriteLine(EvaluateN);

                Assert.AreEqual(Evaluate.ToString(), EvaluateN.ToString());
                Assert.AreEqual("12", EvaluateN.FormatAsString());
            }
            finally
            {
                wb.Close();
            }
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:29,代码来源:TestXSSFFormulaEvaluation.cs

示例7: Bug57430

        public void Bug57430()
        {
            XSSFWorkbook wb = new XSSFWorkbook();
            try
            {
                wb.CreateSheet("Sheet1");

                XSSFName name1 = wb.CreateName() as XSSFName;
                name1.NameName = (/*setter*/"FMLA");
                name1.RefersToFormula = (/*setter*/"Sheet1!$B$3");
            }
            finally
            {
                wb.Close();
            }
        }
开发者ID:age-soft,项目名称:npoi,代码行数:16,代码来源:TestXSSFBugs.cs

示例8: AddPivotCache

 public void AddPivotCache()
 {
     XSSFWorkbook wb = new XSSFWorkbook();
     try
     {
         CT_Workbook ctWb = wb.GetCTWorkbook();
         CT_PivotCache pivotCache = wb.AddPivotCache("0");
         //Ensures that pivotCaches is Initiated
         Assert.IsTrue(ctWb.IsSetPivotCaches());
         Assert.AreSame(pivotCache, ctWb.pivotCaches.GetPivotCacheArray(0));
         Assert.AreEqual("0", pivotCache.id);
     }
     finally
     {
         wb.Close();
     }
 }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:17,代码来源:TestXSSFWorkbook.cs

示例9: Test51037

        public void Test51037()
        {
            XSSFWorkbook wb = new XSSFWorkbook();
            XSSFSheet s = wb.CreateSheet() as XSSFSheet;

            ICellStyle defaultStyle = wb.GetCellStyleAt((short)0);
            Assert.AreEqual(0, defaultStyle.Index);

            ICellStyle blueStyle = wb.CreateCellStyle();
            blueStyle.FillForegroundColor = (IndexedColors.Aqua.Index);
            blueStyle.FillPattern = (FillPattern.SolidForeground);
            Assert.AreEqual(1, blueStyle.Index);

            ICellStyle pinkStyle = wb.CreateCellStyle();
            pinkStyle.FillForegroundColor = (IndexedColors.Pink.Index);
            pinkStyle.FillPattern = (FillPattern.SolidForeground);
            Assert.AreEqual(2, pinkStyle.Index);

            // Starts empty
            Assert.AreEqual(1, s.GetCTWorksheet().sizeOfColsArray());
            CT_Cols cols = s.GetCTWorksheet().GetColsArray(0);
            Assert.AreEqual(0, cols.sizeOfColArray());

            // Add some rows and columns
            XSSFRow r1 = s.CreateRow(0) as XSSFRow;
            XSSFRow r2 = s.CreateRow(1) as XSSFRow;
            r1.CreateCell(0);
            r1.CreateCell(2);
            r2.CreateCell(0);
            r2.CreateCell(3);

            // Check no style is there
            Assert.AreEqual(1, s.GetCTWorksheet().sizeOfColsArray());
            Assert.AreEqual(0, cols.sizeOfColArray());

            Assert.AreEqual(defaultStyle, s.GetColumnStyle(0));
            Assert.AreEqual(defaultStyle, s.GetColumnStyle(2));
            Assert.AreEqual(defaultStyle, s.GetColumnStyle(3));


            // Apply the styles
            s.SetDefaultColumnStyle(0, pinkStyle);
            s.SetDefaultColumnStyle(3, blueStyle);

            // Check
            Assert.AreEqual(pinkStyle, s.GetColumnStyle(0));
            Assert.AreEqual(defaultStyle, s.GetColumnStyle(2));
            Assert.AreEqual(blueStyle, s.GetColumnStyle(3));

            Assert.AreEqual(1, s.GetCTWorksheet().sizeOfColsArray());
            Assert.AreEqual(2, cols.sizeOfColArray());

            Assert.AreEqual(1, cols.GetColArray(0).min);
            Assert.AreEqual(1, cols.GetColArray(0).max);
            Assert.AreEqual(pinkStyle.Index, cols.GetColArray(0).style);

            Assert.AreEqual(4, cols.GetColArray(1).min);
            Assert.AreEqual(4, cols.GetColArray(1).max);
            Assert.AreEqual(blueStyle.Index, cols.GetColArray(1).style);


            // Save, re-load and re-check 
            wb = XSSFTestDataSamples.WriteOutAndReadBack(wb) as XSSFWorkbook;
            s = wb.GetSheetAt(0) as XSSFSheet;
            defaultStyle = wb.GetCellStyleAt(defaultStyle.Index);
            blueStyle = wb.GetCellStyleAt(blueStyle.Index);
            pinkStyle = wb.GetCellStyleAt(pinkStyle.Index);

            Assert.AreEqual(pinkStyle, s.GetColumnStyle(0));
            Assert.AreEqual(defaultStyle, s.GetColumnStyle(2));
            Assert.AreEqual(blueStyle, s.GetColumnStyle(3));

            wb.Close();
        }
开发者ID:age-soft,项目名称:npoi,代码行数:74,代码来源:TestXSSFBugs.cs

示例10: Bug56468

        public void Bug56468()
        {
            XSSFWorkbook wb = new XSSFWorkbook();
            XSSFSheet sheet = wb.CreateSheet() as XSSFSheet;
            XSSFRow row = sheet.CreateRow(0) as XSSFRow;
            XSSFCell cell = row.CreateCell(0) as XSSFCell;
            cell.SetCellValue("Hi");
            sheet.RepeatingRows = (new CellRangeAddress(0, 0, 0, 0));

            MemoryStream bos = new MemoryStream(8096);
            wb.Write(bos);
            byte[] firstSave = bos.ToArray();
            MemoryStream bos2 = new MemoryStream(8096);
            wb.Write(bos2);
            byte[] secondSave = bos2.ToArray();

            Assert.That(firstSave, new EqualConstraint(secondSave));

            wb.Close();
        }
开发者ID:age-soft,项目名称:npoi,代码行数:20,代码来源:TestXSSFBugs.cs

示例11: Test49253

        public void Test49253()
        {
            XSSFWorkbook wb1 = new XSSFWorkbook();
            XSSFWorkbook wb2 = new XSSFWorkbook();

            // No print Settings before repeating
            XSSFSheet s1 = wb1.CreateSheet() as XSSFSheet;
            Assert.AreEqual(false, s1.GetCTWorksheet().IsSetPageSetup());
            Assert.AreEqual(true, s1.GetCTWorksheet().IsSetPageMargins());

            wb1.SetRepeatingRowsAndColumns(0, 2, 3, 1, 2);

            Assert.AreEqual(true, s1.GetCTWorksheet().IsSetPageSetup());
            Assert.AreEqual(true, s1.GetCTWorksheet().IsSetPageMargins());

            XSSFPrintSetup ps1 = s1.PrintSetup as XSSFPrintSetup;
            Assert.AreEqual(false, ps1.ValidSettings);
            Assert.AreEqual(false, ps1.Landscape);


            // Had valid print Settings before repeating
            XSSFSheet s2 = wb2.CreateSheet() as XSSFSheet;
            XSSFPrintSetup ps2 = s2.PrintSetup as XSSFPrintSetup;
            Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageSetup());
            Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageMargins());

            ps2.Landscape = (false);
            Assert.AreEqual(true, ps2.ValidSettings);
            Assert.AreEqual(false, ps2.Landscape);

            wb2.SetRepeatingRowsAndColumns(0, 2, 3, 1, 2);

            ps2 = s2.PrintSetup as XSSFPrintSetup;
            Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageSetup());
            Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageMargins());
            Assert.AreEqual(true, ps2.ValidSettings);
            Assert.AreEqual(false, ps2.Landscape);

            wb1.Close();
            wb2.Close();
        }
开发者ID:age-soft,项目名称:npoi,代码行数:41,代码来源:TestXSSFBugs.cs

示例12: TestSetAllowBlankToTrue

        public void TestSetAllowBlankToTrue()
        {
            XSSFWorkbook wb = new XSSFWorkbook();
            try
            {
                XSSFSheet sheet = wb.CreateSheet() as XSSFSheet;

                XSSFDataValidation validation = CreateValidation(sheet);
                validation.GetCTDataValidation().allowBlank = (/*setter*/true);

                sheet.AddValidationData(validation);

                List<IDataValidation> dataValidations = sheet.GetDataValidations();
                Assert.AreEqual(true, (dataValidations[0] as XSSFDataValidation).GetCTDataValidation().allowBlank);
            }
            finally
            {
                wb.Close();
            }
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:20,代码来源:TestXSSFDataValidation.cs

示例13: Test53965

        public void Test53965()
        {

            XSSFWorkbook wb = new XSSFWorkbook();
            try
            {
                XSSFSheet sheet = wb.CreateSheet() as XSSFSheet;
                List<IDataValidation> lst = sheet.GetDataValidations();    //<-- works
                Assert.AreEqual(0, lst.Count);

                //create the cell that will have the validation applied
                sheet.CreateRow(0).CreateCell(0);

                IDataValidationHelper dataValidationHelper = sheet.GetDataValidationHelper();
                IDataValidationConstraint constraint = dataValidationHelper.CreateCustomConstraint("SUM($A$1:$A$1) <= 3500");
                CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);
                IDataValidation validation = dataValidationHelper.CreateValidation(constraint, addressList);
                sheet.AddValidationData(validation);

                // this line caused XmlValueOutOfRangeException , see Bugzilla 3965
                lst = sheet.GetDataValidations();
                Assert.AreEqual(1, lst.Count);
            }
            finally
            {
                wb.Close();
            }
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:28,代码来源:TestXSSFDataValidation.cs

示例14: IncrementSheetId

        public void IncrementSheetId()
        {
            XSSFWorkbook wb = new XSSFWorkbook();
            try
            {
                int sheetId = (int)(wb.CreateSheet() as XSSFSheet).sheet.sheetId;
                Assert.AreEqual(1, sheetId);
                sheetId = (int)(wb.CreateSheet() as XSSFSheet).sheet.sheetId;
                Assert.AreEqual(2, sheetId);

                //test file with gaps in the sheetId sequence
                XSSFWorkbook wbBack = XSSFTestDataSamples.OpenSampleWorkbook("47089.xlsm");
                try
                {
                    int lastSheetId = (int)(wbBack.GetSheetAt(wbBack.NumberOfSheets - 1)  as XSSFSheet).sheet.sheetId;
                    sheetId = (int)(wbBack.CreateSheet() as XSSFSheet).sheet.sheetId;
                    Assert.AreEqual(lastSheetId + 1, sheetId);
                }
                finally
                {
                    wbBack.Close();
                }
            }
            finally
            {
                wb.Close();
            }
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:28,代码来源:TestXSSFWorkbook.cs

示例15: TestBug56820_Formula2

        public void TestBug56820_Formula2()
        {
            IWorkbook wb = new XSSFWorkbook();
            try
            {
                IFormulaEvaluator Evaluator = wb.GetCreationHelper().CreateFormulaEvaluator();
                ISheet sh = wb.CreateSheet();

                sh.CreateRow(0).CreateCell(0).SetCellValue(0.0d);
                ICell formulaCell1 = sh.CreateRow(1).CreateCell(0);
                ICell formulaCell2 = sh.CreateRow(2).CreateCell(0);
                formulaCell1.CellFormula = (/*setter*/FORMULA2);
                formulaCell2.CellFormula = (/*setter*/FORMULA2);

                double A1 = Evaluator.Evaluate(formulaCell1).NumberValue;
                double A2 = Evaluator.Evaluate(formulaCell2).NumberValue; //<-- FAILS EVALUATION

                Assert.AreEqual(2, A1, 0);
                Assert.AreEqual(4, A2, 0);
            }
            finally
            {
                wb.Close();
            }
        }
开发者ID:age-soft,项目名称:npoi,代码行数:25,代码来源:TestXSSFBugs.cs


注:本文中的NPOI.XSSF.UserModel.XSSFWorkbook.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。