We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How can I deselect or unselect cells in a worksheet template?

This might seem to be a very simple question and I hope there is a simple answer to it.

I have multiple designer worksheet templates that I use for Workbook output. The templates all seem to contain at least 1 selected cell. I can't seem to find a native way in Excel to deselect or unselect any or all cells in a worksheet, either in Excel 2003 or 2007.

This problem results in output that contains the selected cell. If the cell contains data, then that data appears at the top of the worksheet.

I have seen that there are some macros available created by VBA programmers to do such a thing.

However, since I pay for Aspose Cells and use it in my programming I am asking if Aspose has methods or properties to locate selected cells and then deselect them.

I have searched the forums and the documentation and have not found anything yet.

Thanks for any help...

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Well, I am not very clear about your requirement. But if your requirement is to disable the selection of the cells, then you can use the advance protection options of MS Excel (supported by Aspose) to do that. Please see the following Sample Code in this regard,

Sample Code:

//Instantiating a Workbook object

Workbook excel = new Workbook();

//Accessing the first worksheet in the Excel file

Worksheet worksheet = excel.Worksheets[0];

//Allowing users to select locked cells of the worksheet

worksheet.Protection.IsSelectingLockedCellsAllowed = false;

//Allowing users to select unlocked cells of the worksheet

worksheet.Protection.IsSelectingUnlockedCellsAllowed = false;

worksheet.Protect(ProtectionType.Contents, "", "");

//Saving the modified Excel file Excel XP format

excel.Save("C:\\output.xls", FileFormatType.ExcelXP);

Also, you can see the following documentation link for you reference on Advance protection feature,


Thank You & Best Regards,


Well, if you need to activate a worksheet and activate/select your desired cell in your template excel file, you may check the following documentation topic for your reference:


Thank you.

Thank you for the replies.

In response to the first reply, I don't want to "protect" the spreadsheet.

In response to Amjad Sahi I want to do the opposite of activate.

I think my question is TOO simple.

Let me try to explain. If I open up a worksheet and click on a cell, it becomes "selected" but not necessarily "active". The data in the "selected" cell appears at the top of the worksheet.

When I save the workbook and re-open it, the smae cell is STILL selected.

This is also the case of the Templates I have created.

Please try it. Open any Excel worksheet in MS Excel. Select any cell (just click on it once).

Now try to "un-select" it. The only way I have found to do that is by clicking on a different cell, but then THAT cell becomes selected.

When I deliver a workbook/worksheet that the customer downloads from my site I don't want ANY cells to be either "selected" or "active".

So I want to be able to clear the template I use of any "selected" or "active" cells when I save it, so that the finished Workbook, created in my programming with Aspose, will also NOT HAVE any selected cells.

I may be missing something very basic with how to use Microsoft Excel. However, I have read on a newsgroup that MS does not supply a way to un-select a selected cell.

My guess is that if Excel does not allow de-selection or un-selection, then Aspose would have no way to do that either.


Thank you for considering Aspose.

Yes, you are right. It is not possible in MS Excel to un-select a selected cell. Also, if you open any excel file, there will always be an active / selected cell in the worksheet (only not in case of protected worksheets). As, Aspose provides all the API as per MS Excel functionalities, so I am afraid, this will not be implementable with Aspose as well (as not implementable with MS Excel).

Thank You & Best Regards,

Hello Nausherwan,

I am having problem while merging two or more worksheets in a empty workbook. Please check the following code:

//Open a Workbook.
Workbook yearly = new Workbook();

//Open another Workbook.
Workbook monthly = new Workbook();

//Open another Workbook merge the two.
Workbook main = new Workbook();

main.Worksheets.Add("Usage Year to Date");
main.Worksheets["Usage Year to Date"].Copy(yearly.Worksheets[0]);

main.Worksheets.Add("Monthly Usage Trend");
main.Worksheets["Monthly Usage Trend"].Copy(monthly.Worksheets[0]);

//Save the file.
main.Worksheets.ActiveSheetIndex = 0;
main.Save(@"C:\Admin.xls", FileFormatType.Default);


I attached the generated file. When I open the report it shows the two worksheets are grouped (i.e. all the sheets are selected), so I can't select the chart in the first worksheet unless I click right and select "Ungroup Sheets" or go to another sheet and then comeback.

As I cannot expect from my end user to ungroup sheets like this, so this is a critical issue for us, user will think it is not an Excel chart, just an image (because it is not selectable for the moment). Please help me on this issue.


Hi Zerin,

Kindly post your template “A.xls” and “B.xls” files
here, we want to conduct a test for your issue. And which version you
are using?

Thank you