Hello all,
Question:
Is there a way to format column width in an excel file that is produced using -putexcel -?
This is my first week using -putexcel- and it's been a great learning experience.
Per the advice on posting, I've already searched the online help for Stata, used Stata's searched command, read through the manuals, and the bulletin and journal. I've also recently attended the very helpful stata webinar on Reproducible Reporting done by Gabriela.
I am worried that what I'm hoping for does not yet exist.
Here's a sample of the data, which has been saved as "SampleData01.dta."
Missing (as far as I can tell) are the variable labels which have even more characters in them because the intent of this file is to be public-facing and so end-user friendly.
Those variable labels are: Employer, AUN, Starting Salary, Year (Spring Semester), and County.
Here's my code so far:
****************
save "SampleData01.dta", replace
export excel using "SampleData01.xlsx", firstrow(varlabels) nolabel replace
putexcel set "SampleData01.xlsx", modify
putexcel A1:e700, font("Aptos", 11) hcenter
putexcel A1:e1, fpattern(solid,lightgray) hcenter border(all, medium) bold
putexcel C2:C700, nformat(#,###)
*****************
The file created by - putexcel - has columns that aren't wide enough for:
-- the column headers in columns: A, C, and D
-- the text data in columns A and E
-- the numeric data in column B.
Is there a way to automatically or manually set the excel file's column widths so that they are wide enough?
I have tried - txtwrap - and that is not the solution because the columns are so narrow the - txtwrap - causes individual words to be wrapped over two lines.
Thanks for your consideration of this puzzle.
Question:
Is there a way to format column width in an excel file that is produced using -putexcel -?
This is my first week using -putexcel- and it's been a great learning experience.
Per the advice on posting, I've already searched the online help for Stata, used Stata's searched command, read through the manuals, and the bulletin and journal. I've also recently attended the very helpful stata webinar on Reproducible Reporting done by Gabriela.
I am worried that what I'm hoping for does not yet exist.
Here's a sample of the data, which has been saved as "SampleData01.dta."
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str30 EMPLOYERNAME long AUN double startsal int year str14 PhoneNumber str47 Website str14 COUNTYNAME str30 IU str40 Category "IU 01 INTERMEDIATE" 101000000 43000 2026 "" "" "Washington" "Intermediate Unit 1" "Intermediate Unit" "IU 02 PITTSBURGH-MT OLIVER" 102000000 48579 2024 "" "" "Allegheny" "Pittsburgh-Mt Oliver IU 2" "Intermediate Unit" "IU 03 ALLEGHENY" 103000000 47000 2026 "" "" "Allegheny" "Allegheny IU 3" "Intermediate Unit" "IU 04 MIDWESTERN" 104000000 59898 2026 "" "" "Mercer" "Midwestern IU 4" "Intermediate Unit" "IU 05 NORTHWEST TRI-COUNTY" 105000000 63830 2026 "" "" "Erie" "Northwest Tri-County IU 5" "Intermediate Unit" end
Those variable labels are: Employer, AUN, Starting Salary, Year (Spring Semester), and County.
Here's my code so far:
****************
save "SampleData01.dta", replace
export excel using "SampleData01.xlsx", firstrow(varlabels) nolabel replace
putexcel set "SampleData01.xlsx", modify
putexcel A1:e700, font("Aptos", 11) hcenter
putexcel A1:e1, fpattern(solid,lightgray) hcenter border(all, medium) bold
putexcel C2:C700, nformat(#,###)
*****************
The file created by - putexcel - has columns that aren't wide enough for:
-- the column headers in columns: A, C, and D
-- the text data in columns A and E
-- the numeric data in column B.
Is there a way to automatically or manually set the excel file's column widths so that they are wide enough?
I have tried - txtwrap - and that is not the solution because the columns are so narrow the - txtwrap - causes individual words to be wrapped over two lines.
Thanks for your consideration of this puzzle.
Comment