ReadCellsFromRow

TwinCAT TIA
Local File and directory access Excel

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

The command reads the values of cells of a row with specified start and end column index 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.
    Separator
    Separator between the read values of the cells.

Returns:

    ReadCellsFromRow
    A variable of type OpcMethodReturnValueString.
      Result
      Read values from excel sheet separated with specified separators.

Examples:

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

Beckhoff parameter:

    bExcelReadCellsFromRow
    A boolean variable that can be used to trigger the execution of the ReadCellsFromRow command.
    OutputDataReadCellsFromRow
    An instance of "ST_StringOutputData" into which the return value of the ReadCellsFromRow method is written.
    hrExcelReadCellsFromRow
    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 read.
    nEndColumnNumber
    A DINT variable containing the end column index of the cells to be read.
    Separator
    A STRING(255) variable containing the separators between the read values of the cells.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
     bExcelReadCellsFromRow     : BOOL;
     OutputDataReadCellsFromRow    : ST_StringOutputData;
     hrExcelReadCellsFromRow     : HRESULT;

     fbExcel : FB_Excel;
END_VAR

hrExcelReadCellsFromRow := fbExcel.ReadCellsFromRow(
          bExecute    := bExcelReadCellsFromRow,   
          ConnectionHandle := depragSmartConnection.ConnectionHandle, 
          sFileFullPath  := 'C:\Test\TestFile.xlsx',
          sWorksheetName  := 'Testsheet',
          nRowNumber   := 1,
          nStartColumnNumber := 2,
          nEndColumnNumber := 5,
          Separator   := ',',
          OutputData   => OutputDataReadCellsFromRow);
IF hrExcelReadCellsFromRow <> S_FALSE THEN 
     bExcelReadCellsFromRow := 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".