Free Support Forum - aspose.com

Select worksheet to be displayed on open

We are using the Excel designer to populate an excel spreadsheet from our database. When we open the document after it has been processed, it first displays the last column in the last worksheet in the document. How can I reset the cursor to the first column and first row of the first worksheet?

Thanks,

Martin

Hi Martin,

Do you use an evaluation copy or a licensed copy? If your Aspose.Excel is an evaluation copy, the first shown worksheet is always the license page(last worksheet). If your Aspose.Excel is licensed, please use Worksheets.ActiveSheetIndex to set the first shown worksheet.

We have a full licensed version. The activesheetindex worked.

Now when I view a worksheet that has a large number of columns, I first see the last column in the worksheet. The page is scrolled over to the right. How do I reset the view so that I can see the first column in view when the document is opened?

Martin

Hi Martin,

We will provide new properties to set the first view row and column in the future release. Now could you manually set it in your designer file?

I just noticed that my template documents had the last column selected when I opend them. I selected the first column and now it works as requested.

Thank you,

Martin

@Playground,
Aspose.Excel is replaced by Aspose.Cells that contains all the features of Aspose.Excel and also supports the latest features in different versions of MS Excel. Aspose.Cells provides specific API calls to set active worksheet and active cell. The following sample code can be used to active worksheet and cell.

// Instantiate a new Workbook
Workbook workbook = new Workbook();
// Get the first worksheet in the workbook
Worksheet worksheet = workbook.Worksheets[0];
// Get the cells in the worksheet
Cells cells = worksheet.Cells;
// Input data into B2 cell
cells[1, 1].PutValue("Hello World!");
// Set the first sheet as an active sheet
workbook.Worksheets.ActiveSheetIndex = 0;
// Set B2 cell as an active cell in the worksheet
worksheet.ActiveCell = "B2";
// Set the B column as the first visible column in the worksheet
worksheet.FirstVisibleColumn = 1;
// Set the 2nd row as the first visible row in the worksheet
worksheet.FirstVisibleRow = 1;
// Save the excel file
workbook.Save("activecell.xls");

The following link can be referred for more information.
Activating Sheets and Activating a Cell in Workshee

Give a try to this new product by downloading it from the following link:
Aspose.Cells for .NET (Latest Version)

A ready to run solution is available here that can be used to test the variety of features of this new product.