Основной сайт хуманэмулятор.рф | Демо | Купить | API | Wiki
System / word
add_table
add_table($path,$table); - Добавим таблицу в WORD документразмерность каждого из под-массивов может не совпадать.
Функция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Add a table to a Word document $xhe_host = getenv("RPABOT_HOST_URL"); // Connect functional objects if not already connected if (!isset($path)){ $path = "../../../Templates/init.php"; require($path); } // info echo "\n<span >word->" . basename (__FILE__) . "</span>\n"; // Initialize variables $filePath = "test/test_create.docx"; $initialText = "новый текст"; // Example 2: Kill any existing Word processes SYSTEM::$word->kill(); // Example 3: Create a new Word document echo("1. Create docx file: "); $result = SYSTEM::$word->create($filePath, $initialText); if ($result) { echo("Successfully created document\n"); } else { echo("Failed to create document\n"); } // Open the file for edit SYSTEM::$word->open($filePath, false); // Example 4: Prepare table data $tableArray = array(); $tableArray[] = array("0", "1", "2"); $tableArray[] = array("3", "4", "5", "6"); // Example 1: Add the table to the document echo("\n1. Add table to document: "); $result = SYSTEM::$word->add_table($filePath, $tableArray); if ($result) { echo("Successfully added table\n"); } else { echo("Failed to add table\n"); } // Save and close the document SYSTEM::$word->save($filePath); SYSTEM::$word->close($filePath); echo "\n"; // Quit the application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:3039" from xweb_human_emulator import * # начало echo("<hr><font color=blue>sound.xxxxxxxxx</font><hr>") path = "test\\test_create.docx"; word.kill(); # 1 echo("1. Создать docx файл : "); echo(word.create(path,"новый текст")); # 2 tableArray = [ [10,12,14] ,[0,1,2] ]; echo("\n2. Добавим таблицу : "); echo(word.add_table(path,tableArray)); app.shell_execute("open",path); # конец 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(); // начало echo("<hr><font color=blue>word.add_text</font><hr>"); var path = "test\\test_create.docx"; word.kill(); // 1 echo("1. Создать docx файл : "); echo(word.create(path,"новый текст")); // 2 string[][] tableArray = new string[][] { new string[] {"1.1", "1.2"}, new string[] {"2.1", "2.2", "2.3", "2.4"}, new string[] {"3.1", "3.2", "3.3"} }; echo("\n2. Добавим таблицу : "); echo(word.add_table(path,tableArray)); app.shell_execute("open",path); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:3039"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>sound.beep</font><hr>"); var path = "test\\test_create.docx"; word.kill(); // 1 echo("1. Создать docx файл : "); echo(word.create(path,"новый текст")); // 2 var tableArray = [ ["1", "2"], ["3", "4"], ["5", "6"] ]; echo("\n2. Добавим таблицу : "); echo(word.add_table(path,tableArray)); app.shell_execute("open",path); // конец echo("\n"); // Quit app.quit();
=============================================
word Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.