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