get_and_clear_range
get_and_clear_range($path,$sheet,$range,$timeout=3000); - Получить значения заданного диапазона Листа как массив строк и очистить ячейки диапазонаФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Get and clearing cell ranges in Excel file $xhe_host = getenv("RPABOT_HOST_URL"); // Connect functional objects if not already connected if (!isset($path)){ // Path to the init.php file for connecting to the XHE API $path = "../../../Templates/init.php"; // Including init.php grants access to all classes and functionality for working with the XHE API require($path); } echo "\n<span >excelfile->" . basename(__FILE__) . "</span>\n"; // Initialize Excel and prepare file path $filePath = "test/test.xlsx"; SYSTEM::$excel->kill(); // Example 1: Create values for a row echo("\nExample 1: Create values for a row : "); // Extract method arguments into variables $sheetIndex = 1; $rowNumber = 1; $rowData = array('Завод "Э"', 2, 3, 4, 5, 6, 7, 8); $result = SYSTEM::$excelfile->set_row($filePath, $sheetIndex, $rowNumber, $rowData); if ($result === true) echo("true\n"); else echo("false\n"); // Example 2: Get range contents as array and clear it echo("\nExample 2: Get range contents as array and clear it : "); // Extract method arguments into variables $range = "A1:H1"; var_export(SYSTEM::$excelfile->get_and_clear_range($filePath, $sheetIndex, $range)); // Example 3: Get range contents (should be empty) echo("\nExample 3: Get range contents (should be empty) : "); var_export(SYSTEM::$excelfile->get_range($filePath, $sheetIndex, $range)); // Example 4: Close file echo("\nExample 4: Close file : "); $result = SYSTEM::$excelfile->close($filePath); if ($result === true) echo("true\n"); else echo("false\n"); // End of script echo "\n"; // Quit application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7010" from xweb_human_emulator import * # начало echo("<hr><font color=blue>excelfile.get_and_clear_range</font><hr>") path = "test/test.xlsx" excel.kill() echo("\n1. Создать значения для строки: ") echo(excelfile.set_row(path, 1, 1, ['Завод "Э"', 2, 3, 4, 5, 6, 7, 8])) echo("\n2. Получить содержимое диапазона как массив и очистить 1!A1:H1: ") echo(excelfile.get_and_clear_range(path, 1, "A1:H1")) echo("\n5. Получить содержимое диапазона 1!A1:H1 (пусто): ") echo(excelfile.get_range(path, 1, "A1:H1")) # конец 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 XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; #endregion class Program:XHEScript { static void Main(string[] args) { // init XHE server = Environment.GetEnvironmentVariable("RPABOT_HOST_URL"); InitXHE(); var path = "test/test.xlsx"; // начало echo("<hr><font color=blue>excelfile.get_and_clear_range</font><hr>"); // Закрыть все процессы Excel excel.kill(); echo("\n1. Создать значения для строки: "); echo(excelfile.set_row(path, 1, 1, array('Завод "Э"', 2, 3, 4, 5, 6, 7, 8))); echo("\n2. Получить содержимое диапазона как массив и очистить: "); print_r(excelfile.get_and_clear_range(path, 1, "A1:H1")); echo("\n3. Получить содержимое диапазона (пусто): "); print_r(excelfile.get_range(path, 1, "A1:H1")); // конец echo("\n\n"); app.quit(); } }
xhe_host="127.0.0.1:7010";
echo=require("../../../Templates JS/init.js");
// начало
echo("<hr><font color=blue>excelfile.get_range</font><hr>");
const path = "test/test.xlsx";
// Закрыть все процессы Excel
excel.kill();
echo("\n1. Создать значения для строки (1): ");
echo(excelfile.set_row(path, 1, 1, ['Завод "Э"', 2, 3, 4, 5, 6, 7, 8]));
echo("\n2. Получить содержимое диапазона как массив и очистить (1!A1:H1): ");
let res = excelfile.get_and_clear_range(path, 1, "A1:H1");
console. log(res);
echo("\n3. Получить содержимое диапазона (пусто) (1!A1:H1): ");
res = excelfile.get_range(path, 1, "A1:H1");
console.log(res);
// конец
echo("\n");
// Quit
app.quit();=============================================
excelfile Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.