Rockwell Automation 9307 FactoryTalk EnergyMetrix User Manual

Page 278

Advertising
background image

FactoryTalk EnergyMetrix Software

278

Excel spreadsheet sample

This sample MPR Excel Report script populates an existing Excel spreadsheet with
document properties, basic cell values as well as populate the sheet with meter data, that
could be used for trend charts, bar charts etc. in excel. It uses the Excel.SetCell function
that simplifies the process of populating Excel cells with various content.

Sub Main()

' Define variables used with the routine.

Dim worksheetName As String

Dim meter As Meter

Dim day As Day

Dim kwh As Integer

Dim row As Integer

Dim startdate as object

' Set pre-defined properties of the Excel workbook.

Excel.Workbook.Properties.Author = "Author name"

Excel.Workbook.Properties.Title = "This is an Excel MPR

report"

Excel.Workbook.Properties.Subject = "Subject goes here"

Excel.Workbook.Properties.Category = "This is the

category"

Excel.Workbook.Properties.Comments = "Some comments"

Excel.Workbook.Properties.Keywords = "keyword1 keyword2

keyword3"

In this script, the worksheet name is included in the Excel.SetCell calls as
the first parameter, and the preceding parameters define the location and
content.

Advertising