Friday

QTP - Excel Worksheet Object Model


Worksheet API...

Set xlApp=Createobject("Excel.Application")
set xlWorkBook=xlApp.workbooks.add
set xlWorkSheet=xlWorkBook.WorkSheets.add
'Every where on net it is given .WorkSheet instead of .WorkSheets and failing ... take care

' Action we can perform on Worksheet like ...Few this you we can do
xlWorkSheet.Range("A1:B10").interior.colorindex = 34 'Color
outputWkbook.SaveAs testData,,pwd,writeresPwd 'Save
outputWkbook.Close

'Used Range and FInd

With objSheet.UsedRange ‘ select the used range in particular sheet
Set c = .Find (“nn”)’ data to find
For each c in objSheet.UsedRange’ Loop through the used range
If c=”nn” then’ compare with the expected data
c.Interior.ColorIndex = 40′ make the gary color if it finds the data
End If
Set c = .FindNext(c)’ next search

'Copy
objWorkbook1.Worksheets(“Sheet1″).UsedRange.Copy

'Counting
rowsCount=xlWorkSheet.Evaluate("COUNTA(A:A)") 'Will count the # of rows which have non blank value in the column A
colsCount=xlWorkSheet.Evaluate("COUNTA(1:1)") 'Will count the # of non blank columns in 1st row



Worksheets (Worksheet)
Names (Name)
Range
Areas
Borders (Border)
Errors
Error
Font
Interior
Characters
Font
Name
Style
Borders (Border)
Font
Interior
FormatConditions (FormatCondition)
Hyperlinks (Hyperlink)
Validation
Comment
Phonetics (Phonetic)
Shapes (Shape)right arrow
SmartTags
SmartTag
CustomProperties
CustomProperty
SmartTagActions
SmartTagAction
Protection
AllowEditRanges
AllowEditRange
UserAccessList
UserAccess

Comments (Comment)
CustomProperties
CustomProperty
HPageBreaks (HPageBreak)
VPageBreaks (VPageBreak)
Hyperlinks (Hyperlink)
Scenarios (Scenario)
OLEObjects (OLEObject)
Outline
PageSetup
Graphic
QueryTables (QueryTable)
Parameters (Parameter)
PivotTables (PivotTable)
CalculatedFields
CalculatedMembers
CalculatedMember
CubeFields
CubeField
TreeviewControl
PivotCache
PivotFields
PivotFormulas (PivotFormula)
PivotItems (PivotItem)
CubeFields (CubeField)
OLEObjects (OLEObject)
ChartObjects (ChartObject)
Chartright arrow
PivotLayout
AutoFilter
Filters (Filter)
Tab

No comments:

Post a Comment