Данная команда получает данные из листа excel-файла в виде двухмерного массива (строки и столбцы).
<?php $xhe_host = "127.0.0.1:7020"; // подключим объект для управления RPAbot, если еще не подключен if (!isset($path)) $path="../../../Templates/init.php"; require($path); // начало echo "<hr><font color=blue>excelfile->".basename (__FILE__)."</font><hr>"; $excel->kill(); // 1 echo("1. Получим содержимое листа в виде двухмерного массива: \n\n"); print_r($excelfile->get_sheet("test\\test.xlsx", 0)); // откроем исходный файл для сравнения с результатом $app->shell_execute("open", "test\\test.xlsx"); // конец echo "<hr><br>"; // Quit $app->quit(); ?>
#region using using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading; using System.Threading.Tasks; using XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; using Newtonsoft.Json.Linq; #endregion class MyScript:XHEScript { static void Main(string[] args) { // init XHE server = "127.0.0.1:7027"; InitXHE(); string path_excel ="challenge.xlsx"; // go to google browser.navigate("https://rpachallenge.com/"); // данные из файла JArray arr = excelfile.get_sheet(path_excel,0); btn.click_by_inner_text("START"); for (int i = 0; i < arr.Count; i++) { JArray row = (JArray)arr[i]; //label.get_by_inner_text("First Name").get_next().set_value(row[0]); input.set_value_by_attribute("ng-reflect-name","labelFirstName", 1, (string)row[0]); // фамилия //label.get_by_inner_text("Last Name").get_next().set_value(row[1]); input.set_value_by_attribute("ng-reflect-name","labelLastName", 1, (string)row[1]); // //label.get_by_inner_text("Company Name").get_next().set_value(row[2]); input.set_value_by_attribute("ng-reflect-name","labelCompanyName", 1, (string)row[2]); // //label.get_by_inner_text("Role in Company").get_next().set_value(row[3]); input.set_value_by_attribute("ng-reflect-name","labelRole", 1, (string)row[3]); // //label.get_by_inner_text("Address").get_next().set_value(row[4]); input.set_value_by_attribute("ng-reflect-name","labelAddress", 1, (string)row[4]); // //label.get_by_inner_text("Email").get_next().set_value(row[5]); input.set_value_by_attribute("ng-reflect-name","labelEmail", 1, (string)row[5]); // //label.get_by_inner_text("Phone Number").get_next().set_value(row[6]); input.set_value_by_attribute("ng-reflect-name","labelPhone", 1, (string)row[6]); button.click_by_value("Submit"); /*for (int j = 0; j < row.Count; j++) { echo((string)row[j]+"<br>"); }*/ } // exit app.quit(); } /*static void print_r(object val) { if (val.GetType() == typeof(string)) { Console.Write(val); return; } else if (val.GetType().GetInterface(typeof(IEnumerable).FullName) != null) { foreach (object i in val) { // Process val as array } } else { Console.Write(val); return; } }*/ }
xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>excelfile.get_cell</font><hr>"); // 1 echo("\n1. Получим соедержимое листа как массив: "); console.log(excelfile.get_sheet("test\\test.xlsx",0)); // конец echo("<hr><br>"); // Quit app.quit();
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7028" from xweb_human_emulator import * # начало echo("<hr><font color=blue>excelfile.read_sheet</font><hr>") # 1 echo("\n1. Прочитаем лист как массив : \n\n"); echo(excelfile.get_sheet("test\\test.xlsx",0)); # конец echo("<hr><br>") # Quit app.quit()