Dragging data to Excel using DoDragDrop

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bruce_Stough

    #1

    Dragging data to Excel using DoDragDrop

    I am currently using Control.DoDragD rop to drop a text string into Excel. I
    use the following code

    DataObject dd = new DataObject();
    dd.SetData(Data Formats.Text,"\ \\\ws-it-bstough\\ShareF older\\Test.wav ");
    DoDragDrop(dd,D ragDropEffects. Copy);

    The code works as expected but it will always populate into Excel as a
    string literal and not as a link to the audio file. If I type the path into
    a excel the link appears correctly. I am using a windows form in C# to
    initiate the drag request.

    Any Suggestions ?


    Bruce Stough


  • Peter Duniho

    #2
    Re: Dragging data to Excel using DoDragDrop

    Bruce_Stough wrote:
    I am currently using Control.DoDragD rop to drop a text string into
    Excel. I use the following code
    >
    DataObject dd = new DataObject();
    dd.SetData(Data Formats.Text,"\ \\\ws-it-bstough\\ShareF older\\Test.wav ");
    DoDragDrop(dd,D ragDropEffects. Copy);
    >
    The code works as expected but it will always populate into Excel as a
    string literal and not as a link to the audio file. If I type the path
    into a excel the link appears correctly. I am using a windows form in
    C# to initiate the drag request.
    >
    Any Suggestions ?
    I'm not sure you're going to be able to do that using the Text data
    format. I've noticed in the past that Excel won't auto-recognize URLs,
    UNC paths, etc. except when parsing direct user-input.

    If you were using automation, there might be a way to get it to do the
    recognition explicitly, but AFAIK you can't hook that up to a simple D&D
    operation.

    The one thing that does come to mind is the possibility of creating a
    ..lnk format object for the DataObject. That might be in a format Excel
    would recognize and paste in as an actual link.

    Of course, how exactly to do that doesn't come immediately to mind. I
    guess you'll have to look into that yourself. But it's a thought
    anyway. :)

    Pete

    Comment

    • Adrian Gallero

      #3
      Re: Dragging data to Excel using DoDragDrop

      Hi Bruce,

      Bruce_Stough wrote:
      >
      The code works as expected but it will always populate into Excel as
      a string literal and not as a link to the audio file. If I type the
      path into a excel the link appears correctly. I am using a windows
      form in C# to initiate the drag request.
      >
      Any Suggestions ?
      >

      I am not sure if you can use third party comopnents, but if that is
      possible, we fully support dragging and dropping native xls data
      (including hyperlinks) to and from Excel.

      If you are insterested, you can take a look at
      Discover TMS Software's comprehensive suites of VCL, FMX, .NET and FNC components tailored for Delphi, C++Builder, Visual Studio developers. Elevate your Windows, Web, iOS, Android, macOS and Linux development with our cutting-edge tools, including cross-platform UI frameworks, reporting solutions, web development kits, and data management systems. Experience seamless integration and enhanced productivity with TMS Software's innovative solutions for modern software development.


      download it, run the demo from the start menu, and select "API->Copy
      and Paste" demo from the left menu. In the demo you will be able to
      drag an hyperlink from Excel to the demo app, and then drag it again
      from the demo app to Excel. Of course your app you can create the
      hyperlink directly and let the user drag it to Excel.

      The xls reading/writing/reporting part of FlexCel is free for non
      commercial use, so it should be not a problem if your app is non
      commercial. If it is commercial, I believe the price is quite
      affordable anyway, and will pay itself very fast.

      Best regards,
      Adrian.



      Comment

      • =?Utf-8?B?QnJ1Y2VfU3RvdWdo?=

        #4
        Re: Dragging data to Excel using DoDragDrop

        Thanks Peter,
        I have tried to use a LinkLabel object as well but Excel seems to be
        rejecting all requests with the exception of Text, Bitmap or Metafile. I
        will keep at it, and judging from the next sales post it is indeed possible.
        :)

        --
        Bruce Stough
        CTI-Results.Com


        "Peter Duniho" wrote:
        Bruce_Stough wrote:
        I am currently using Control.DoDragD rop to drop a text string into
        Excel. I use the following code

        DataObject dd = new DataObject();
        dd.SetData(Data Formats.Text,"\ \\\ws-it-bstough\\ShareF older\\Test.wav ");
        DoDragDrop(dd,D ragDropEffects. Copy);

        The code works as expected but it will always populate into Excel as a
        string literal and not as a link to the audio file. If I type the path
        into a excel the link appears correctly. I am using a windows form in
        C# to initiate the drag request.

        Any Suggestions ?
        >
        I'm not sure you're going to be able to do that using the Text data
        format. I've noticed in the past that Excel won't auto-recognize URLs,
        UNC paths, etc. except when parsing direct user-input.
        >
        If you were using automation, there might be a way to get it to do the
        recognition explicitly, but AFAIK you can't hook that up to a simple D&D
        operation.
        >
        The one thing that does come to mind is the possibility of creating a
        ..lnk format object for the DataObject. That might be in a format Excel
        would recognize and paste in as an actual link.
        >
        Of course, how exactly to do that doesn't come immediately to mind. I
        guess you'll have to look into that yourself. But it's a thought
        anyway. :)
        >
        Pete
        >

        Comment

        • Peter Duniho

          #5
          Re: Dragging data to Excel using DoDragDrop

          Adrian Gallero wrote:
          [...]
          I doubted a lot before posting, because I know mentioning your own
          product has an adverse effect on many people, (and I am not going to
          post under a fake account) but I thought this could honestly help.
          After all, if this was not the correct solution for him, he could just
          dismiss the message. Now really after reading both Bruce's and your
          answer, I think I maybe should have keep myself shut.
          Or perhaps you could have just been a little more clear about things.

          I don't think that there's any need to have an absolute prohibition on
          mentioning one's own products. There are indeed situations in which
          it's appropriate to mention that as a possible solution. But your post
          was missing some elements that IMHO would have been important in
          differentiating a post that's a really honest attempt to be helpful from
          a post intended simply to market one's own product.

          Note that I'm not saying your intent wasn't honest. I'm simply saying
          it wasn't immediately apparent from the post you made.
          The reason I did not post a "suggestion on how to do it yourself" is
          just because I don't know one. But I do know how to do it using our
          library, and that is what I said.
          Well, one thing you might have mentioned is that you don't actually know
          how to do it yourself. Nothing in your post made it clear that in spite
          of being involved with a product that apparently supports this feature,
          you yourself had no involvement or understanding of the actual
          implementation of that feature.

          Obviously it would be unreasonable for anyone to be disappointed in you
          for not sharing information you yourself do not have.
          The solution I mentioned is simple on the conceptual part, and I am
          glad to answer any question I can answer about it.
          It just puts a "biff8" object into the clipboard, or drags a biff8
          object into Excel. Just in case, Biff8 is the native file format in
          Excel. And the code to do that is on the demo I mentioned, all source
          for the demo is included in the file you can freely download from the
          page. So I don't know what else I could have said.
          Nothing in your post mentioned the availability of source code. Nor is
          it clear from your post (or even now) that you are offering the source
          code itself as a guide to a solution, as opposed to requiring some
          payment to use the code.

          IMHO, assuming Bruce doesn't just copy your code wholesale, but rather
          just implements his own solution based on techniques found in your code,
          that would be a fine approach for him to technique. I doubt you'd have
          legal standing to demand payment from him either in that scenario.

          But you didn't write anything in your post suggesting that as a
          solution. You didn't even mention that the source code was available.
          Just that you had a library he could license for that use.
          [...]
          >Now, whether this is a justifiable effort on your part depends on how
          >closely tied to Excel you want to be. This would definitely be an
          >Excel-specific thing, and might not be worth doing if your
          >application is to support drag-and-drop to a wider variety of
          >programs. But if you're writing something that is specifically to be
          >used with Excel, it might be worth the effort.
          >
          You can copy more than one format to the clipboard. for example, text
          for apps that do not understand biff8, and biff8 for Excel.
          Yes. Believe it or not, I do understand that. My point is that
          applications don't generally go around putting every possible format of
          data onto the clipboard. An application would generally only put
          Excel's format on the clipboard if there was a high expectation that the
          target application would be Excel.

          If Bruce is writing an application that just happens to paste file
          references as text to the clipboard to be used by a wide variety of
          applications, he may simply want to accept Excel's limitation as given
          and not bother working around it (and IMHO this is definitely a
          limitation in Excel...there's no fundamental reason Excel couldn't do
          the same "link recognition" when pasting data as it does in other
          scenarios).

          On the other hand, if his application is designed specifically to work
          with Excel, then yes...it likely would make a lot of sense to do
          whatever work is required to ensure a seamless interaction between the
          two applications.

          Pete

          Comment

          • Adrian Gallero

            #6
            Re: Dragging data to Excel using DoDragDrop

            Peter,

            You have expressed your opinion, I have expressed mine, and I don't
            think it makes sense to repeat it again and again.

            I think the root of all our misunderstandin gs is here:
            >However, this forum is primarily for helping other people implement
            >their own code.
            I believe this forum is primarily for helping other people solve their
            problems.

            In you light, what you said makes sense. In my pov, whay I said (and
            did) makes sense too.

            This is my last post here, since this is not going nowhere.
            Best regards,
            Adrian.

            Comment

            • Adrian Gallero

              #7
              Re: Dragging data to Excel using DoDragDrop

              Hi Bruce,

              Nice to know you could get something constructive after all. Hope you
              can solve your problems, and if you have any doubt where you think I
              can help about your implementation, please feel free to contact me.

              Good luck :)
              Adrian.
              Thanks Peter, Adrian
              I am sorry I misunderstood the original postings, but the
              followups have been very insiteful. I will take a look at the biff8
              format and see what it has to offer. After taking Peter's suggestion
              I did notice that a memorywriter object is returned as the
              dataformats are pretty much all encompassing. I assume this is the
              standard return for a serializable object though.
              I will post again as soon as everything becomes clear :)
              >
              Thanks again for everyones help.


              --

              Comment

              • Peter Duniho

                #8
                Re: Dragging data to Excel using DoDragDrop

                Adrian Gallero wrote:
                You have expressed your opinion, I have expressed mine, and I don't
                think it makes sense to repeat it again and again.
                Yet, you keep doing so. Odd.
                I think the root of all our misunderstandin gs is here:
                >
                >However, this forum is primarily for helping other people implement
                >their own code.
                >
                I believe this forum is primarily for helping other people solve their
                problems.
                And I believe that's far too general a description.

                We are writing code here. As I've said, I'm not actually promoting a
                no-exceptions rule to exclude any reference to third-party libraries.
                Sometimes those are just the right solution.

                But the preferred solutions should be in the form of real, usable code
                that uses the .NET Framework (and only the .NET Framework) to solve the
                problem. If a person has knowledge that would allow that form of
                solution to be posted, they should share that rather than just hawking
                their own wares.

                And just to try to make this even more clear, since this doesn't seem to
                be registering with you: at this point, it's clear you don't have that
                knowledge, and so of course I don't fault you for not posting it. It's
                just that your first post did not make this clear at all, thus my
                initial reaction.

                My primary complaint (if you can even call it that) at this point is
                with respect to the potential improvement with respect to communicating
                why you posted what you did instead of a full solution.

                Like I said, if you can't post the actual answer to the question, that's
                fine. But you should say so, to avoid any misunderstandin g as to
                whether you are simply refusing to share your own knowledge in deference
                to selling a product.

                And to reiterate: it's simply the avoidance of the misunderstandin g that
                I'm talking about. If you don't mind the misunderstandin g, then there's
                absolutely no need for you to concern yourself with my comments.

                I do think it's a bit silly of you to say that your original post was
                perfectly clear; it seems to me that the mere fact that this thread has
                taken the direction it has is proof enough that there's room for
                improvement on the clarity front. But hey, that's your business. If
                you think I'm wrong about that, there's no need for you to be offended
                or argue about it. Just move on.

                If you do insist on arguing about it, I am happy to oblige. At least,
                to a point much farther than I suspect most people would. Even I have
                my limits. :)
                In you light, what you said makes sense. In my pov, whay I said (and
                did) makes sense too.
                >
                This is my last post here, since this is not going nowhere.
                You said that before too.

                Pete

                Comment

                • Adrian Gallero

                  #9
                  Re: Dragging data to Excel using DoDragDrop

                  Hi Bruce,

                  Just an idea I had this morning (I sometimes can't help having those
                  ideas in the morning...)

                  You might try putting an RTF object in the clipboard. It will not be as
                  nice as a biff8 object, but Excel will probably understand the
                  hyperlink, and creating an RTF file is much easier than creating a
                  biff8 file. I have not tested it so I can not tell you if it works, but
                  it surely is worth a try.

                  Best regards,
                  Adrian.

                  Comment

                  Working...