本文整理汇总了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);
}