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

Importing a datatable to a sheet - View not getting updated.

Hi . 

I'm using SpreadsheetControl in my application. 

I have to import a datatable to Worksheet ( the sheet can be anything that the user selects ) .

            SpreadsheetControl mySpeadsheetControl = Application.Current.MainWindow.FindName("mySpreadsheet") as SpreadsheetControl;
            IWorksheet sheet = mySpeadsheetControl.ExcelProperties.WorkBook.ActiveSheet;
            sheet.Activate();
            sheet.ImportDataTable(myGridContents, true, 1, 1);

When I do like this, the view is not getting updated. But if I click on some other sheet and then come back to this original sheet the view will be updated. How can i resolve this ? 

If I use the following method instead of  "sheet.ImportDataTable(myGridContents, true, 1, 1);"  
           mySpeadsheetControl.ImportFromDataTable(myGridContents); 
the view is getting updated immediately. But the problem with this is, whatever sheet I select , the changes happen only in Sheet1. Let me know if there is ant solution for this . 

Thanks in advance. 

1 Reply

BP Balakrishnan P Syncfusion Team October 10, 2014 10:52 AM UTC

Hi Stephly,

Thanks for contacting Syncfusion support.

You can achieve your requirement "view updated immediately when loading the data table" by using invalidatecells() and invalidatevisuals() method. Please find the below code snippet for your reference.

Code Snippet:

this.spreadsheetControl.GridProperties.ActiveSpreadsheetGrid.InvalidateCells();

this.spreadsheetControl.GridProperties.ActiveSpreadsheetGrid.InvalidateVisual();


Please let us know if you have any queries.

Thanks,
Balakrishnan.P

Loader.
Live Chat Icon For mobile
Up arrow icon