Micro Focus QTP (UFT) Forums
saving same datatable modified by diff sources - 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 Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: saving same datatable modified by diff sources (/Thread-saving-same-datatable-modified-by-diff-sources)



saving same datatable modified by diff sources - Pradeep - 08-26-2008

Hi ,
i am facing an issue in saving to an common xls from diff scripts running from diff machines populating different columns & rows.
The data which persist is from the last run script( Previous script data is lost).Methods used are datatable.import and export.

Pls let me know how can i persist the old data even.

Thanks.


RE: saving same datatable modified by diff sources - Pradeep - 08-26-2008

Can anybody help out with this please?


RE: saving same datatable modified by diff sources - somisays - 08-26-2008

Dear Pradeep,
Are you exporting global and local sheet ?
Can you post your import or export code here...

If you are exporting Global and Local then it is going to update..

I can help you if you post your code here.


RE: saving same datatable modified by diff sources - Pradeep - 08-26-2008

thanks Sridhar, its a global sheet i will be exporting code is usval one

datatable.Import("C:\Test_Data.xls")
* some cals here
datatable.Value("Test_PL_value")=Plval
datatable.export("C:\Test_Data.xls")

but this code is also run in another machine ( diff environment) and update the same datatable. The result i am seeing is the latest update but what i need is both saves done on diff environments (offcourse to diff columns).

-Pradeep


RE: saving same datatable modified by diff sources - somisays - 08-27-2008

Dear Pradeep,
Export method exports both global and local sheet.
clear me one thing .Where is the output is it in Global sheet or Local sheet.
If it is in only either local ot global sheet then you use the Import or Export sheet method then it is going to workout for you..


RE: saving same datatable modified by diff sources - Pradeep - 08-27-2008

Hi Sridhar,
Its in the Global sheet.

The whole process is
1.2 scripts picks up(import) the xls file
2.Updates it
3.stores it at the different time(exports to the same loc and same file name).

the script which stores the datatable at the later time is actually replacing the old xls file . This is the pronblem .

what i need is something wherein the xls gets updated with preserving the existing data in it.

The approach i think is to read the xls first before saving any update and write to it with pervious data (which is read) with the new data.

pls suggest as i feel this is bit complicated approach.


Thanks,
Pradeep


RE: saving same datatable modified by diff sources - sshukla12 - 08-04-2011

U need to append the exls file instead of writing it again
Below code might help u:

Code:
Dim fso
Set fso=CreateObject("Excel.Application")
fso.visible=true
Set excel_obj=fso.workbooks.open("D:\BookingResults\test1.xls")
Set obj_worksheet=excel_obj.worksheets(1)
cell_address=obj_worksheet.UsedRange.Address
add_array=split(cell_address,"$",-1,0)
row=add_array(2)+1
col=add_array(1)
obj_worksheet.cells(row,col).activate
obj_worksheet.cells(row,col).value="Hi"

Correct me if wrong
Regards,
Sankalp