WriteValueToCell

TwinCAT TIA
Lokal Datei- und Ordner-Zugriff Excel

ns=2;s=DEPRAG Smart/Local/FileAndDirectoryAccess/Excel/WriteValueToCell

Der Befehl schreibt einen neuen Inhalt in eine Zelle des angegebenen Exceltabellenblatts in einem angegebenen Pfad.

Parameter:

    FileFullPath
    Pfad der Datei. Die Datei kann entweder eine lokale Datei sein oder eine Datei, die auf einem Netzwerklaufwerk abgelegt ist.

Rückgabewert:

Beispiele:

Neben den bereits erläuterten Parametern sind für die Implementierung in TwinCAT 3 nachfolgende Variablen anzulegen / zu übergeben:

Beckhoff Parameter:

    bExcelWriteValueToCell
    Eine boolesche Variable, über welche die Ausführung des WriteValueToCell-Befehls getriggert werden kann.
    OutputDataWriteValueToCell
    An instance of "ST_VoidOutputData" into which the return value of the WriteValueToCell method is written.
    hrExcelWriteValueToCell
    This can be used to monitor the execution of the command. Error codes have the type "HRESULT".
    fbExcel
    An instance of the "FB_Excel" function block supplied with the DEPRAG Smart library.
    sFileFullPath
    A STRING variable containing the full path of the Excel file.
    sWorksheetName
    A STRING variable containing the name of the Excel worksheet.
    sValueToWrite
    A String(255) variable with the value to be written to the cell.
    nRowNumber
    A DINT variable containing the row index.
    nColumnNumber
    A DINT variable containing the column index.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
     bExcelWriteValueToCell     : BOOL;
     OutputDataWriteValueToCell    : ST_VoidOutputData;
     hrExcelWriteValueToCell     : HRESULT;

     fbExcel : FB_Excel;
END_VAR

hrExcelWriteValueToCell := fbExcel.WriteValueToCell(
          bExecute    := bExcelWriteValueToCell,   
          ConnectionHandle := depragSmartConnection.ConnectionHandle, 
          sFileFullPath  := 'C:\Test\TestFile.xlsx',
          sWorksheetName  := 'Testsheet',
          sValueToWrite  := '123',
          nRowNumber   := 1,
          nColumnNumber  := 1,
          OutputData   => OutputDataWriteValueToCell);
IF hrExcelWriteValueToCell <> S_FALSE THEN 
     bExcelWriteValueToCell := FALSE;
END_IF
                                                    

For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".