humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
open
open($path,$timeout=6000); - открыть файл для дальнейшей работы с ним (Доступна с версии 7.0.58)Функция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: Open Excel file $xhe_host = "localhost:7010"; // 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"; // Extract method arguments into variables $filePath = "test/test.xlsx"; // Initialize Excel SYSTEM::$excel->kill(); // Example 1: Open file echo("Example 1: Open file : "); $timeout = 600; $showExcel = true; $result = SYSTEM::$excelfile->open($filePath, $timeout, $showExcel); if ($result === true) echo("true\n"); else echo("false\n"); // Example 2: Output all cells echo("\nExample 2: Output all cells : "); // Extract method arguments into variables $sheetIndex = 0; for ($k=1;$k<=SYSTEM::$excelfile->get_rows_count($filePath, $sheetIndex);$k++) { for ($j=1;$j<=SYSTEM::$excelfile->get_cols_count($filePath, $sheetIndex);$j++) echo SYSTEM::$excelfile->get_cell($filePath, $sheetIndex, $k, $j)."|"; echo "\n"; } // Example 3: Copy cells to sheet 2 with new colors echo("\nExample 3: Copy cells to sheet 2 with new colors: "); // Extract method arguments into variables $destSheetIndex = 1; $bgColor = "FF0000FF"; $fgColor = "FFFFFF00"; for ($k=1;$k<=SYSTEM::$excelfile->get_rows_count($filePath, $sheetIndex);$k++) { for ($j=1;$j<=SYSTEM::$excelfile->get_cols_count($filePath, $sheetIndex);$j++) { echo SYSTEM::$excelfile->set_cell($filePath, $destSheetIndex, $k, $j, SYSTEM::$excelfile->get_cell($filePath, $sheetIndex, $k, $j)) . "\n"; SYSTEM::$excelfile->set_cell_background_color($filePath, $destSheetIndex, $k, $j, $bgColor); SYSTEM::$excelfile->set_cell_color($filePath, $destSheetIndex, $k, $j, $fgColor); } echo "\n"; } // Example 4: Save file echo("\nExample 4: Save file : "); $result = SYSTEM::$excelfile->save($filePath); if ($result === true) echo("true\n"); else echo("false\n"); // Example 5: Close file echo("\nExample 5: Close file : "); $result = SYSTEM::$excelfile->close($filePath); if ($result === true) echo("true\n"); else echo("false\n"); // View the result // 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:3039" from xweb_human_emulator import * # начало echo("<hr><font color=blue>excelfile.get_sheets_count</font><hr>") # путь к файлу path="test\\test.xlsx"; # 1 echo("\n1. Откроем : "); echo(excelfile.open(path)); # 2 echo("\n2. Выведем все ячейки : "); for i in range(1, excelfile.get_rows_count(path,0)): for j in range(1, excelfile.get_cols_count(path,0)): echo(excelfile.get_cell(path,0,i,j)+"|") echo("\n") # 3 echo("\n3. Скопируем ячейки на 2 лист c новыми цветами: "); for i in range(1, excelfile.get_rows_count(path,0)): for j in range(1, excelfile.get_cols_count(path,0)): echo(excelfile.set_cell(path,1,i,j,excelfile.get_cell(path,0,i,j))," ") excelfile.set_cell_background_color(path,1,i,j,"FF0000FF") excelfile.set_cell_color(path,1,i,j,"FFFFFF00") echo("\n") # 4 echo("\n4. Сохраним : "); echo(excelfile.save(path)); # 5 echo("\n5. Закроем : ") echo(excelfile.close(path)) # посмотрим 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 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 = "localhost:7010"; InitXHE(); // начало echo("<hr><font color=blue>excelfile.get_sheets_count</font><hr>"); // путь к файлу string path="test\\test.xlsx"; // 1 echo("\n1. Откроем : "); echo(excelfile.open(path)); // 2 echo("\n2. Выведем все ячейки : "); for (int i=1;i<=excelfile.get_rows_count(path,0);i++) { for (int j=1;j<=excelfile.get_cols_count(path,0);j++) echo(excelfile.get_cell(path,0,i,j.ToString())+"|"); echo("\n"); } // 3 echo("\n3. Скопируем ячейки на 2 лист c новыми цветами: "); for (int i=1;i<=excelfile.get_rows_count(path,0);i++) { for (int j=1;j<=excelfile.get_cols_count(path,0);j++) { echo(excelfile.set_cell(path,1,i,j.ToString(),excelfile.get_cell(path,0,i,j.ToString()))+" "); excelfile.set_cell_background_color(path,1,i,j.ToString(),"FF0000FF"); excelfile.set_cell_color(path,1,i,j.ToString(),"FFFFFF00"); } echo("\n"); } // 4 echo("\n4. Сохраним : "); echo(excelfile.save(path)); // 5 echo("\n5. Закроем : "); echo(excelfile.close(path)); // посмотрим app.shell_execute("open","test\\test.xlsx"); // конец echo("\n\n"); app.quit(); } }
xhe_host="127.0.0.1:3039";
echo=require("../../../Templates JS/init.js");
// начало
echo("<hr><font color=blue>excelfile.get_sheets_count</font><hr>");
// путь к файлу
path="test\\test.xlsx";
// 1
echo("\n1. Откроем : ");
echo(excelfile.open(path));
// 2
echo("\n2. Выведем все ячейки : ");
for (i=1;i<=excelfile.get_rows_count(path,0);i++)
{
for (j=1;j<=excelfile.get_cols_count(path,0);j++)
echo(excelfile.get_cell(path,0,i,j)+"|");
echo("\n");
}
// 3
echo("\n3. Скопируем ячейки на 2 лист c новыми цветами: ");
for (i=1;i<=excelfile.get_rows_count(path,0);i++)
{
for (j=1;j<=excelfile.get_cols_count(path,0);j++)
{
echo(excelfile.set_cell(path,1,i,j,excelfile.get_cell(path,0,i,j))+" ");
excelfile.set_cell_background_color(path,1,i,j,"FF0000FF");
excelfile.set_cell_color(path,1,i,j,"FFFFFF00");
}
echo("\n");
}
// 4
echo("\n4. Сохраним : ");
echo(excelfile.save(path));
// 5
echo("\n5. Закроем : ");
echo(excelfile.close(path));
// посмотрим
app.shell_execute("open","test\\test.xlsx");
// конец
echo("\n");
// Quit
app.quit();=============================================
excelfile Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.