Here is a collection of Delphi lines of code that we use routinely to automate Excel. These have helped us tremendously with streamlining repetitive tasks. The key requirement for using these code lines is that you have Microsoft Excel already installed on your computer. We have tested our code with Delphi 6, Delphi XE, and Delphi 10.1 Berlin. Our code is for the Windows operating environment. We have not, and do not plan to, adapt the code for other operating environments. The code works well with Office 365 version of Excel, however, some our code has been in use since we were using Office 2010 (and continues to work well). We hope these will be useful to you. If you find errors, encounter unhandled errors/exceptions, or have suggestions, please let us know.
As you browse through the lines of code, please remember that an Excel file is also referred to as an Excel workbook. An Excel worksheet is what many people commonly refer to as an Excel tab. By default, a new workbook has one worksheet (used to be three in earlier versions of Excel), but a workbook can contain many worksheets (limited only by the computer's available memory). See here for workbook and worksheet specifications and limits.
Excel File (i.e., Workbook) Operations
Excel Worksheet (i.e., Tab) Operations
Excel Row and Column Operations
Excel Cell Formatting Operations
Posted: Saturday, December 5, 2020
Last updated: Wednesday, March 19, 2025