Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 829861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:56:54+00:00 2026-05-15T03:56:54+00:00

I have a Excel addin that displays some structures on the worksheet. Users can

  • 0

I have a Excel addin that displays some structures on the worksheet. Users can copy the structures and paste them in another worksheet or another application which is handled by the Clipboard formats. When a user copies the structure, I convert the structure into a specific format and put it on the clipboard using the DataObject::SetData(). Please note that when a copy is initiated in Excel, it puts a number of formats on the clipboard (see image).

The problem is that there is a third party application that depends on the data on the clipboard(Copy from Excel and paste into this 3rd party app) but the funny thing is that I am not sure which format it depends on. I need to preserve the existing formats that Excel has put up there and also add my own format to it.

Currently when I use the Clipboard class in .NET (taking the DataObject and calling SetData inside it), all the other formats are replaced by new ones.
I then tried to create a new DataObject, copy the existing format data to this data object and then set this data object in the Clipboard. This works fine but it takes time to copy the data.

 // Copying existing data in clipboard to our new DataObject
 IDataObject existingDataObject = Clipboard.GetDataObject();
 DataObject dataObject = new DataObject();

 string[] existingFormats = existingDataObject.GetFormats();
 foreach (string existingFormat in existingFormats)
        dataObject.SetData(existingFormat, existingDataObject.GetData(existingFormat));

I am looking for a solution to just access the existing DataObject and quietly add my own data to it without affecting other formats.

Excel Clipboard Formats – (Ignore the Native Format)

Clipboard Formats http://www.freeimagehosting.net/uploads/258a7fcdd8.jpg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:56:55+00:00Added an answer on May 15, 2026 at 3:56 am

    You could create a wrapper class for the IDataObject that you get from the Windows clipboard to add your data. The idea is that the wrapper would know about your custom formats and delegate to the original, wrapped IDataObject for all other formats.

    Here’s a partial implementation showing the constructor and one of the IDataObject method implementations:

    public class MyDataObject : IDataObject
    {
        public MyDataObject(IDataObject inner, string format, Type type, object data)
        {
            m_inner = inner;
            m_format = format;
            m_type = type;
            m_data = data;
        }
        private IDataObject m_inner;
        private string m_format;
        private Type m_type;
        private object m_data;
    
        object IDataObject.GetData(string format)
        {
            // if my format, return the wrapper data
            if (format == m_format)
                return object;
    
            // otherwise, delegate to the wrapped data object which holds
            //  the other formats
            return m_inner.GetData(format);
        }
    
        // implement the rest of IDataObject similarly
        ...
    }
    

    One caveat: When retrieving the system clipboard IDataObject, you’ll have to check if it’s one of your wrapper objects. In that case, you don’t want to keep wrapping your wrappers. Instead you’d want to either modify the data/format fields of the existing wrapper, or create a new wrapper for the original clipboard data object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.