Posts

Showing posts from February, 2018

Delphi IOUtils. Accessing and changing Directories and Files in Delphi

New Delphi versions provide TDirectory, TFile and TPath records which help to access and change directories and files in a easy way. Lots of procedures and functions available to use. So lets see how to use  TDirectory, TFile and TPath  First we have to use following units in Uses clause Uses    System.IOUtils, System.Types; TDirectory - Any directory related operation 1. Create a new Diretory TDirectory.CreateDirectory('c:\testfolder'); 2. Delete an existing directory TDirectory.Delete('c:\testfolder'); 3. Check if Directory exists TDirectory.Exists('c:\testfolder'); 4. Copy a Directory from One folder to another TDirectory.Copy('c:\Sourcefolder', c:\Destfolder'); 5. Move a Directory from One folder to another TDirectory.Move('c:\Sourcefolder', c:\Destfolder'); 5. Find create time, last opened time and last modified time TDirectory.GetCreationTime('c:\testfolder'); TDirectory.GetLastAccessTime

MS Excel Automation in Delphi

In this blog I will describe how to read and write data from and to an Excel file. Sometime in our application we use Excel for reporting purpose, for data import / export purpose and for other works. So here I will explain how to access an Excel file and use for data read / write. For this Excel 2003 or later should have installed in our system. First use Excel2000 unit to uses clause. This unit comes with Delphi installation it self. You can get the unit in installed path C:\Program Files (x86)\Embarcadero\RAD Studio\10.0\OCX\Servers Uses    Excel2000; Before proceed I would mention an important word  LCID which is required at most places. So what it LCID? LCID = In Microsoft Excel, the LCID indicates the currency symbol to be used when this is an xlListDataTypeCurrency type.  Returns 0 (which is the Language Neutral LCID) when no locale is set for the data type of the column. We can get LCID in Delphi by using  GetUserDefaultLCID  function.. privat