Results 1 to 17 of 17

Thread: copy/move excel sheet with QT

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: copy/move excel sheet with QT

    It looks like you don't know how Copy works.

    here is the help
    http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx


    Looks like this is no longer Qt programming question...
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  2. #2

    Default Re: copy/move excel sheet with QT

    Hi,

    Thanks a lot yours link. It help me to find the solution. I need to pass the object worksheet for before or after parameter;

    so instead of

    Qt Code:
    1. sheet->dynamicCall("Copy");
    To copy to clipboard, switch view to plain text mode 

    I do

    Qt Code:
    1. worksheet_copy_after = sheets->querySubObject("Item( int )", 5 );
    2. QVariant param1 = worksheet_copy_after->asVariant();
    3. worksheet_to_copy->dynamicCall("Copy (const QVariant&)",param1);
    To copy to clipboard, switch view to plain text mode 

    and the copy occurs in the same worksheets!!!

    Thanks

  3. #3

    Default Re: copy/move excel sheet with QT

    In fact I success to copy before but not After

    according to : http://msdn.microsoft.com/en-US/libr...(v=vs.80).aspx

    I try to pass en empty Qvaraint to the first parameter but nothing happen.

    Qt Code:
    1. worksheet_copy_after = sheets->querySubObject("Item( int )", 5 );
    2. QVariant param1 = "missing";
    3. QVariant param2 = worksheet_copy_after->asVariant();
    4. worksheet_to_copy->dynamicCall("Copy (const QVariant&, const QVariant&)",param1,param2);
    To copy to clipboard, switch view to plain text mode 

    How can I do?

    Thanks

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: copy/move excel sheet with QT

    use a null QVariant, not a QVariant with a string="missing"
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5

    Default Re: copy/move excel sheet with QT

    I had already try with NULL variant (and a lot of stupid test that i prefer to not post here)

    but nothing is working

    Qt Code:
    1. worksheet_copy_after = sheets->querySubObject("Item( int )", 5 );
    2. QVariant param1 = NULL;
    3. QVariant param2 = worksheet_copy_after->asVariant();
    4. worksheet_to_copy->dynamicCall("Copy (const QVariant&, const QVariant&)",param1,param2);
    To copy to clipboard, switch view to plain text mode 

    any suggestion?

    thanks

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: copy/move excel sheet with QT

    QVariant param1 = NULL;

    does that even compile? I don't believe it is a null variant though - if it compiles it will be a QVariant of type string with string = "", or a QVariant of type int with value = 0, or something like that.

    This is how you make a null variant:

    QVariant param;
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  7. #7

    Default Re: copy/move excel sheet with QT

    Of course it compiles. I will not post something which not compile.

    Qt Code:
    1. worksheet_copy_after = sheets->querySubObject("Item( int )", 5 );
    2. QVariant param1;
    3. QVariant param2 = worksheet_copy_after->asVariant();
    4. worksheet_to_copy->dynamicCall("Copy (const QVariant&, const QVariant&)",param1,param2);
    To copy to clipboard, switch view to plain text mode 

    Doesn't work anymore!

  8. #8
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: copy/move excel sheet with QT

    only this idea, I don't know if it will work at all:

    Qt Code:
    1. QString after = worksheet_copy_after->asVariant().toString(); // don't know if this works!
    2. QString call("Copy(missing,%1)");
    3. call = call.arg(after);
    4.  
    5. activeX->dynamicCall(call.toLatin1().constData());
    To copy to clipboard, switch view to plain text mode 

    I thought of that after reading http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx and http://qt-project.org/doc/qt-4.8/qax...ml#dynamicCall. The problem is how to deal with 'missing' correctly. If you can think of some way to access System.Type.Missing then that will probably help.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  9. #9

    Default Re: copy/move excel sheet with QT

    Qt Code:
    1. QString after = worksheet_copy_after->asVariant().toString(); // don't know if this works!
    2. QString call("Copy(missing,%1)");
    3. call = call.arg(after);
    To copy to clipboard, switch view to plain text mode 
    seems working !
    Qt Code:
    1. activeX->dynamicCall(call.toLatin1().constData());
    To copy to clipboard, switch view to plain text mode 
    but what is your activeX?

  10. #10
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: copy/move excel sheet with QT

    worksheet_to_copy
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: copy/move excel sheet with QT

    Quote Originally Posted by amleto View Post
    QVariant param1 = NULL;

    does that even compile? I don't believe it is a null variant though - if it compiles it will be a QVariant of type string with string = "", or a QVariant of type int with value = 0, or something like that.

    This is how you make a null variant:

    QVariant param;
    NULL is:

    Qt Code:
    1. #define NULL 0L
    To copy to clipboard, switch view to plain text mode 

    therefore this:

    Qt Code:
    1. QVariant param1 = NULL;
    To copy to clipboard, switch view to plain text mode 

    stores an integer of value "0" in the variant.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QSettings: copy from ini to xml? Copy group?
    By TorAn in forum Qt Programming
    Replies: 1
    Last Post: 11th January 2012, 14:51
  2. Problem in Move Move Event Handler.
    By redgoof in forum Qt Programming
    Replies: 0
    Last Post: 7th April 2010, 11:45
  3. ActiveQt hosting Excel sheet
    By ArmanS in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2010, 10:27
  4. How to copy from Excel and paste to QTableView
    By sms in forum Qt Programming
    Replies: 5
    Last Post: 7th February 2009, 03:58
  5. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 05:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.