excel



 excel object is used to read or save the value of excel files. Users can save values or other information generated during operation as an excel file by using the excel object. Otherwise, it is used to read the value on the excel.




Methods




Return Type

Method

Description


close()

Close the operating excel file.


copySheet( originSheet, copySheet )

Copy the sheet of excel files.


deleteSheet( sheet )

Delete the sheet of excel files.

str

errorMessage()

When opening or saving an excel file is failed, it is able to check an error message.

  str

getStringValue( sheet, column, row )

When entering a sheet, column, and row of excel files, it obtains the value as Sting.

int or float

getValue( sheet, column, row )

When entering a sheet, column, and row of excel files, it obtains the value as Numeric.

boolean

open( path )

Open the excel file for that path.

boolean

save( path )

Save the excel file on that path.


setStringValue( sheet, column, row, value )

Set the entered String on the location of the sheet, column, row of excel files.


setValue( sheet, column, row, value )

Set the entered Numbers on the location of the sheet, column, row of excel files.

       

  boolean open( path:Excel file path )

 

  Open the excel file for that path.


        ㆍ Users enter the file path to path as String.

                - If the excel file is in the project. : Enter the name of excel files including the extension.

                        Example) When opening 'test.xls' in the project : Enter 'test.xls'.


                - If the excel file is not in the project : Enter the entire path of excel files.

                        Example) When opening 'test.xls' in 'C:\\' : Enter 'C:\\test.xls'.


        ㆍ If opening a file succeeds, return TRUE, if it fails, return FALSE.

                - If opening a file succeeds : True(1)

                - If opening a file fails : False(0)



  Example)

   


       excel.open('c:\\test.xls')  # Open 'test.xls' in 'c:\\'.





  boolean save( path:Excel file path )

 

  path에 Save the operating excel file on that path.


        ㆍ Users enter the file path to path as String.

                - If the excel file is in the project : Enter the name of excel files including the extension.

                        Example)When opening 'test.xls' in the project : Enter 'test.xls'.


                - If the excel file is not in the project : Enter the entire path of excel files.

                        Example) When opening 'test.xls' in 'C:\\' : Enter 'C:\\test.xls'.


        ㆍ If saving a file succeeds, return TRUE, if it fails, return FALSE.

                - If saving a file succeeds : True(1)

                - If saving a file fails : False(0)


  ※ Precautions

        ㆍ You must enter the extension of the open method and save method identically.

        ㆍ When the same path is entered on the save method and open method, the data of the original file could be disappeared because the excel file had been overwritten.



  Example)

   


       # Enter the file extension of the open method and save method identically.


       # If the extension is '.xls'.

       excel.open('c:\\test.xls')

       excel.save('d:\\test_save.xls')

       

       # If the extension is '.xlsx'.

       excel.open('c:\\test.xlsx')

       excel.save('d:\\test_save.xlsx')

       




  close()

 

  close method closes the operating excel file.


        ㆍ close method has no return values.



  Example)

   


       excel.close()  # Close the operating excel file.


       



  int or float getValue( sheet:Sheet name, column:Column name, row:Row name )

 

  getValue obtains the value as Numeric when the sheet, column, and row of excel files are entered.


        ㆍ Enter the name of sheets of the operating excel file to sheet.

        ㆍ Enter the column of that sheet to column.

        ㆍ Enter the row of that sheet to row.


  ※ Precautions

        ㆍ When obtaining the text or the String using getValue, return 0.



  Example)

   


       excel.open('C:\\test.xls')  # Open 'test.xls' in 'c:\\'


       v1 = excel.getValue('Sheet1', 'A', '3')  # Obtain the value of cell A3 on Sheet1.

       v2 = excel.getValue('Sheet1', 'E', '5')  # Obtain the value of cell E5 on Sheet1.


       



  str getStringValue( sheet:Sheet name, column:Column name, row:Row name )

 

        ㆍ Enter the row of that sheet to row



  Example)

   


       excel.open('C:\\test.xls')  # Open 'test.xls' on 'c:\\'.

       

       v1 = excel.getStringValue('Sheet1', 'A', '3')  # Obtain the value of cell A3 on Sheet1.

       v2 = excel.getStringValue('Sheet1', 'E', '5')  # Obtain the value of cell E5 on Sheet1.


       



  setValue( sheet:Sheet name, column:Column name, row:Row name, value:Numbers )

 

  setValue enters the value to the selected location (Sheet, Column, Row) in the operating excel file.


        ㆍ Enter the name of sheets of excel files to sheet.

        ㆍ Enter the column of that sheet to column.

        ㆍ Enter the row of that sheet to column.

        ㆍ value is the number to set.


  setValue has no return values.



  Example)

   


       excel.open('C:\\test.xlsx')  # Open 'test.xlsx' in 'c:\\'.

       

       # Obtain the value of 'Station.Point'.

       p = scada.getAnalogValue('Station.Point')

       

       # Set the pvalue of analog points to B3 cell of Sheet1.

       excel.setValue('Sheet1', 'B', '3', p)


             



               




  setStringValue( sheet:Sheet name, column:Column name, row:Row name, value:String )

 

  setValue enters the value on the selected location(Sheet, column, row) in the operating excel file.


        ㆍ Enter the name of sheets of excel files to sheet.

        ㆍ Enter the column of that sheet to column.

        ㆍ Enter the row of that sheet to row.

        ㆍ value is the String you want to set.


  setStringValue has no return values.



  Example)

   


       excel.open('C:\\test.xlsx')  # Open 'test.xlsx' in 'c:\\'.


       # Set the String '' to cell B2 of Sheet1.

       excel.setStringValue('Sheet1', 'B', '2', 'Solar Energy')


             


               




  str errorMessage()

 

  When opening or saving an excel file failed, it is able to check an error message.



  Example) When opening an excel file failed.


   


       open = excel.open('C:\\test.xlsx')  # Open 'test.xlsx' in 'c:\\'.


       # When opening an excel file failed. it is able to find the cause of failure through error messages.

       if( open == 0 ):

              openError = excel.errorMessage();

              app.messageBox('File open failed', openError);  # Print an error message on the message box.


             


                =



 Example) When saving an excel file failed.


   


       save = excel.save('C:\\test_save.xlsx')  # Save 'test_save.xlsx' to 'c:\\'.


       # When saving an excel file failed, it is able to find the cause of failure through error messages.

       if( save == 0 ):

              saveError = excel.errorMessage();

              app.messageBox('File save failed', saveError);  # Print an error message on the message box.


           


               



  copySheet( orignSheet:Original sheet, copySheet:Copy sheet )

 

  copySheet is used to copy an excel sheet.


        ㆍ Enter the original sheet to originSheet.

        ㆍ Enter the copy sheet to copySheet.


  ※ Precautions

        ㆍ When the same path is entered on save method and open method, the data of the original file could disappear because the excel file has overwritten.


  Example)

   


       excel.open('C:\\test.xlsx')  # Open 'test.xlsx' in 'c:\\'.


       excel.copySheet('origin', 'copy')  # Copy the sheet of origin file to the sheet of copy file.


       excel.save('C:\\test.xlsx')


             



  deleteSheet( sheet:The name of sheet to be deleted )

 

  deleteSheet is used to delete an excel sheet.


        ㆍ Enter the name of sheets to sheet.


  ※ Precautions

        ㆍ When the same path is entered on save method and open method, the data of the original file could disappear because the excel file has overwritten.


  Example)

   


       excel.open('C:\\test.xlsx')  # Open 'test.xlsx' in 'c:\\'.


       excel.deleteSheet('delete')  # Delete 'delete' sheet.


       excel.save('C:\\test.xlsx')