51Testing软件测试论坛
标题:
个人学习笔记:WinRunner 读写Excel文件\操作单元格
[打印本页]
作者:
peter.zheng
时间:
2008-8-13 17:53
标题:
个人学习笔记:WinRunner 读写Excel文件\操作单元格
table = "C:\\lesson8.xls";
Result="c:\\result.txt";
table2 = "C:\\lesson9.xls";
file_open(Result,2);
rc = ddt_open(table, DDT_MODE_READ); //open XSL File
ddt_open(table2,DDT_MODE_READWRITE);//open XSL File
if (rc!= E_OK && rc != E_FILE_OPEN)
pause("Cannot open table.");
ddt_get_row_count(table,table_RowCount);
for(table_Row = 1; table_Row <= table_RowCount; table_Row ++)
{
# ddt_set_row(table,table_Row);
# aa=ddt_val(table,"CUS"); #get data from XLS file
aa=ddt_val_by_row ( table, table_Row, "CUS" ); #get data from XLS file by row
file_printf(Result,"%s ",aa,"\n"); #write data in txt file
# ddt_set_val(table2,"CUS",aa); #write data in XLS file
ddt_set_val_by_row ( table2, table_Row, "CUS", aa ); #write data in XLS file by row
}
file_close(Result);
ddt_close(table);
ddt_save(table2);
ddt_close(table2);
个人在V8。1上面都能跑过的,大家分享一下!有什么好方法也交流一下,谢谢各位了。
[
本帖最后由 peter.zheng 于 2008-8-14 10:47 编辑
]
作者:
peter.zheng
时间:
2008-8-14 10:46
table = "C:\\lesson8.xls";
Result="c:\\result.txt";
table2 = "C:\\lesson9.xls";
file_open(Result,2);
rc = ddt_open(table, DDT_MODE_READ);
ddt_open(table2,DDT_MODE_READWRITE);
if (rc!= E_OK && rc != E_FILE_OPEN)
pause("Cannot open table.");
ddt_get_row_count(table,table_RowCount);
for(table_Row = 1; table_Row <= table_RowCount; table_Row ++)
{
ddt_set_row(table,table_Row); #Active row by row
aa=ddt_val(table,"CUS"); #get data from XLS file
file_printf(Result,"%s ",aa,"\n");#write data in txt file
ddt_set_row(table2,table_Row); #Active row by row
ddt_set_val(table2,"CUS",aa); #write data in XLS file
}
file_close(Result);
ddt_close(table);
ddt_save(table2);
ddt_close(table2);
作者:
sunth
时间:
2008-9-5 16:31
如果我有好多excel文件想做替换操作,可以用它吗?
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2