1: oExcel = This is the Excel.Application object2: oWorkBook = This is the WorkBook Object, this can only contain one object.3: aSheets = Array of Worksheet objects, each element is one sheet.4: aExcelRow = Internal Array used by ConvertStringToArray and BuildLineFromArray.

To load the DLL:

oReport = CREATEOBJECT("ExcelClass.clsExcel")

Methods contained in the class are used to manipulate the Excel object and work sheet objects, these methods are:

FontStyle ParametersBBoldUUnderlineIItalicNNormal - Reset to defaultBU or UBBold and UnderlinedBI or IBBold and ItalicUI or IUUnderlined and Italic

MethodAddSheetParameterstcWheretnWorkSheet

Example CallThe font Parameter is in the format = ontName:FontSize:FontStyle

oReport.AddSheet(“Before”,1) && Add a new sheet before worksheet 1
oReport.AddSheet(“After”,2) && Add a new sheet after worksheet 2

tcWhere can be either Before or After, when you use this method, you will have to remember that the internal array ‘aSheets’ is re-mapped, so if you have 3 worksheets to start with then add a new sheet after 1 the array will look like this:

MethodFindSheetParameterstuWhatReturnsSheet Name or Number depending on tuWhat

This Method will find a specific sheet either by name or number. If you pass a number as the parameter, the function will return the tab name of the selected sheet. If you pass the Name you want to find, the function will return the sheet number.

This method will take a comma delimited string and convert this into a two dimensional array which can be used by the BuildLineFromArray method.

Example Call

LOCAL lcHeadString
*-- You can specify the column width in the string by using a :width, .T. = AutoFit.
lcHeadString = “a:.T.,b:10,c,d,e,f:10,g”
oReport.ConvertStringToArray(lcHeadString)
oReport.BuildLineFromArray(1,”A5”)

MethodSetCellParameterstnWorkSheettcRangetcPropertytuValue

This method allows the user to manipulate any cell or range of cells properties.

This method allows the user to manipulate any of the worksheet properties.

Example Call

oReport.SetWorkSheetl(1,”PageSetup.Orientation”,2) && Set page to Landscape

MethodDrawBorderParameterstnWorkSheettcRangetcStyletnColortlGrid

This method allows you to draw lines around a single cell or a range of cells, you can also specify the colour and thickness of the line to be drawn. tcStyle is in the following format: LineType:Thickness.

oReport.Drawborderl(1,”A1”,”xlContinuous”) && Draw continuous border around Cell A1*-- This draws a hairline dashed box around cells A1-C3 with the colour of red and draws lines*-- Inside the box as well.
oReport.DrawBorder(1,”A1:C3”,”xlDash:xlHairline”,RGB(255,0,0),.T.)

Planned ModificationsTo allow multiple orkBook objects, also method to allow selection of appropriate workbook either by Name or number. Options to include adding graphs, also other options for opening different types of files from .txt to .csv etc… Also allow for saving to different file formats. Increase the options in the ConvertStringToArray method; including Cell Formatting, Alignment and colours, these can be done through other methods at the moment.

Update (November 20, 2001)Simon has updated his Excel Wrapper Class to version 1.0.5. All Excel Examples have been tested and are fully functional after having cleared a few bugs found in some earlier versions. Simon is still working on the Beta release of the Help file, but in the interim has included documents as well as the beta release of the Help file. The classes for Word, Outlook and PowerPoint which are also planned for inclusion are still in development. You can download the new library here. The file size is 192,978 bytes.

ABOUT THE AUTHOR: SIMON ARNOLD

Simon has worked with FoxPro for over 16 years. He currently works for a company based in Harrogate, North Yorkshire (UK), which
specialises in FoxPro, Web and Unix development.He has a weblog at http://weblogs.foxite.com/simonarnold.