How to set the horizontal and vertical scroll position in worksheet

Hi,


How to set the horizontal and vertical scroll position in a worksheet. I tried using “ActiveCell” property, but it did not help.

Please find the attached sheets for reference. I am using following code.

LoadOptions options = new LoadOptions(LoadFormat.Excel97To2003);
Workbook wkBook = new Workbook(@“E:\Code_Bak\Personal\ExcelAsposeTester\test.xls”, options);
Worksheet sheet = wkBook.Worksheets[0];
sheet.ActiveCell = “A1”;
wkBook.Save(@“E:\Code_Bak\Personal\ExcelAsposeTester\test1.xls”);

Attached file Test.xls is the input file and Test1.xls is the output file.

Thanks, Vinay

Further searched your forum and found

worksheet1.FirstVisibleColumn =20;
worksheet1.FirstVisibleRow = 180;

I could use it to something like
worksheet1.FirstVisibleColumn =worksheet1.Cells[“A1”].Row;
worksheet1.FirstVisibleRow = worksheet1.Cells[“A1”].Column;

I guess this should be it or is there any other solution as well?

Hi,

Yes you are absolutely right.

Moreover, you need to use license and using the licensing code instantiated before using your code segment, otherwise your active worksheet would be the evaluation worksheet. Here is my sample code using your file that works fine.

Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense(@“E:\Licenses\Aspose.Cells.lic”);
Workbook wb = new Workbook(@“e:\test2\test.xls”);
Worksheet ws = wb.Worksheets[0];
wb.Worksheets.ActiveSheetIndex = 0;
ws.ActiveCell = “A1”;
ws.FirstVisibleColumn = 0;
ws.FirstVisibleRow = 0;

wb.Save(“e:\test2\test1.xls”);

Hey Thanks,


Yes, I am using Licenced version of Aspose… the sheet I sent u was generated using a POC which doesnot use the Licence file.

Thanks.