openpyxl how to read formula result after editing input data on the sheet? data_only=True gives me a “None” result










0














Using openpyxl, I'm able to read 2 numbers on a sheet, and also able to read their sum by loading the sheet with data_only=True.



However, when I alter the 2 numbers using openpyxl and then try to read the answer using data_only=True, it returns no output. How do I do this?










share|improve this question























  • From the docs "data_only controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet." Notice that neither of those options include evaluating the formula. What you want cannot be done with openpyxl.
    – Steven Rumbalski
    Nov 12 '18 at 23:58











  • @Idlehands afraid that doesn't work. 'Cell' object has no attribute 'value2'.
    – oktested
    Nov 13 '18 at 13:17










  • @oktested sorry I was in between Python and VBA so got them mixed up a little.
    – Idlehands
    Nov 13 '18 at 13:43















0














Using openpyxl, I'm able to read 2 numbers on a sheet, and also able to read their sum by loading the sheet with data_only=True.



However, when I alter the 2 numbers using openpyxl and then try to read the answer using data_only=True, it returns no output. How do I do this?










share|improve this question























  • From the docs "data_only controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet." Notice that neither of those options include evaluating the formula. What you want cannot be done with openpyxl.
    – Steven Rumbalski
    Nov 12 '18 at 23:58











  • @Idlehands afraid that doesn't work. 'Cell' object has no attribute 'value2'.
    – oktested
    Nov 13 '18 at 13:17










  • @oktested sorry I was in between Python and VBA so got them mixed up a little.
    – Idlehands
    Nov 13 '18 at 13:43













0












0








0







Using openpyxl, I'm able to read 2 numbers on a sheet, and also able to read their sum by loading the sheet with data_only=True.



However, when I alter the 2 numbers using openpyxl and then try to read the answer using data_only=True, it returns no output. How do I do this?










share|improve this question















Using openpyxl, I'm able to read 2 numbers on a sheet, and also able to read their sum by loading the sheet with data_only=True.



However, when I alter the 2 numbers using openpyxl and then try to read the answer using data_only=True, it returns no output. How do I do this?







python excel openpyxl






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 10:51









Aqueous Carlos

293213




293213










asked Nov 12 '18 at 23:39









oktestedoktested

91




91











  • From the docs "data_only controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet." Notice that neither of those options include evaluating the formula. What you want cannot be done with openpyxl.
    – Steven Rumbalski
    Nov 12 '18 at 23:58











  • @Idlehands afraid that doesn't work. 'Cell' object has no attribute 'value2'.
    – oktested
    Nov 13 '18 at 13:17










  • @oktested sorry I was in between Python and VBA so got them mixed up a little.
    – Idlehands
    Nov 13 '18 at 13:43
















  • From the docs "data_only controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet." Notice that neither of those options include evaluating the formula. What you want cannot be done with openpyxl.
    – Steven Rumbalski
    Nov 12 '18 at 23:58











  • @Idlehands afraid that doesn't work. 'Cell' object has no attribute 'value2'.
    – oktested
    Nov 13 '18 at 13:17










  • @oktested sorry I was in between Python and VBA so got them mixed up a little.
    – Idlehands
    Nov 13 '18 at 13:43















From the docs "data_only controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet." Notice that neither of those options include evaluating the formula. What you want cannot be done with openpyxl.
– Steven Rumbalski
Nov 12 '18 at 23:58





From the docs "data_only controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet." Notice that neither of those options include evaluating the formula. What you want cannot be done with openpyxl.
– Steven Rumbalski
Nov 12 '18 at 23:58













@Idlehands afraid that doesn't work. 'Cell' object has no attribute 'value2'.
– oktested
Nov 13 '18 at 13:17




@Idlehands afraid that doesn't work. 'Cell' object has no attribute 'value2'.
– oktested
Nov 13 '18 at 13:17












@oktested sorry I was in between Python and VBA so got them mixed up a little.
– Idlehands
Nov 13 '18 at 13:43




@oktested sorry I was in between Python and VBA so got them mixed up a little.
– Idlehands
Nov 13 '18 at 13:43












2 Answers
2






active

oldest

votes


















0














You can have either the value or the formula in openpyxl. It is precisely to avoid the confusion that this kind of edit could introduce that the library works like this. To evaluate the changed formulae you'll need to load the file in an app like MS Excel or LibreOffice that can evaluate the formulae and store the results.






share|improve this answer




















  • Nice to get a reply from the man himself. Congrats on the work so far and pls keep going! I'm not changing the formula itself - I just want to use the same formula on a new set of inputs that I'm entering into excel using openpyxl. Basically I have a complex sheet of formulas already and I need openpyxl to repeatedly use those formulas on new inputs, and read the results back to python. I presume this is not possible in openpyxl? This would make openpyxl super-powerful (context: I'm an investment banker from the fixed income space, trying to upgrade my skills with some python). Thnx!
    – oktested
    Nov 13 '18 at 13:13











  • You could now write your own formula engine with the tokeniser but that way madness lies (dependencies and possible infitite loops). Excel and LibreOffice have optimisations for that, so much better to make the changes in openpyxl and let them do the calculations, especially as you can remote control them.
    – Charlie Clark
    Nov 13 '18 at 14:06










  • Apologies - I didn't understand your reply. By "write your own formula engine with the tokeniser", are you referring to making all the formulas in Python instead of excel, so as to leave Excel altogether? Secondly, when you say, "make the changes in openpyxl and let them do the calculations", the "them" refers to Excel? Sorry I'm not clear what your recommendation is.
    – oktested
    Nov 14 '18 at 4:02


















0














openpyxl data_only flag set to true only get the formula evaluated value when load the file.
Even more, the data_only can only get the value if some tool such as MS Excel already evaluated the formula and stored the cached value, or openpyxl will get None.
I found it from this answer






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271690%2fopenpyxl-how-to-read-formula-result-after-editing-input-data-on-the-sheet-data%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can have either the value or the formula in openpyxl. It is precisely to avoid the confusion that this kind of edit could introduce that the library works like this. To evaluate the changed formulae you'll need to load the file in an app like MS Excel or LibreOffice that can evaluate the formulae and store the results.






    share|improve this answer




















    • Nice to get a reply from the man himself. Congrats on the work so far and pls keep going! I'm not changing the formula itself - I just want to use the same formula on a new set of inputs that I'm entering into excel using openpyxl. Basically I have a complex sheet of formulas already and I need openpyxl to repeatedly use those formulas on new inputs, and read the results back to python. I presume this is not possible in openpyxl? This would make openpyxl super-powerful (context: I'm an investment banker from the fixed income space, trying to upgrade my skills with some python). Thnx!
      – oktested
      Nov 13 '18 at 13:13











    • You could now write your own formula engine with the tokeniser but that way madness lies (dependencies and possible infitite loops). Excel and LibreOffice have optimisations for that, so much better to make the changes in openpyxl and let them do the calculations, especially as you can remote control them.
      – Charlie Clark
      Nov 13 '18 at 14:06










    • Apologies - I didn't understand your reply. By "write your own formula engine with the tokeniser", are you referring to making all the formulas in Python instead of excel, so as to leave Excel altogether? Secondly, when you say, "make the changes in openpyxl and let them do the calculations", the "them" refers to Excel? Sorry I'm not clear what your recommendation is.
      – oktested
      Nov 14 '18 at 4:02















    0














    You can have either the value or the formula in openpyxl. It is precisely to avoid the confusion that this kind of edit could introduce that the library works like this. To evaluate the changed formulae you'll need to load the file in an app like MS Excel or LibreOffice that can evaluate the formulae and store the results.






    share|improve this answer




















    • Nice to get a reply from the man himself. Congrats on the work so far and pls keep going! I'm not changing the formula itself - I just want to use the same formula on a new set of inputs that I'm entering into excel using openpyxl. Basically I have a complex sheet of formulas already and I need openpyxl to repeatedly use those formulas on new inputs, and read the results back to python. I presume this is not possible in openpyxl? This would make openpyxl super-powerful (context: I'm an investment banker from the fixed income space, trying to upgrade my skills with some python). Thnx!
      – oktested
      Nov 13 '18 at 13:13











    • You could now write your own formula engine with the tokeniser but that way madness lies (dependencies and possible infitite loops). Excel and LibreOffice have optimisations for that, so much better to make the changes in openpyxl and let them do the calculations, especially as you can remote control them.
      – Charlie Clark
      Nov 13 '18 at 14:06










    • Apologies - I didn't understand your reply. By "write your own formula engine with the tokeniser", are you referring to making all the formulas in Python instead of excel, so as to leave Excel altogether? Secondly, when you say, "make the changes in openpyxl and let them do the calculations", the "them" refers to Excel? Sorry I'm not clear what your recommendation is.
      – oktested
      Nov 14 '18 at 4:02













    0












    0








    0






    You can have either the value or the formula in openpyxl. It is precisely to avoid the confusion that this kind of edit could introduce that the library works like this. To evaluate the changed formulae you'll need to load the file in an app like MS Excel or LibreOffice that can evaluate the formulae and store the results.






    share|improve this answer












    You can have either the value or the formula in openpyxl. It is precisely to avoid the confusion that this kind of edit could introduce that the library works like this. To evaluate the changed formulae you'll need to load the file in an app like MS Excel or LibreOffice that can evaluate the formulae and store the results.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 13 '18 at 8:20









    Charlie ClarkCharlie Clark

    9,72322233




    9,72322233











    • Nice to get a reply from the man himself. Congrats on the work so far and pls keep going! I'm not changing the formula itself - I just want to use the same formula on a new set of inputs that I'm entering into excel using openpyxl. Basically I have a complex sheet of formulas already and I need openpyxl to repeatedly use those formulas on new inputs, and read the results back to python. I presume this is not possible in openpyxl? This would make openpyxl super-powerful (context: I'm an investment banker from the fixed income space, trying to upgrade my skills with some python). Thnx!
      – oktested
      Nov 13 '18 at 13:13











    • You could now write your own formula engine with the tokeniser but that way madness lies (dependencies and possible infitite loops). Excel and LibreOffice have optimisations for that, so much better to make the changes in openpyxl and let them do the calculations, especially as you can remote control them.
      – Charlie Clark
      Nov 13 '18 at 14:06










    • Apologies - I didn't understand your reply. By "write your own formula engine with the tokeniser", are you referring to making all the formulas in Python instead of excel, so as to leave Excel altogether? Secondly, when you say, "make the changes in openpyxl and let them do the calculations", the "them" refers to Excel? Sorry I'm not clear what your recommendation is.
      – oktested
      Nov 14 '18 at 4:02
















    • Nice to get a reply from the man himself. Congrats on the work so far and pls keep going! I'm not changing the formula itself - I just want to use the same formula on a new set of inputs that I'm entering into excel using openpyxl. Basically I have a complex sheet of formulas already and I need openpyxl to repeatedly use those formulas on new inputs, and read the results back to python. I presume this is not possible in openpyxl? This would make openpyxl super-powerful (context: I'm an investment banker from the fixed income space, trying to upgrade my skills with some python). Thnx!
      – oktested
      Nov 13 '18 at 13:13











    • You could now write your own formula engine with the tokeniser but that way madness lies (dependencies and possible infitite loops). Excel and LibreOffice have optimisations for that, so much better to make the changes in openpyxl and let them do the calculations, especially as you can remote control them.
      – Charlie Clark
      Nov 13 '18 at 14:06










    • Apologies - I didn't understand your reply. By "write your own formula engine with the tokeniser", are you referring to making all the formulas in Python instead of excel, so as to leave Excel altogether? Secondly, when you say, "make the changes in openpyxl and let them do the calculations", the "them" refers to Excel? Sorry I'm not clear what your recommendation is.
      – oktested
      Nov 14 '18 at 4:02















    Nice to get a reply from the man himself. Congrats on the work so far and pls keep going! I'm not changing the formula itself - I just want to use the same formula on a new set of inputs that I'm entering into excel using openpyxl. Basically I have a complex sheet of formulas already and I need openpyxl to repeatedly use those formulas on new inputs, and read the results back to python. I presume this is not possible in openpyxl? This would make openpyxl super-powerful (context: I'm an investment banker from the fixed income space, trying to upgrade my skills with some python). Thnx!
    – oktested
    Nov 13 '18 at 13:13





    Nice to get a reply from the man himself. Congrats on the work so far and pls keep going! I'm not changing the formula itself - I just want to use the same formula on a new set of inputs that I'm entering into excel using openpyxl. Basically I have a complex sheet of formulas already and I need openpyxl to repeatedly use those formulas on new inputs, and read the results back to python. I presume this is not possible in openpyxl? This would make openpyxl super-powerful (context: I'm an investment banker from the fixed income space, trying to upgrade my skills with some python). Thnx!
    – oktested
    Nov 13 '18 at 13:13













    You could now write your own formula engine with the tokeniser but that way madness lies (dependencies and possible infitite loops). Excel and LibreOffice have optimisations for that, so much better to make the changes in openpyxl and let them do the calculations, especially as you can remote control them.
    – Charlie Clark
    Nov 13 '18 at 14:06




    You could now write your own formula engine with the tokeniser but that way madness lies (dependencies and possible infitite loops). Excel and LibreOffice have optimisations for that, so much better to make the changes in openpyxl and let them do the calculations, especially as you can remote control them.
    – Charlie Clark
    Nov 13 '18 at 14:06












    Apologies - I didn't understand your reply. By "write your own formula engine with the tokeniser", are you referring to making all the formulas in Python instead of excel, so as to leave Excel altogether? Secondly, when you say, "make the changes in openpyxl and let them do the calculations", the "them" refers to Excel? Sorry I'm not clear what your recommendation is.
    – oktested
    Nov 14 '18 at 4:02




    Apologies - I didn't understand your reply. By "write your own formula engine with the tokeniser", are you referring to making all the formulas in Python instead of excel, so as to leave Excel altogether? Secondly, when you say, "make the changes in openpyxl and let them do the calculations", the "them" refers to Excel? Sorry I'm not clear what your recommendation is.
    – oktested
    Nov 14 '18 at 4:02













    0














    openpyxl data_only flag set to true only get the formula evaluated value when load the file.
    Even more, the data_only can only get the value if some tool such as MS Excel already evaluated the formula and stored the cached value, or openpyxl will get None.
    I found it from this answer






    share|improve this answer

























      0














      openpyxl data_only flag set to true only get the formula evaluated value when load the file.
      Even more, the data_only can only get the value if some tool such as MS Excel already evaluated the formula and stored the cached value, or openpyxl will get None.
      I found it from this answer






      share|improve this answer























        0












        0








        0






        openpyxl data_only flag set to true only get the formula evaluated value when load the file.
        Even more, the data_only can only get the value if some tool such as MS Excel already evaluated the formula and stored the cached value, or openpyxl will get None.
        I found it from this answer






        share|improve this answer












        openpyxl data_only flag set to true only get the formula evaluated value when load the file.
        Even more, the data_only can only get the value if some tool such as MS Excel already evaluated the formula and stored the cached value, or openpyxl will get None.
        I found it from this answer







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 9:39









        cublecuble

        15617




        15617



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271690%2fopenpyxl-how-to-read-formula-result-after-editing-input-data-on-the-sheet-data%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3