當前位置: 首頁>>代碼示例>>C#>>正文


C# HSSFWorkbook.SetRepeatingRowsAndColumns方法代碼示例

本文整理匯總了C#中NPOI.HSSF.UserModel.HSSFWorkbook.SetRepeatingRowsAndColumns方法的典型用法代碼示例。如果您正苦於以下問題:C# HSSFWorkbook.SetRepeatingRowsAndColumns方法的具體用法?C# HSSFWorkbook.SetRepeatingRowsAndColumns怎麽用?C# HSSFWorkbook.SetRepeatingRowsAndColumns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NPOI.HSSF.UserModel.HSSFWorkbook的用法示例。


在下文中一共展示了HSSFWorkbook.SetRepeatingRowsAndColumns方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestRepeatingRowsAndColumsNames

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

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

            Assert.AreEqual("Print_Titles", nr1.NameName);
            if (false)
            {
#if !HIDE_UNREACHABLE_CODE
                //     TODO - full column references not rendering properly, absolute markers not present either
                Assert.AreEqual("FirstSheet!$A:$A,FirstSheet!$1:$3", nr1.RefersToFormula);
#endif
            }
            else
            {
                Assert.AreEqual("FirstSheet!A:A,FirstSheet!$A$1:$IV$3", nr1.RefersToFormula);
            }

            // Save and re-open
            HSSFWorkbook nwb = HSSFTestDataSamples.WriteOutAndReadBack(wb);

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

            Assert.AreEqual("Print_Titles", nr1.NameName);
            Assert.AreEqual("FirstSheet!A:A,FirstSheet!$A$1:$IV$3", nr1.RefersToFormula);

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

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

            Assert.AreEqual("Print_Titles", nr2.NameName);
            Assert.AreEqual("SecondSheet!B:C,SecondSheet!$A$1:$IV$1", nr2.RefersToFormula);

            //if (false) {
            //    // In case you fancy Checking in excel, to ensure it
            //    //  won't complain about the file now
            //        File tempFile = File.CreateTempFile("POI-45126-", ".xls");
            //        FileOutputStream fout = new FileOutputStream(tempFile);
            //        nwb.Write(fout);
            //        fout.close();
            //        Console.WriteLine("check out " + tempFile.GetAbsolutePath());
            //}
        }
開發者ID:xoposhiy,項目名稱:npoi,代碼行數:59,代碼來源:TestHSSFName.cs

示例2: TestSetRepeatingRowsAndColumns

 public void TestSetRepeatingRowsAndColumns()
 {
     // Test bug 29747
     HSSFWorkbook b = new HSSFWorkbook();
     b.CreateSheet();
     b.CreateSheet();
     b.CreateSheet();
     b.SetRepeatingRowsAndColumns(2, 0, 1, -1, -1);
     NameRecord nameRecord = b.Workbook.GetNameRecord(0);
     Assert.AreEqual(3, nameRecord.SheetNumber);
 }
開發者ID:xoposhiy,項目名稱:npoi,代碼行數:11,代碼來源:TestHSSFWorkbook.cs

示例3: TestRepeatingColsRows

        public void TestRepeatingColsRows()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            NPOI.SS.UserModel.ISheet sheet = workbook.CreateSheet("Test Print Titles");

            IRow row = sheet.CreateRow(0);

            ICell cell = row.CreateCell(1);
            cell.SetCellValue(new HSSFRichTextString("hi"));


            workbook.SetRepeatingRowsAndColumns(0, 0, 1, 0, 0);

            string filepath = TempFile.GetTempFilePath("TestPrintTitles", ".xls");

            FileStream fileOut = new FileStream(filepath, FileMode.OpenOrCreate);
            workbook.Write(fileOut);
            fileOut.Close();

            Assert.IsTrue(File.Exists(filepath), "file exists");
        }
開發者ID:hanwangkun,項目名稱:npoi,代碼行數:21,代碼來源:TestWorkbook.cs

示例4: TestRepeatingColsRowsMinusOne

        public void TestRepeatingColsRowsMinusOne()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Test Print Titles");

            IRow row = sheet.CreateRow(0);

            ICell cell = row.CreateCell(1);
            cell.SetCellValue(new HSSFRichTextString("hi"));


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

            FileInfo file = TempFile.CreateTempFile("testPrintTitlesA", ".xls");

            FileStream fileOut = new FileStream(file.FullName, FileMode.Create, FileAccess.ReadWrite);
            workbook.Write(fileOut);
            fileOut.Close();
            Assert.IsTrue(file.Exists, "file exists");
        }
開發者ID:Reinakumiko,項目名稱:npoi,代碼行數:20,代碼來源:TestWorkbook.cs


注:本文中的NPOI.HSSF.UserModel.HSSFWorkbook.SetRepeatingRowsAndColumns方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。