Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • putexcel png changes the dimensions of an image

    Dear all,

    I am trying to export a graph to excel using putexcel. The png image is normal dimensions but when I put in excel the image appears stretched. The code is below and I have specified the desired width and height, the png itself is the correct dimensions but when it is put in excel the image appears vertically stretch. This is the same no matter what width or height I set, I have also tried using a different image format such as jpg and still have the same problem.

    Code:
    graph export "age_sex_graph.png", replace width(550) height(300)
    putexcel set "output.xlsx", sheet(graph1_2age_sex) modify  
    putexcel B3=picture(age_sex_graph.png)
    thanks for your help

  • #2
    Hi all,

    Just posting an update to this problem.

    When I add the option 'replace' to the command (below) the correct dimensions are exported. It is only when I then re run the code using just the modify option (as I do not want to overwrite other results I am exporting) that this problem appears. Does anyone have any ideas if this is a problem within Stata or there are other options I could add to prevent this happening, I have of course also tried adding sheetreplace into sheet options as shown below.


    Code:
     //1 running this exports graphs as the correct dimensions
    putexcel set "output.xlsx", sheet(graph1_2age_sex, replace) modify replace  
    
     //2 re running option 1 to modify results changes graph dimensions and 'squishes it'
    putexcel set "output.xlsx", sheet(graph1_2age_sex, replace) modify
    Last edited by Yumi Nito; 31 Jul 2023, 09:13.

    Comment

    Working...
    X