We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to Set a ActiveWorksheet ?

I want to write this with the SyncFusion library:

        private Workbook ActiveWorkbook
        {
            get
            {
                return this.activeWorkbook;
            }
            set
            {
                this.activeWorkbook = value;
            }
        }

        private Worksheet ActiveWorksheet
        {
            get
            {
                return this.ActiveWorkbook.ActiveWorksheet;
            }
            set
            {
                this.ActiveWorkbook.ActiveWorksheet = value;
            }
        }

How can I achive the same with SyncFusion library ?


3 Replies

DE Devid February 21, 2017 09:40 AM UTC

The problem I have is that ActiveWorkbook.ActiveSheet is a read only property in SyncFusion


DE Devid February 21, 2017 10:21 AM UTC

I think this would be the solution. But ActiveSheet should not be actually Read Only in my opinion, but anyway.

 private IWorksheet ActiveWorksheet
        {
            get { return this.ActiveWorkbook.ActiveSheet; }
            set { this.SelectSheet(value); }
        }

 private void SelectSheet(IWorksheet value)
        {
            if (value != null)
            {
                SelectSheet(value.Index);
            }
        }


SS Sridhar Sukumar Syncfusion Team February 22, 2017 01:06 PM UTC

Hi Devid, 
 
Thank you for contacting Syncfusion support. 
 
We regret to let you know that ActiveSheet property cannot be changed as Read and Write property in XlsIO. However, you can achieve your requirement using the following code example in XlsIO. 
 
Code snippet: 
 private Worksheet ActiveWorksheet 
        { 
            get 
            { 
                return this.ActiveWorkbook.ActiveWorksheet; 
            } 
            set 
            { 
               value.Activate(); 
            } 
        } 
 
To know more about activating a worksheet refer the below documentation link.

Documentation Link: https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.ITabSheet.html#Syncfusion_XlsIO_ITabSheet_Activate

Regards,
 
Sridhar S. 


Loader.
Up arrow icon