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.
  • Andy314A Offline
    Andy314A Offline
    Andy314
    wrote on last edited by Andy314
    #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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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);

      Andy314A 1 Reply Last reply
      0
      • mrjjM mrjj

        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);

        Andy314A Offline
        Andy314A Offline
        Andy314
        wrote on last edited by Andy314
        #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 ?

        Andy314A 1 Reply Last reply
        0
        • Andy314A Andy314

          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 ?

          Andy314A Offline
          Andy314A Offline
          Andy314
          wrote on last edited by Andy314
          #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

          • Login

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