CreateNewExcelWorksheet

TwinCAT TIA
Local File and directory access Excel

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

The command creates a new Excel worksheet in a specified path. If the specified Excel worksheet already exists, no new Excel worksheet will be created.

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:

    bExcelCreateNewExcelWorksheet
    A Boolean variable that can be used to trigger the execution of the CreateNewExcelWorksheet command.
    OutputDataExcelCreateNewExcelWorksheet
    An instance of "ST_VoidOutputData" in which the return value of the CreateNewExcelWorksheet method is written.
    hrExcelCreateNewExcelWorksheet
    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.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
     bExcelCreateNewExcelWorksheet   : BOOL;
     OutputDataExcelCreateNewExcelWorksheet : ST_VoidOutputData;
     hrExcelCreateNewExcelWorksheet   : HRESULT;

     fbExcel : FB_Excel;
END_VAR

hrExcelCreateNewExcelWorksheet := fbExcel.CreateNewExcelWorksheet(
           bExecute    := bExcelCreateNewExcelWorksheet,   
           ConnectionHandle := depragSmartConnection.ConnectionHandle, 
           sFileFullPath  := 'C:\Test\TestFile.xlsx',
           sWorksheetName  := 'Testsheet',
           OutputData   => OutputDataExcelCreateNewExcelWorksheet);
IF hrExcelCreateNewExcelWorksheet <> S_FALSE THEN 
     bExcelCreateNewExcelWorksheet := 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".