humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | Changelog

set_cell_font

set_cell_font($path,$sheet,$row,$col,$font); - Задать шрифт заданной ячейки XHE_Font

Функция на вход принимает параметры:

  • $path – Путь к файлу Excel
  • $sheet – Номер Листа
  • $row – Номер строки
  • $col – Колонка. Буквенное или цифровое значение
  • $font – объект типа XHE_Font

    После выполнения функции возвращаемое значение будет равно одному из двух :
  • true – успешно
  • false – не удалось

    Пример использования
    <?php
    // Scenario: Set font properties for a cell in an Excel file
    $xhe_host = getenv("RPABOT_HOST_URL");
    // Connect functional objects if not already connected
    if (!isset($path)){
      $path = "../../../Templates/init.php";
      require($path);
    }
    
    // beginning
    echo "\n<span >excelfile->".basename (__FILE__)."</span>\n";
    
    // Example 1: Set cell font with multiple properties
    SYSTEM::$excel->kill();
    $filePath = "test/test.xlsx";
    $sheetIndex = 0;
    $row = 6;
    $column = "A";
    
    // Create font object with properties
    $font = new XHEFont();
    $font->name = "Arial";
    $font->is_bold = true;
    $font->is_italic = true;
    $font->is_striketrough = true;
    $font->is_underline = true;
    $font->is_shadow = true;
    $font->size = 20;
    
    echo("1. Set font properties for cell at row $row, column $column: ");
    $result = SYSTEM::$excel->set_cell_font($filePath, $sheetIndex, $row, $column, $font);
    if ($result) {
        echo("Successfully set font properties for cell\n");
        echo("Font properties: Name=$font->name, Bold=$font->is_bold, Italic=$font->is_italic, ");
        echo("Striketrough=$font->is_striketrough, Underline=$font->is_underline, Shadow=$font->is_shadow, Size=$font->size\n");
    } else {
        echo("Failed to set font properties for cell\n");
    }
    
    // end
    echo "\n";
    
    // Quit
    WINDOW::$app->quit();
    ?>
    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7026"
    from xweb_human_emulator import *
    
    # начало
    echo("<hr><font color=blue>excelfile.set_cell</font><hr>")
    
    # шрифт
    font=XHEFont()
    font.name="Arial"
    font.is_bold=true
    font.is_italic=true
    font.size=20
    
    # 1
    echo("\n1. Зададим шрифт ячейки : ");
    echo(excel.set_cell_font("test\\test.xlsx",0,2,"A",font));
    
    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 = Environment.GetEnvironmentVariable("RPABOT_HOST_URL");
    			InitXHE();
    
    			// начало
    			echo("<hr><font color=blue>excelfile.set_cell</font><hr>");
    
    			// шрифт
    			var font=new XHEFont();
    			font.name="Arial";
    			font.is_bold=true;
    			font.is_italic=true;
    			font.size=20;
    			
    			// 1 
    			echo("\n1. Зададим шриф ячейки : "+font.ToString());
    			echo(excel.set_cell_font("test\\test.xlsx",0,2,"A",font));
    
    			app.shell_execute("open","test\\test.xlsx");
    
    			// конец
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    xhe_host="127.0.0.1:7026";
    echo=require("../../../Templates JS/init.js");
    XHEFont=require("../../../Templates JS/Objects/xhe_font.js");
    
    // начало
    echo("<hr><font color=blue>excelfile.get_cell</font><hr>");
    
    // шрифт
    var font=new XHEFont();
    font.name="Arial";
    font.is_bold=true;
    font.is_italic=true;
    font.size=20;
    
    // 1
    echo("\n1. Зададим шрифт ячейки : "+font+" => ");
    echo(excel.set_cell_font("test\\test.xlsx",0,2,"A",font));
    
    app.shell_execute("open","test\\test.xlsx");
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

    =============================================
    excel    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .