using System; using System.Text; using System.IO; using NPOI.HSSF.UserModel; using NPOI.HPSF; using NPOI.POIFS.FileSystem; using System.Collections.Generic; using NPOI.SS.Util; using NPOI.SS.UserModel; namespace SetActiveCellRangeInXls { class Program { static void Main(string[] args) { InitializeWorkbook(); //use HSSFCell.SetAsActiveCell() to select B6 as the active column Sheet sheet1 = hssfworkbook.CreateSheet("Sheet A"); CreateCellArray(sheet1); sheet1.GetRow(5).GetCell(1).SetAsActiveCell(); //set TopRow and LeftCol to make B6 the first cell in the visible area sheet1.TopRow = 5; sheet1.LeftCol = 1; //use Sheet.SetActiveCell(), the sheet can be empty Sheet sheet2 = hssfworkbook.CreateSheet("Sheet B"); sheet2.SetActiveCell(1, 5