Aspose allows two or more sheets to be active at the same time

Hi,


I am not sure if this is a bug or expected behaviour:

var workbook = new Workbook();

Worksheet newSheet = workbook.Worksheets[workbook.Worksheets.Add()];

newSheet.IsSelected = true;

workbook.Save(“Selected.xlsx”);

In this case, if you open the output file both Sheet1 and Sheet2 are active and are bold.
This is also reflected in the code as setting newSheet to selected does not set the first sheet’s IsSelected property to false.

Is this expected behaviour?

Best regards.

Hi,


Thanks for your query.

Well, if you are setting the licensing code with a valid license in your sample code at the start, by default the first worksheet would be active too, so when you set the new sheet selected it would make a group with the first sheet (which is already active), so you are seeing both Sheet1 and Sheet2 are selected making a group in the output Excel file.

For your needs, please set your desired sheet as active sheet too, see the sample code for your reference (I have only added a line to your code):
e.g
Sample code:

Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense(“e:\test2\Aspose.Cells.lic”);

var workbook = new Workbook();

Worksheet newSheet = workbook.Worksheets[workbook.Worksheets.Add()];

newSheet.IsSelected = true;

workbook.Worksheets.ActiveSheetIndex = newSheet.Index;

workbook.Save(“e:\test2\out1.xlsx”);

Let us know if you still find any issue.

Thank you.


Hi,


Ok that makes sense. Thanks for your reply!

Hi,


Good to know that it sorts out your issue now. Feel free to write back if you have further comments or questions, we will be happy to assist you soon.

Thank you.