WriteValuesToRow

TwinCAT TIA
Local File and directory access Excel

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

The command writes new values to the cells of a row of the specified Excel worksheet in a specified path.

Parameters:

    FileFullPath
    Path of the file. The file can be either a local file or a file stored on a network drive.

Returns:

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bExcelWriteValuesToRow
    A boolean variable that can be used to trigger the execution of the WriteValuesToRow command.
    OutputDataWriteValuesToRow
    An instance of "ST_VoidOutputData" into which the return value of the WriteValuesToRow method is written.
    hrExcelWriteValuesToRow
    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.
    nRowNumber
    A DINT variable containing the row index.
    nStartColumnNumber
    A DINT variable containing the start column index of the cells to be written.
    WriteValuesArray
    An array of STRING(255) values to be written to the cells.
    nNumberOfValues
    A UINT variable containing the number of values to be written.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
     bExcelWriteValuesToRow     : BOOL;
     OutputDataWriteValuesToRow    : ST_VoidOutputData;
     hrExcelWriteValuesToRow     : HRESULT; 
     WriteValuesArray       : ARRAY[1..50] OF STRING(255) := ['val1','val2', 'val3'];

     fbExcel : FB_Excel;
END_VAR

hrExcelWriteValuesToRow := fbExcel.WriteValuesToRow(
          bExecute    := bExcelWriteValuesToRow,   
          ConnectionHandle := depragSmartConnection.ConnectionHandle, 
          sFileFullPath  := 'C:\Test\TestFile.xlsx',
          sWorksheetName  := 'Testsheet',
          nRowNumber   := 1,
          nStartColumnNumber := 1,
          sValueToWrite  := WriteValuesArray,
          nNumberOfValues  := 3,
          OutputData   => OutputDataWriteValuesToRow);
IF hrExcelWriteValuesToRow <> S_FALSE THEN 
     bExcelWriteValuesToRow := 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".