title: ClosedXML - How do I set the scroll position of a sheet?
body: <p>I am creating an Excel spreadsheet (XLSX) from an existing template and adding a dataset to a table on one of the worksheets.
  I have been able to programmatically set the active sheet, but I can't set where the scroll position of the sheet is so that the last rows of data are displayed when someone opens the spreadsheet in Excel.</p>
  <p>I'm adding 5000+ rows but when someone opens the file in Excel, the scroll position is where it was when the original template was saved. The cell I set to selected is indeed selected but it's off screen.</p>
  <p>Here's my code:</p>
  <pre><code>using (var workbook = new XLWorkbook(fileInfo.FullName))
  {
  workbook.Properties.Author = _configuration.GetSection(&quot;ExcelAuthor&quot;).Value;
  
  var workSheet = workbook.Worksheet(_configuration.GetSection(&quot;ExcelWorkSheetName&quot;).Value);
  var table = workSheet.Table(_configuration.GetSection(&quot;ExcelTableName&quot;).Value);
  
  var range = table.ReplaceData(data.Tables[0]);
  
  //Set the sheet as the active sheet
  foreach (var sheet in workbook.Worksheets)
  {
      var isCurrentSheet = sheet.Equals(workSheet);
  
      sheet.SetTabActive(isCurrentSheet);
      sheet.SetTabSelected(isCurrentSheet);
  }
  
   //workSheet.ActiveCell = range.LastCell();
   workSheet.Cell(range.LastCell().Address).Select();
  
   //range.LastCell().Select();
   //range.LastCell().SetActive();
  
  
  
  path = string.Format(&quot;{0} - {1}.xlsx&quot;, _configuration.GetSection(&quot;FileNamePrefix&quot;).Value, DateTime.Now.ToString(&quot;yyyy-MM-dd&quot;));
  path = string.Format(&quot;{0}\\{1}&quot;, _configuration.GetSection(&quot;OutputFolder&quot;).Value.TrimEnd(new[] { '/', '\\' }), path);
  workbook.SaveAs(path);
  </code></pre>
  <p>};</p>