• EN
    RU

excelfile/open

open(path, is_wait_busy, wait_busy_seconds, timeout=3000)

Данная команда позволяет открыть файл.

Команда на вход принимает параметры
  • path – путь к файлу
  • is_wait_busy
  • wait_busy_seconds
  • timeout – таймаут операции (по умолчанию равен 3000 секунд)

После отработки команда возвращает результат своей работы в робот
  • true – успешно открыли
  • false – открыть не удалось



Пример использования open (Python):

# Additional paths
import sys
sys.path.insert(0, '../../../Templates PY/')
 
xhe_host = "127.0.0.1:7015"
from xweb_human_emulator import *
 
# начало
echo("<hr><font color=blue>excelfile.get_sheets_count</font><hr>")
 
# путь к файлу
path="test\\test.xlsx";
 
# 1 
echo("\n1. Откроем : ");
echo(excelfile.open(path));
 
# 2
echo("\n2. Выведем все ячейки : ");
for i in range(1, excelfile.get_rows_count(path,0)):
	for j in range(1, excelfile.get_cols_count(path,0)):	
		echo(excelfile.get_cell(path,0,i,j)+"|")
	echo("\n")
 
# 3
echo("\n3. Скопируем ячейки на 2 лист c новыми цветами: ");
for i in range(1, excelfile.get_rows_count(path,0)):
	for j in range(1, excelfile.get_cols_count(path,0)):	
		echo(excelfile.set_cell(path,1,i,j,excelfile.get_cell(path,0,i,j))," ")
		excelfile.set_cell_background_color(path,1,i,j,"FF0000FF")
		excelfile.set_cell_color(path,1,i,j,"FFFFFF00")
	echo("\n")
 
# 4
echo("\n4. Сохраним : ");
echo(excelfile.save(path));
 
# 5
echo("\n5. Закроем : ")
echo(excelfile.close(path))
 
# посмотрим
app.shell_execute("open","test\\test.xlsx")
 
# конец
echo("<hr><br>")
 
# Quit
app.quit()

Пример использования open (JS):

xhe_host="127.0.0.1:7015";
echo=require("../../../Templates JS/init.js");
 
// начало
echo("<hr><font color=blue>excelfile.get_sheets_count</font><hr>");
 
// путь к файлу
path="test\\test.xlsx";
 
// 1 
echo("\n1. Откроем : ");
echo(excelfile.open(path));
 
// 2
echo("\n2. Выведем все ячейки : ");
for (i=1;i<=excelfile.get_rows_count(path,0);i++)
{
	for (j=1;j<=excelfile.get_cols_count(path,0);j++)
		echo(excelfile.get_cell(path,0,i,j)+"|");
	echo("\n");
}
 
// 3
echo("\n3. Скопируем ячейки на 2 лист c новыми цветами: ");
for (i=1;i<=excelfile.get_rows_count(path,0);i++)
{
	for (j=1;j<=excelfile.get_cols_count(path,0);j++)
	{
		echo(excelfile.set_cell(path,1,i,j,excelfile.get_cell(path,0,i,j))+" ");
		excelfile.set_cell_background_color(path,1,i,j,"FF0000FF");
		excelfile.set_cell_color(path,1,i,j,"FFFFFF00");
	}
	echo("\n");
}
 
// 4
echo("\n4. Сохраним : ");
echo(excelfile.save(path));
 
// 5
echo("\n5. Закроем : ");
echo(excelfile.close(path));
 
// посмотрим
app.shell_execute("open","test\\test.xlsx");
 
// конец
echo("<hr><br>");
 
// Quit
app.quit();