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


C# HSSFWorkbook.GetPrintArea方法代碼示例

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


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

示例1: Test46664

        public void Test46664()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            ISheet sheet = wb.CreateSheet("new_sheet");
            IRow row = sheet.CreateRow((short)0);
            row.CreateCell(0).SetCellValue(new HSSFRichTextString("Column A"));
            row.CreateCell(1).SetCellValue(new HSSFRichTextString("Column B"));
            row.CreateCell(2).SetCellValue(new HSSFRichTextString("Column C"));
            row.CreateCell(3).SetCellValue(new HSSFRichTextString("Column D"));
            row.CreateCell(4).SetCellValue(new HSSFRichTextString("Column E"));
            row.CreateCell(5).SetCellValue(new HSSFRichTextString("Column F"));

            //set print area from column a to column c (on first row)
            wb.SetPrintArea(
                    0, //sheet index
                    0, //start column
                    2, //end column
                    0, //start row
                    0  //end row
            );

            wb = WriteOutAndReadBack(wb);

            // Ensure the tab index
            TabIdRecord tr = null;
            foreach (Record r in wb.Workbook.Records)
            {
                if (r is TabIdRecord)
                {
                    tr = (TabIdRecord)r;
                }
            }
            Assert.IsNotNull(tr);
            Assert.AreEqual(1, tr._tabids.Length);
            Assert.AreEqual(0, tr._tabids[0]);

            // Ensure the print setup
            Assert.AreEqual("new_sheet!$A$1:$C$1", wb.GetPrintArea(0));
            Assert.AreEqual("new_sheet!$A$1:$C$1", wb.GetName("Print_Area").RefersToFormula);

            // Needs reference not value
            NameRecord nr = wb.Workbook.GetNameRecord(
                  wb.GetNameIndex("Print_Area")
            );
            Assert.AreEqual("Print_Area", nr.NameText);
            Assert.AreEqual(1, nr.NameDefinition.Length);
            Assert.AreEqual(
                  "new_sheet!$A$1:$C$1",
                  ((Area3DPtg)nr.NameDefinition[0]).ToFormulaString(HSSFEvaluationWorkbook.Create(wb))
            );
            // TODO - fix me to be Reference not Value!
            //Assert.AreEqual('R', nr.NameDefinition[0].RVAType);
        }
開發者ID:xoposhiy,項目名稱:npoi,代碼行數:53,代碼來源:TestBugs.cs


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