Micro Focus QTP (UFT) Forums
How do I change the columnheader(s) in a Datatable ? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How do I change the columnheader(s) in a Datatable ? (/Thread-How-do-I-change-the-columnheader-s-in-a-Datatable)



How do I change the columnheader(s) in a Datatable ? - paulv - 09-04-2008

How can I change the header of a DataTable column (DTParameter) during runtime ?
I can add a column (DTSheet.AddParameter), get the name of a certain column (DTSheet.GetParameter) and even delete a column (DTSheet.DeleteParameter) but can't find the trick to change column-header.
Any suggestions ?

Paul


RE: How do I change the columnheader(s) in a Datatable ? - kishoreinchennai - 09-04-2008

Code:
'add a New Colum
DataTable.GetSheet("dtGlobalSheet").AddParameter "NewColumn","Row1Value"

'copy the cells from the old column into the new column
cnt=DataTable.GetRowCount
For i=1 to cnt
       DataTable.SetCurrentRow(i)
       OldVal=DataTable.Value("OldColumn","dtGlobalSheet")
       DataTable.Value("NewColumn","dtGlobalSheet")=OldVal
Next

'delete the old column
DataTable.GetSheet("dtGlobalSheet").DeleteParameter("OldColumn")
Regards


RE: How do I change the columnheader(s) in a Datatable ? - paulv - 09-04-2008

Kishore,

thx for the reply.
We already had a similar option in mind, but unfortunately this way of working would be too time-consuming.
Therefor I choose for another way of working :
no longer copy our 'floating' header-definition from within the table to the header, but just read it at the position it is now.

Thanks anyway !

Paul


RE: How do I change the columnheader(s) in a Datatable ? - kishoreinchennai - 09-04-2008

Code:
'add a New Colum
DataTable.GetSheet("dtGlobalSheet").AddParameter "NewColumn","Row1Value"

'copy the cells from the old column into the new column
cnt=DataTable.GetRowCount
For i=1 to cnt
       DataTable.SetCurrentRow(i)
       OldVal=DataTable.Value("OldColumn","dtGlobalSheet")
       DataTable.Value("NewColumn","dtGlobalSheet")=OldVal
Next

'delete the old column
DataTable.GetSheet("dtGlobalSheet").DeleteParameter("OldColumn")


Regards