humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
get_text_blocks_count_odt
get_text_blocks_count_odt($file_path,$timeout=300); - Прочитать файл формата OpenDocument Text с расширением '.odt'Функция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Count text blocks in an ODT document $xhe_host = getenv("RPABOT_HOST_URL"); // подключим функциональные объекты, если еще не подключен 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 >libreOffice->".basename (__FILE__)."</span>\n"; // Path to the ODT file to analyze $filePath = "test/test_style.odt"; // Example 1: Get the count of text blocks in the ODT file echo "\n\nExample 1: Get the count of text blocks in the ODT file\n"; $textBlocksCount = SYSTEM::$libreOffice->get_text_blocks_count_odt($filePath); if ($textBlocksCount >= 0) { echo "The ODT file contains $textBlocksCount text blocks.\n"; } else { echo "Error: Failed to count text blocks in the ODT file.\n"; } // Example 2: Get the count with custom timeout echo "\n\nExample 2: Get the count with custom timeout\n"; $timeout = 600; $textBlocksCount = SYSTEM::$libreOffice->get_text_blocks_count_odt($filePath, $timeout); if ($textBlocksCount >= 0) { echo "With extended timeout: The ODT file contains $textBlocksCount text blocks.\n"; } else { echo "Error: Failed to count text blocks in the ODT file with extended timeout.\n"; } // Quit the application WINDOW::$app->quit(); ?>
# Example for get_text_blocks_count_odt function # # This example demonstrates how to count the number of text blocks in an ODT file # using the XHELibreOffice class. import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7013" from xweb_human_emulator import libreOffice, app, echo # начало echo("<hr><font color=blue>libreOffice->get_text_blocks_count_odt</font><hr>") # Path to the ODT file to analyze filePath = "test/test_style.odt" # Get the count of text blocks in the ODT file textBlocksCount = libreOffice.get_text_blocks_count_odt(filePath) textBlocksCount = int(textBlocksCount) if textBlocksCount >= 0: echo(f"The ODT file contains {textBlocksCount} text blocks.\n") else: echo("Error: Failed to count text blocks in the ODT file.\n") # Example with custom timeout textBlocksCount = libreOffice.get_text_blocks_count_odt(filePath, 600) textBlocksCount = int(textBlocksCount) if textBlocksCount >= 0: echo(f"With extended timeout: The ODT file contains {textBlocksCount} text blocks.\n") else: echo("Error: Failed to count text blocks in the ODT file with extended timeout.\n") # Quit app.quit()
using System; /** * Example for get_text_blocks_count_odt function * * This example demonstrates how to count the number of text blocks in an ODT file * using the XHELibreOffice class. */ // Scenario: Count text blocks in an ODT document namespace XHELibreOfficeExamples { class GetTextBlocksCountOdtExample { static void Main(string[] args) { string xheHost = "127.0.0.1:7010"; // Initialize XHE API connection // In C#, you would initialize the XHE API client here // This is equivalent to including init.php in PHP Console.WriteLine("\nlibreOffice->get_text_blocks_count_odt.cs"); // Path to the ODT file to analyze string filePath = "test/test_style.odt"; // Example 1: Get the count of text blocks in the ODT file Console.WriteLine("\n\nExample 1: Get the count of text blocks in the ODT file"); int textBlocksCount = libreOffice.get_text_blocks_count_odt(filePath); if (textBlocksCount >= 0) { Console.WriteLine($"The ODT file contains {textBlocksCount} text blocks."); } else { Console.WriteLine("Error: Failed to count text blocks in the ODT file."); } // Example 2: Get the count with custom timeout Console.WriteLine("\n\nExample 2: Get the count with custom timeout"); int timeout = 600; textBlocksCount = libreOffice.get_text_blocks_count_odt(filePath, timeout); if (textBlocksCount >= 0) { Console.WriteLine($"With extended timeout: The ODT file contains {textBlocksCount} text blocks."); } else { Console.WriteLine("Error: Failed to count text blocks in the ODT file with extended timeout."); } // Quit the application app.quit(); } } }
/** * Example for get_text_blocks_count_odt function * * This example demonstrates how to count the number of text blocks in an ODT file * using the XHELibreOffice class. */ xhe_host = "127.0.0.1:7013"; // подключим функциональные объекты, если еще не подключен require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>libreOffice.get_text_blocks_count_odt</font><hr>"); // Path to the ODT file to analyze const filePath = "test/test_style.odt"; // Get the count of text blocks in the ODT file let textBlocksCount = libreOffice.get_text_blocks_count_odt(filePath); if (textBlocksCount >= 0) { echo("The ODT file contains " + textBlocksCount + " text blocks.\n"); } else { echo("Error: Failed to count text blocks in the ODT file.\n"); } // Example with custom timeout textBlocksCount = libreOffice.get_text_blocks_count_odt(filePath, 600); if (textBlocksCount >= 0) { echo("With extended timeout: The ODT file contains " + textBlocksCount + " text blocks.\n"); } else { echo("Error: Failed to count text blocks in the ODT file with extended timeout.\n"); } // Quit app.quit()
=============================================
libreoffice Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.