Set Worksheet scroll position in Excel spreadsheet in .NET

I am adding CSV data to a worksheet (worksheet1) and then inserting sum summary lines at the end of that data.

So, I know that rowX is my last populated row position in worksheet1. I save the file and send it to the end users. When they open the file, I want worksheet1 to scroll to rowX (leaving all data rows preceeding it in their place...).

I tried using

Workbook.Worksheets.ActiveSheetIndex = 0;

worksheet1.ActiveCell = "A" + rowX.ToString();

worksheet1.FirstVisibleColumn = 0;

worksheet1..FirstVisibleRow = rowX;

But it seems that this moves rowX to the top (above lower ordinal rows) and then just displays that row when you click on it (not the desired behavior). What to do?

Using Aspose.Cells.dll version 4.9.1.3.

Thanks in advance (and apologies if this has been answered elsewhere... I could not find it).

Jai Singh

Hi,

I think it works as expected. If your desired row goes on top beyond display, please change your code to:
Workbook.Worksheets.ActiveSheetIndex
= 0;

worksheet1.ActiveCell = "A" + rowX.ToString();

worksheet1.FirstVisibleColumn = 0;

worksheet1..FirstVisibleRow = rowX-1;


And if you just need your desired should not be on top but you just want the focus should be on your active cell (no matter where the cell is in the worksheet), you may skip or comment out the line.

//worksheet1..FirstVisibleRow = rowX;


If you still have any confusion, kindly let us know with details and sample files.


Thank you.