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


C# XSSFWorkbook.GetNameAt方法代码示例

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


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

示例1: TestRepeatingRowsAndColums

        public void TestRepeatingRowsAndColums()
        {
            // First Test that Setting RR&C for same sheet more than once only Creates a
            // single  Print_Titles built-in record
            XSSFWorkbook wb = new XSSFWorkbook();
            wb.CreateSheet("First Sheet");

            wb.SetRepeatingRowsAndColumns(0, -1, -1, -1, -1);

            // Set repeating rows and columns twice for the first sheet
            for (int i = 0; i < 2; i++)
            {
                wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3);
                //sheet.CreateFreezePane(0, 3);
            }
            Assert.AreEqual(1, wb.NumberOfNames);
            IName nr1 = wb.GetNameAt(0);

            Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr1.NameName);
            Assert.AreEqual("'First Sheet'!$A:$A,'First Sheet'!$1:$4", nr1.RefersToFormula);

            //remove the columns part
            wb.SetRepeatingRowsAndColumns(0, -1, -1, 0, 3);
            Assert.AreEqual("'First Sheet'!$1:$4", nr1.RefersToFormula);

            //revert
            wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3);

            //remove the rows part
            wb.SetRepeatingRowsAndColumns(0, 0, 0, -1, -1);
            Assert.AreEqual("'First Sheet'!$A:$A", nr1.RefersToFormula);

            //revert
            wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3);

            // Save and re-open
            IWorkbook nwb = XSSFTestDataSamples.WriteOutAndReadBack(wb);

            Assert.AreEqual(1, nwb.NumberOfNames);
            nr1 = nwb.GetNameAt(0);

            Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr1.NameName);
            Assert.AreEqual("'First Sheet'!$A:$A,'First Sheet'!$1:$4", nr1.RefersToFormula);

            // check that Setting RR&C on a second sheet causes a new Print_Titles built-in
            // name to be Created
            nwb.CreateSheet("SecondSheet");
            nwb.SetRepeatingRowsAndColumns(1, 1, 2, 0, 0);

            Assert.AreEqual(2, nwb.NumberOfNames);
            IName nr2 = nwb.GetNameAt(1);

            Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr2.NameName);
            Assert.AreEqual("SecondSheet!$B:$C,SecondSheet!$1:$1", nr2.RefersToFormula);

            nwb.SetRepeatingRowsAndColumns(1, -1, -1, -1, -1);
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:57,代码来源:TestXSSFName.cs


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