Cant paste the previously copied cells after clearing the sheet

See the attachment.


Attachment: SfSpreadSheet_Test_7af1e6c9.zip

13 Replies

MS Malini Selvarasu Syncfusion Team October 23, 2024 01:40 PM UTC

Hi crosslife,

Thank you for providing the demo. Based on the information provided, we understand that you are experiencing an issue with pasting previously copied cells after clearing the sheet. We have prepared a video demonstrating this issue.
Please take a moment to review the attached video and confirm whether you are encountering the same problem and if the replication steps align with yours. If not, we kindly request that you provide a video reference regarding the issue. This information will help us better understand the problem and facilitate a prompt solution.
Thank you for your understanding.
Regards,
Malini Selvarasu


Attachment: SfSpreadSheet___Issue_b8d7f241.zip


CR crosslife October 25, 2024 07:29 AM UTC

Yes,I forgot to add the video to the attachments.



MS Malini Selvarasu Syncfusion Team October 28, 2024 02:07 PM UTC

Hi crosslife,

Thank you for confirming this issue. We are currently analyzing the scenario you reported and require additional time to validate it. We will provide an update on or before October 30, 2024.

We appreciate your patience in the meantime.

Regards,
Malini Selvarasu


MS Malini Selvarasu Syncfusion Team October 29, 2024 02:51 PM UTC

Hi crosslife,

We have reviewed the reported scenario and confirmed that it is the default behavior of the spreadsheet. When clearing the sheet using the ActiveSheet.Clear() method, the contents are removed, which also eliminates any relevant context for pasting previously copied data. As a result, the copied data is not retained after the sheet is cleared.
Additionally, we acknowledge that the paste option remains enabled after clearing a worksheet. We understand this may cause confusion, as it suggests that pasting is possible even when there is no data context to support it. To address this issue, we plan to disable the paste option following the clearing of the sheet.
Thank you for your understanding.
Regards,
Malini Selvarasu

 



CR crosslife November 1, 2024 08:13 AM UTC

No, what I want is to have the copied data directly stored in the clipboard, so that even if the data is cleared, it can still be pasted elsewhere.



MS Malini Selvarasu Syncfusion Team November 4, 2024 03:43 PM UTC

Hi crosslife,
Based on the information provided, we understand that you need to paste data using clipboard text. We are currently analyzing the scenario you reported and require additional time for validation. We will provide an update on or before November 6, 2024.
We appreciate your patience in the meantime.
Regards,
Malini Selvarasu


MS Malini Selvarasu Syncfusion Team November 6, 2024 02:01 PM UTC

Hi crosslife,

As we mentioned earlier, when pasting data using Ctrl+V or the context menu options, the data is not pasted, which is the default behavior of the spreadsheet. We have verified the same behavior in Excel, and it behaves in the same way. We have attached a video demonstrating this behavior.
However, in Excel, the text is pasted using the clipboard, whereas in SfSpreadsheet, the text is not pasted from the clipboard. We have checked the reported issue, 'Pasting from the Clipboard did not work after clearing the Worksheet,' on our end, and it has been confirmed as a defect. We have logged a bug for this issue, and we will fix it in our NuGet release, which is scheduled for December 03, 2024.
You can track the status of this report through the following feedback link,
Note: The provided feedback link is private, and you need to log in to view this feedback.
We will let you know once it is released. We appreciate your patience until then.
Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.
Regards,
Malini Selvarasu

Attachment: Excel__Video_Reference_81aa1670.zip


MS Malini Selvarasu Syncfusion Team December 3, 2024 01:14 PM UTC

Hi crosslife,

We regret the inconvenience. We are unable to include the fix for this issue, "Pasting from the Clipboard did not work after clearing the Worksheet" in our NuGet package released today as promised.

 
We would like to inform you that when data is copied from the spreadsheet, the copied range is stored. During pasting, this range is moved to the targeted range (i.e., the pasted range). However, when the active sheet is cleared, the copied range's text is also cleared, leaving it empty. As a result, pasting from the clipboard history (Windows + V) does not work after clearing the worksheet. We will address this issue in the first weekly NuGet release following the 2024 Volume 4 main release.

 

We will let you know once it is released. We appreciate your patience until then.

 

Thank you for your understanding and cooperation.

Regards,
Malini Selvarasu


CR crosslife December 4, 2024 02:46 AM UTC

I am developing an application where cells only contain plain text. I want to achieve the following: after copying, all cell texts should be stored in the clipboard using a specific data structure, so that even after the ActiveSheet is cleared, the content can still be pasted anywhere, including in another process.


As I mentioned in 

https://www.syncfusion.com/forums/195373/how-to-disable-sfspreadsheets-copy-paste-behavior-and-implement-custom-logic-instead


If there's a way to disable the default copy-paste logic of the Spreadsheet and implement my own by listening to keyboard events and menu responses, that would also work.



MA Manikanda Akash Munisamy Syncfusion Team December 4, 2024 04:40 PM UTC

Hi crosslife,

Thank you for your update. As the query mentioned is a new topic, we kindly request you to follow up on the dedicated forum thread for better tracking and discussion.
 
 
If you have further concerns or require any additional assistance, please feel free to let us know.

Regards,
Manikanda Akash


MS Malini Selvarasu Syncfusion Team December 19, 2024 09:37 AM UTC

Hi crosslife,

We apologize for the inconvenience. Unfortunately, we were unable to include the fix for the issue "Pasting from the Clipboard did not work after clearing the Worksheet" in our NuGet package released today, as promised.
We would like to inform you that in the spreadsheet, when a range is copied, the copied range (SourceRange) and its text are retained. During the paste operation, the SourceRange is moved to the target range (pasted range).
However, in this scenario, when the sheet is cleared, the SourceRange becomes empty, causing the paste operation to not function as expected. To address this issue, we attempted to set the null for the SourceRange text after clearing the active sheet. While this approach resolved the problem for pasting using the clipboard, it also allowed normal pasting with Ctrl + V to work. In Excel, normal paste does not function after clearing the active sheet.
We are actively working to resolve this issue to ensure the expected behavior in Excel. The fix is scheduled to be included in the upcoming Weekly NuGet release on December 24, 2024. We appreciate your patience and understanding as we continue to refine our solution.
Regards,
Malini Selvarasu


MS Malini Selvarasu Syncfusion Team December 24, 2024 02:08 PM UTC

Hi crosslife,

We apologize for the inconvenience. Unfortunately, we were unable to include the fix for the issue, "Pasting from the Clipboard does not work after clearing the Worksheet," in today's NuGet package release as promised. We are still facing challenges in aligning the behavior with Excel after clearing the sheet and attempting to paste.
We are actively working to resolve this issue and ensure the expected Excel behavior. The fix is scheduled to be included in the upcoming weekly NuGet release on Jan 07, 2025.
We appreciate your patience and understanding as we continue to refine our solution.
Regards,
Malini Selvarasu


MS Malini Selvarasu Syncfusion Team January 7, 2025 02:07 PM UTC

Hi crosslife,

We have investigated the reported issue on our end. In the Spreadsheet, we handle the sheet and grid separately. For reference, any updates made to a sheet are internally processed in the grid, and similarly, any actions performed on the grid are processed in the sheet.

In this case, when clearing data from the active sheet, the ranges and their values are cleared. However, we do not receive any notifications from the sheet, which prevents us from clearing the grid-related implementations or APIs, ultimately causing the issue. To address this, we have customized the Spreadsheet to handle this scenario effectively. Refer to the below code snippet,

C# Code Snippet related to CustomCopyPaste:

/// <summary>

/// Provides custom copy-paste functionality for the spreadsheet.

/// </summary>

public class CustomCopyPaste : SpreadsheetCopyPaste

{

    /// <summary>

    /// Gets or sets the associated SfSpreadsheet instance.

    /// </summary>

    public SfSpreadsheet SpreadSheet { get; set; }

 

    /// <summary>

    /// Initializes a new instance of the EnhancedCopyPaste class.

    /// </summary>

    /// <param name="spreadsheet">The associated SfSpreadsheet instance.</param>

    public CustomCopyPaste(SfSpreadsheet spreadsheet)

        : base()

    {

        SpreadSheet = spreadsheet;

    }

 

    /// <summary>

    /// Clears the copied text in clipboard and resets copy-paste related properties.

    /// </summary>

    public void Clear()

    {

        var sourceRangeText = GetPrivateProperty("SourceRangeText");

        if (!string.IsNullOrEmpty(sourceRangeText))

        {

            Clipboard.Clear();

            SetPrivateProperty("SourceRangeText", null);

        }           

        SourceRange = null;

        SourceWorkbookRange = null;

        ClipboardText = null;

        SpreadSheet.GetType().GetMethod("RefreshCurrentCell", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(SpreadSheet, null);

    }

 

    /// <summary>

    /// Sets the value of a private property in the base class.

    /// </summary>

    private void SetPrivateProperty(string propertyName, object value)

    {

        this.GetType().BaseType.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic)

            .SetValue(this, value);

    }

 

    /// <summary>

    /// Get the value of a private property in the base class.

    /// </summary>

    private string GetPrivateProperty(string propertyName)

    {

        return (string)this.GetType().BaseType.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic)

            .GetValue(this);

    }
}

 C# Code Snippet related to Initialization of CustomCopyPaste and clear method:

public partial class MainWindow : Window

{

    public MainWindow()

    {

        InitializeComponent();

        // Initialize custom copy-paste functionality

        spreadsheet.CopyPaste = new CustomCopyPaste(spreadsheet);           

    }       

 

    /// <summary>

    /// Handles the Clear button click event.

    /// Clears the active worksheet and resets the copy-paste state.

    /// </summary>

    private void ClearButton_Click(object sender, RoutedEventArgs e)

    {           

        var worksheet = spreadsheet.ActiveSheet;

        worksheet.Clear();           

        // Clear the copy-paste properties

        (spreadsheet.CopyPaste as CustomCopyPaste)?.Clear();

        spreadsheet.ActiveGrid.InvalidateCells();

        //When clicking the button, the focus shifts to the button,

        //causing the focus to leave the spreadsheet. As a result, the Win + V key does not function as expected.

        //To resolve this issue, set the focus back to the active grid of the spreadsheet.

        spreadsheet.ActiveGrid.Focus();           

    }
}   

Find the modified sample demo in the attachment.

Regards,
Malini Selvarasu

Attachment: Modified_Sample_4_71ff1e28.zip

Loader.
Up arrow icon