Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAxObject->Excel setNumberFormat does not work
Forum Updated to NodeBB v4.3 + New Features

QAxObject->Excel setNumberFormat does not work

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andy314
    wrote on 12 Nov 2016, 18:59 last edited by Andy314 11 Dec 2016, 19:09
    #1

    Hello,
    I tried to set the format of a date-Excel-cell.

    It does not work, I get always the standard format.

    Its most likely not a Qt problem, but maybe someone had the same problem. Here is my code. Obj is the QAxObject* for the Cell, QString f;

           Obj->setProperty("NumberFormat", f);
           Obj->dynamicCall("SetNumberFormat(const QString&)", f); 
           Obj->setProperty("NumberFormatLocal", f);
           Obj->dynamicCall("SetNumberFormatLocal(const QString&)", f); 
    
        ```
    Nothing works !
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 12 Nov 2016, 19:19 last edited by
      #2

      Hi
      Are you sure a Cell has SetNumberFormat ?
      https://msdn.microsoft.com/en-us/library/office/ff196401.aspx
      Seems to be from the Range object.

      Maybe something like
      QAxObject * range = worksheet->querySubObject("Cells(int,int)", 1, 1);
      if (!range) { qDebug()<<"range does not exist"; return };
      range->dynamicCall("SetNumberFormat(const QString&)", formatStr);

      A 1 Reply Last reply 12 Nov 2016, 20:03
      0
      • M mrjj
        12 Nov 2016, 19:19

        Hi
        Are you sure a Cell has SetNumberFormat ?
        https://msdn.microsoft.com/en-us/library/office/ff196401.aspx
        Seems to be from the Range object.

        Maybe something like
        QAxObject * range = worksheet->querySubObject("Cells(int,int)", 1, 1);
        if (!range) { qDebug()<<"range does not exist"; return };
        range->dynamicCall("SetNumberFormat(const QString&)", formatStr);

        A Offline
        A Offline
        Andy314
        wrote on 12 Nov 2016, 20:03 last edited by Andy314 11 Dec 2016, 20:21
        #3

        Hello @mrjj ,
        I use a similar code like you. My Obj is your range of one cell.
        The Obj is a correct pointer, it works, I can Obj->setProperty("Value", var);

        After setting the NumberFormat, I read the it and get always the german standard format "TT.MM.JJJJ hh:mm".

        Obj->property("NumberFormat").toString();
        

        PS: I there a way to find out if a ActiveX call has worked/ was accepted ?

        A 1 Reply Last reply 12 Nov 2016, 20:33
        0
        • A Andy314
          12 Nov 2016, 20:03

          Hello @mrjj ,
          I use a similar code like you. My Obj is your range of one cell.
          The Obj is a correct pointer, it works, I can Obj->setProperty("Value", var);

          After setting the NumberFormat, I read the it and get always the german standard format "TT.MM.JJJJ hh:mm".

          Obj->property("NumberFormat").toString();
          

          PS: I there a way to find out if a ActiveX call has worked/ was accepted ?

          A Offline
          A Offline
          Andy314
          wrote on 12 Nov 2016, 20:33 last edited by Andy314 11 Dec 2016, 20:34
          #4

          I have found it, stupid error.
          The format string, I simple copied from a demo code was not invalid.

          Nevertheless my last question stays:
          I there a way to find out if a ActiveX call has worked/ was accepted ?

          1 Reply Last reply
          0

          1/4

          12 Nov 2016, 18:59

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved