Основной сайт хуманэмулятор.рф | Демо | Купить | API | Wiki
System / libreoffice
get_header_text_blocks_count_odt
get_header_text_blocks_count_odt($file_path,$timeout=300); - Получить количество блоков строк в odt файле типа `header`Функция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Count header text blocks in an ODT document and retrieve all headers $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"; // Example 1: Count header text blocks in a document echo "\n\nExample 1: Counting header text blocks in a document\n"; $filePath = "test/test_style.odt"; $headerCount = SYSTEM::$libreOffice->get_header_text_blocks_count_odt($filePath); if ($headerCount >= 0) { echo "The ODT file contains {$headerCount} header text blocks.\n"; } else { echo "Error: Failed to count header text blocks in the ODT file.\n"; } // Example 2: Get all headers from a document echo "\n\nExample 2: Get all headers from a document\n"; $headerCount = SYSTEM::$libreOffice->get_header_text_blocks_count_odt($filePath); if ($headerCount > 0) { for ($headerIndex = 0; $headerIndex < $headerCount; $headerIndex++){ $headerTextBlock = SYSTEM::$libreOffice->get_header_text_block_by_index_odt($filePath, $headerIndex); if (!empty($headerTextBlock)) { echo "header $headerIndex:\n$headerTextBlock\n"; } else { echo "No header found at index {$headerIndex} or error occurred.\n"; } } } // Quit the application WINDOW::$app->quit(); ?>
# Example for get_header_text_blocks_count_odt function # # This example demonstrates how to count the number of header 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 * # начало echo("<hr><font color=blue>libreOffice->get_header_text_blocks_count_odt</font><hr>") # file path filePath = "test/test_style.odt" # Example 1: Count header text blocks in a document echo("Example 1: Counting header text blocks in a document\n") headerCount = libreOffice.get_header_text_blocks_count_odt(filePath) headerCount = int(headerCount) if headerCount >= 0: echo(f"The ODT file contains {headerCount} header text blocks.\n") else: echo("Error: Failed to count header text blocks in the ODT file.\n") # Example 2: Get all headers from a document echo("Example 2: Get all headers from a document\n") headerCount = libreOffice.get_header_text_blocks_count_odt(filePath) headerCount = int(headerCount) if headerCount > 0: for headerIndex in range(0, headerCount): headerTextBlock = libreOffice.get_header_text_block_by_index_odt(filePath, headerIndex) if headerTextBlock: echo(f"header #{headerIndex}:\n{headerTextBlock}\n") else: echo(f"No header found at index {headerIndex} or error occurred.\n") # Quit app.quit()
using System; /** * Example for get_header_text_blocks_count_odt function * * This example demonstrates how to count the number of header text blocks in an ODT file * using the XHELibreOffice class. */ // Scenario: Count header text blocks in an ODT document and retrieve all headers namespace XHELibreOfficeExamples { class GetHeaderTextBlocksCountOdtExample { 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_header_text_blocks_count_odt.cs"); // Example 1: Count header text blocks in a document Console.WriteLine("\n\nExample 1: Counting header text blocks in a document"); string filePath = "test/test_style.odt"; int headerCount = SYSTEM.libreOffice.get_header_text_blocks_count_odt(filePath); if (headerCount >= 0) { Console.WriteLine($"The ODT file contains {headerCount} header text blocks."); } else { Console.WriteLine("Error: Failed to count header text blocks in the ODT file."); } // Example 2: Get all headers from a document Console.WriteLine("\n\nExample 2: Get all headers from a document"); headerCount = SYSTEM.libreOffice.get_header_text_blocks_count_odt(filePath); if (headerCount > 0) { for (int headerIndex = 0; headerIndex < headerCount; headerIndex++) { string headerTextBlock = SYSTEM.libreOffice.get_header_text_block_by_index_odt(filePath, headerIndex); if (!string.IsNullOrEmpty(headerTextBlock)) { Console.WriteLine($"header {headerIndex}:\n{headerTextBlock}"); } else { Console.WriteLine($"No header found at index {headerIndex} or error occurred."); } } } // Quit the application app.quit(); } } }
/** * Example for get_header_text_blocks_count_odt function * * This example demonstrates how to count the number of header text blocks in an ODT file * using the XHELibreOffice class. */ xhe_host = "127.0.0.1:7013"; // подключим функциональные объекты, если еще не подключен require("../../../Templates JS/init.js"); // Example 1: Count header text blocks in a document echo("Example 1: Counting header text blocks in a document\n"); const filePath = "test/test_style.odt"; let headerCount = libreOffice.get_header_text_blocks_count_odt(filePath); if (headerCount >= 0) { echo("The ODT file contains " + headerCount + " header text blocks.\n"); } else { echo("Error: Failed to count header text blocks in the ODT file.\n"); } // Example 2: Get all headers from a document echo("Example 2: Get all headers from a document\n"); headerCount = libreOffice.get_header_text_blocks_count_odt(filePath); if (headerCount > 0) { for (let headerIndex = 0; headerIndex < headerCount; headerIndex++){ const headerTextBlock = libreOffice.get_header_text_block_by_index_odt(filePath, headerIndex); if (headerTextBlock) { echo("header #" + headerIndex + ":\n" + headerTextBlock + "\n"); } else { echo("No header found at index " + headerIndex + " or error occurred.\n"); } } } // Quit app.quit();
=============================================
libreoffice Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.