Announcement

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

  • Stata 17 Table command - shading cells for .docx documents

    Hi,

    I'm having a problem with the new stata 17 table command. I want to output tables to .docx where cells are coloured according to their values. My problem is that the shading only highlights the value and does not apply to the whole cell.

    Click image for larger version

Name:	table shading.PNG
Views:	1
Size:	10.3 KB
ID:	1623719

    Does anyone have any ideas how I can get the whole cell to be shaded?


    Code:
    webuse auto7.dta, clear
    
    table (headroom) (foreign), statistic(mean price)
    
     
     collect style cell foreign[1]#headroom[2.5], shading(background(aqua)) border(all)
     collect style cell foreign[0]#headroom[4.5], shading(background(lime)) border(all)
    
     collect export  "shading example.docx", replace

  • #2
    Stata technical support came back with this which worked perfectly.

    Code:
    putdocx clear
    
    webuse auto7.dta, clear
    
    table (headroom) (foreign), statistic(mean price)
    
    collect style cell foreign[1]#headroom[2.5], shading(background(aqua)) border(all)
    
    collect style cell foreign[0]#headroom[4.5], shading(background(lime)) border(all)
    
    putdocx begin
    
    putdocx collect
    
    putdocx table tbl1(6,3), shading(aqua)
    
    putdocx table tbl1(10,2), shading(lime)
    
    putdocx save example.docx, replace

    Comment

    Working...
    X