1,C#,NPOI2.2.1版本,设值打印区域,打印标题,设值筛选

1,  NPOI2.2.1版本,设值打印区域,打印标题,设值筛选。

using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using NPOI.SS.Util;

string tpath = "d:\\BM.xls";

FileStream filewrite = new FileStream(tpath, FileMode.Open, FileAccess. Write);

HSSFWorkbook book2 = new HSSFWorkbook(filewrite);

HSSFSheet CPS ;

//设置打印标题

CPS.RepeatingRows = new CellRangeAddress(0, 8, 0, 8);

// (int first row,int last row,int first col,int last col)

//设置Excel的自动筛选

CellRangeAddress c = CellRangeAddress.ValueOf("A1:K1");

CPS.SetAutoFilter(c);

//设置打印区域

book2.SetPrintArea(sheetnum, int first row,int last row,int first col,int last col);

book2.Write(fileSave2);

filewrite.Close();

posted on 2019-01-11 10:13  helloe  阅读(1071)  评论(0编辑  收藏  举报

导航