[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-670627-105":59,"doc-detail-670627-en":130,"doc-similar-670627":161},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","xl-excel-file-io-class","xl() - Excel file I/O class","","The xl() Mata class enables creating, loading, and manipulating Excel workbooks across Excel 1997/2003 (.xls) and Excel 2007/2013 (.xlsx) formats. It supports opening and clearing workbooks, adding and configuring worksheets, and reading or writing both string and numeric data to specific cells. The class also provides utilities to format numbers, align cells, set borders and fills, control fonts and text properties, and apply formatting to cell ranges via formatting IDs.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/xl-excel-file-io-class/670627/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/xl-excel-file-io-class/670627.png","ImageObject",300,407,{"name":92,"@type":93},"dabgoudw","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-30","2026-11-01",true,{"@type":102,"interactionType":103,"userInteractionCount":24},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What does the xl() class support regarding Excel file formats?","Question",{"text":112,"@type":113},"The xl() class supports creating .xls (Excel 1997/2003) and .xlsx (Excel 2007/2013) files and loading them with Mata matrices.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How do you create and open an Excel workbook using xl()?",{"text":117,"@type":113},"Use xl() to initialize B = xl(), then call methods such as .create book() to create a workbook, or .load book() to load an existing one, followed by .close book() when finished.",{"name":119,"@type":110,"acceptedAnswer":120},"What kinds of formatting can be applied to Excel output?",{"text":121,"@type":113},"It supports cell-level formatting (number formats, alignment, borders, fills, row/column dimensions), text formatting (font properties and text wrapping/rotation/indent), and range formatting using formatting IDs through the fmtid utilities.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},670627,1793570389,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":24,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":41,"language":139,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":67,"update_tm":129,"read_time":143,"preview_page_count":19,"preview_urls":144},3985747860484,"https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c","Title [stata.com](stata.com)  \nxl( )—Excel ﬁle I/O class  \nDescription Syntax Remarks and examples Appendix  \nAlso see  \nDescription  \nThe xl() class allows you to create Excel 1997/2003 ( .xls) ﬁles and Excel 2007/2013 ( .xlsx)ﬁles and load them from and to Mata matrices. The two Excel ﬁle types have different data size limits that you can read about in the technical note Excel data size limits of [D] import excel. The xl() class is supported on Windows, Mac, and Linux.  \nSyntax  \nIf you are trying to import or export an Excel ﬁle to or from Stata, see [D] import excel. If you are trying to export a table created by Stata to Excel, see [P] putexcel.  \nThe syntax diagrams below describe a Mata class. For help with class programming in Mata, see [M-2] class.  \nSyntax is presented under the following headings:  \nStep 1: Initialization  \nStep 2: Creating and opening an Excel workbook  \nStep 3: Setting the Excel worksheet  \nStep 4: Reading and writing data from and to an Excel worksheet  \nStep 5: Formatting cells in an Excel worksheet  \nStep 6: Formatting text in an Excel worksheet  \nStep 7: Formatting cell ranges in an Excel worksheet  \nUtility functions for use in all steps  \nStep 1: Initialization  \nB = xl()  \nStep 2: Creating and opening an Excel workbook  \n(void) B .create book(\"ﬁlename\", \"sheetname \" 􀀂 , f \"xls\" j \"xlsx\" g, \"locale \" 􀀃)  \n(void) B .load book(\"ﬁlename \" 􀀂, \"locale \" 􀀃)  \n(void) B .clear book(\"ﬁlename\")  \n(void) B .set mode(\"open\" j \"closed\")  \n(void) B .close book()  \nStep 3: Setting the Excel worksheet  \n(void) B .add sheet(\"sheetname\")  \n(void) B .set sheet(\"sheetname\")  \n(void) B .set sheet gridlines(\"sheetname\", 􀀈\"on\" j \"off\" 􀀉)  \n(void) B .set sheet merge(\"sheetname\", real vector row , real vector col)(void) B .clear sheet(\"sheetname\")  \n(void) B .delete sheet(\"sheetname\")  \n(void) B .delete sheet merge(\"sheetname\", real vector row , real vector col) string colvector B .get sheets()  \nStep 4: Reading and writing data from and to an Excel worksheet  \nstring matrix B .get string(real vector row , real vector col)  \nreal matrix B .get number(real vector row , real vector col  \n􀀂 , f \"asdate\" j \"asdatetime\" g 􀀃)  \nstring matrix B .get cell type(real vector row , real vector col)  \n(void) B .put string(real scalar row , real scalar col , string matrix s)(void) B .put number(real scalar row , real scalar col , real matrix r  \n􀀂 , f \"asdate\" j \"asdatetime\" j \"asdatenum\" j asdatetimenum g 􀀃)  \n(void) B .put formula(real scalar row , real scalar col , string matrix s)  \n(void) B .put picture(real scalar row , real scalar col, \"ﬁlename\")  \n(void) B .set missing( 􀀂real scalar num j string scalar val 􀀃)  \nStep 5: Formatting cells in an Excel worksheet  \n(void) B .set number format(real vector row , real vector col, \"format\")(void) B .set vertical align(real vector row , real vector col, \"align\")(void) B .set horizontal align(real vector row , real vector col, \"align\")  \n(void) B .set border(real vector row , real vector col, \"style \"  \n􀀂, \"color \" 􀀃)  \n(void) B .set left border(real vector row , real vector col \"style \"  \n􀀂, \"color \" 􀀃)  \n(void) B .set right border(real vector row , real vector col, \"style \"  \n􀀂, \"color \" 􀀃)  \n(void) B .set top border(real vector row , real vector col, \"style \"  \n􀀂, \"color \" 􀀃)  \n(void) B .set bottom border(real vector row , real vector col, \"style \"  \n􀀂, \"color \" 􀀃)  \n(void) B .set diagonal border(real vector row , real vector col, \"direction\",  \n\"style \" 􀀂, \"color \" 􀀃)  \n(void) B .set fill pattern(real vector row , real vector col, \"pattern\",  \n\"fgcolor \" 􀀂, \"bgcolor \" 􀀃)  \n(void) B .set column width(real scalar col1 , real scalar col2 , real scalar width)(void) B .set row height(real scalar row1 , real scalar row2 , real scalar height)  \nStep 6: Formatting text in an Excel worksheet  \n(void) B .set font(real vector row , real vector col, \"fontname\", real scalar size  \n􀀂, \"color \" 􀀃)  \n(void) B .set font bold(real vector row , real vector col , 􀀈\"on\" j \"off\" 􀀉)  \n(void) B .set fon","cbCaitj1zH79SjRd","https://ap.wps.com/l/cbCaitj1zH79SjRd","pdf",303240,"English","# Step 1: Initialization\n# Step 2: Creating and opening an Excel workbook\n# Step 3: Setting the Excel worksheet\n# Step 4: Reading and writing data from and to an Excel worksheet\n# Step 5: Formatting cells in an Excel worksheet\n# Step 6: Formatting text in an Excel worksheet\n# Step 7: Formatting cell ranges in an Excel worksheet","[{\"question\":\"What does the xl() class support regarding Excel file formats?\",\"answer\":\"The xl() class supports creating .xls (Excel 1997/2003) and .xlsx (Excel 2007/2013) files and loading them with Mata matrices.\"},{\"question\":\"How do you create and open an Excel workbook using xl()?\",\"answer\":\"Use xl() to initialize B = xl(), then call methods such as .create book() to create a workbook, or .load book() to load an existing one, followed by .close book() when finished.\"},{\"question\":\"What kinds of formatting can be applied to Excel output?\",\"answer\":\"It supports cell-level formatting (number formats, alignment, borders, fills, row/column dimensions), text formatting (font properties and text wrapping/rotation/indent), and range formatting using formatting IDs through the fmtid utilities.\"}]","xl() - Excel file I/O class | PDF",76,[145,149,153,157],{"page_no":8,"url":146,"width":147,"height":148},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/b1e5720b0f12cd87a9aaa9a6a2576bf6.webp",983,1415,{"page_no":14,"url":150,"width":151,"height":152},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/ff31725b7ef649234c7425a79cea9370.webp",982,1414,{"page_no":81,"url":154,"width":155,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/4dbb6220fd65c9483e000524c3fd4e33.webp",981,1412,{"page_no":19,"url":158,"width":159,"height":160},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/35dbd042643b05a4484975557a8f5b41.webp",980,1411,{"list":162,"token":66},[163,170,177,183,189,195,202,208,214,220],{"doc_id":164,"doc_title":165,"file_type":137,"home_preview_img_url":166,"slug":167,"view_count":168,"category_name":30,"create_tm":169},343206,"putexcel - Export results to an Excel file","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229910744413/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=cweQJLAOqYANpR3o6xJA4MeF6FM%3D","putexcel-export-results-to-an-excel-file",15,1790050286,{"doc_id":171,"doc_title":172,"file_type":137,"home_preview_img_url":173,"slug":174,"view_count":175,"category_name":30,"create_tm":176},488683,"Excel Basics for Account Reconciliation","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229927086112/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=CU8%2BhjJSlzLnuZCCxjV37qRukn0%3D","excel-basics-for-account-reconciliation",17,1790815981,{"doc_id":178,"doc_title":179,"file_type":137,"home_preview_img_url":180,"slug":181,"view_count":44,"category_name":30,"create_tm":182},670638,"Excel Fundamentals - read online free","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988696945/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=ra3wkLAdt488DLM9xs4f%2F2KSfPI%3D","excel-fundamentals-read-online-free",1793570536,{"doc_id":184,"doc_title":185,"file_type":137,"home_preview_img_url":186,"slug":187,"view_count":19,"category_name":30,"create_tm":188},688591,"MICROSOFT EXCEL 101 - Unlocking the Power of Spreadsheets - Introduction to Microsoft Excel Basics","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230001282531/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=1n8P4XkjPOppAxuafHWBbaGZS6o%3D","microsoft-excel-101-unlocking-the-power-of-spreadsheets-introduction-to-microsoft-excel-basics",1794090073,{"doc_id":190,"doc_title":191,"file_type":137,"home_preview_img_url":192,"slug":193,"view_count":81,"category_name":30,"create_tm":194},669980,"Getting Started with Microsoft Excel - Functions and Worksheet Management","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988682727/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=8%2FuURv7DSgUcVbyUNbqBUwv7JK0%3D","getting-started-with-microsoft-excel-functions-and-worksheet-management",1793565466,{"doc_id":196,"doc_title":197,"file_type":137,"home_preview_img_url":198,"slug":199,"view_count":200,"category_name":30,"create_tm":201},289123,"Excel Shortcuts Cheat Sheet","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229902981705/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=5ZWmZ4LKlGgmPhdK8GO%2FDvILHRw%3D","excel-shortcuts-cheat-sheet",33,1789634595,{"doc_id":203,"doc_title":204,"file_type":137,"home_preview_img_url":205,"slug":206,"view_count":14,"category_name":30,"create_tm":207},670626,"SESUG Paper 132-2024 - Creating and Customizing High-Impact Excel Workbooks from SAS with ODS EXCEL","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988345196/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=ygeeL2mYaFBCLGpCL4SH3wQeDiE%3D","sesug-paper-132-2024-creating-and-customizing-high-impact-excel-workbooks-from-sas-with-ods-excel",1793570383,{"doc_id":209,"doc_title":210,"file_type":137,"home_preview_img_url":211,"slug":212,"view_count":24,"category_name":30,"create_tm":213},686919,"Excel Formatting - Best Practices in Financial Models","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230001217355/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=WqpMopa2OjoanGWwJ8cLR%2BQMKZ0%3D","excel-formatting-best-practices-in-financial-models",1794075235,{"doc_id":215,"doc_title":216,"file_type":137,"home_preview_img_url":217,"slug":218,"view_count":44,"category_name":30,"create_tm":219},670635,"UNIT - IV - Microsoft Excel Introduction - Creating a Worksheet - Formatting and Printing a Worksheet - Creating Charts","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988345674/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=yTJO3w1Ix8hAMVTzYZPgUrcUWgI%3D","unit-iv-microsoft-excel-introduction-creating-a-worksheet-formatting-and-printing-a-worksheet-creating-charts",1793570527,{"doc_id":221,"doc_title":222,"file_type":137,"home_preview_img_url":223,"slug":224,"view_count":24,"category_name":30,"create_tm":225},670636,"Essential Spreadsheets - Book 1 - Spreadsheet Basics","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988345693/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110439&Signature=Cc1cn2o2uRQdiwWZPJ0YZecZYqw%3D","essential-spreadsheets-book-1-spreadsheet-basics",1793570530]