Class ExcelHelper


  • @OpenApiAll
    public class ExcelHelper
    extends java.lang.Object
    The helper class being used in the scripts for handling data transformation and other utilities between fUML runtime object and Excel file.
    Since:
    CST 18.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object getCellValue​(java.lang.String fileName, java.lang.String sheetName, java.lang.Number atRow, java.lang.Number atCol)
      get value by specific row and column in the excel file.
      int getLatestRowNum​(java.lang.String fileName, java.lang.String sheetName)
      Get the latest row number of the sheet in the excel file.
      fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet​(java.lang.String fileName, java.lang.Number rowIndex)
      Read the excel file and create the fUML ValueList.
      fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet​(java.lang.String fileName, java.lang.Number rowIndex, java.lang.Object mappingClass)
      Read the excel file and create the fUML ValueList.
      fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet​(java.lang.String fileName, java.lang.String sheetName, java.lang.Number rowIndex)
      Read the excel file and create the fUML ValueList.
      fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet​(java.lang.String fileName, java.lang.String sheetName, java.lang.Number rowIndex, java.lang.Object mappingClass)
      Read the excel file and create the fUML ValueList.
      fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName, java.lang.Number startRow, java.lang.Number endRow)
      Read the excel file and create the fUML ValueList.
      fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName, java.lang.Number startRow, java.lang.Number endRow, java.lang.Object mappingClass)
      Read the excel file and create the fUML ValueList.
      fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName, java.lang.Object mappingClass)
      Read the excel file and create the fUML ValueList for all rows in excel.
      fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName, java.lang.String name)
      Read the excel file and create the fUML ValueList for all rows in excel.
      fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName, java.lang.String sheetName, java.lang.Number startRow, java.lang.Number endRow)
      Read the excel file and create the fUML ValueList.
      fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName, java.lang.String sheetName, java.lang.Number startRow, java.lang.Number endRow, java.lang.Object mappingClass)
      Read the excel file and create the fUML ValueList.
      fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName, java.lang.String sheetName, java.lang.Object mappingClass)
      Read the excel file and create the fUML ValueList for all rows in excel.
      void setCellValue​(java.lang.Object object, java.lang.String fileName, java.lang.String sheetName, java.lang.Number atRow, java.lang.Number atCol)
      Set fUML runtime value to specific row and column in the excel file.
      void updatefUMLValueFromSpreadSheet​(fUML.Semantics.Classes.Kernel.StructuredValue value, java.lang.String fileName, java.lang.Number rowIndex)
      update the value of SpreadSheet to fUML runtime object.
      void updatefUMLValueFromSpreadSheet​(fUML.Semantics.Classes.Kernel.StructuredValue value, java.lang.String fileName, java.lang.Number rowIndex, java.lang.Object mappingClass)
      update the value of SpreadSheet to fUML runtime object.
      void updatefUMLValueFromSpreadSheet​(fUML.Semantics.Classes.Kernel.StructuredValue value, java.lang.String fileName, java.lang.String sheetName, java.lang.Number rowIndex)
      update the value of SpreadSheet to fUML runtime object.
      void updatefUMLValueFromSpreadSheet​(fUML.Semantics.Classes.Kernel.StructuredValue value, java.lang.String fileName, java.lang.String sheetName, java.lang.Number rowIndex, java.lang.Object mappingClass)
      update the value of SpreadSheet to fUML runtime object.
      void writeObjectsToSpreadSheet​(java.lang.Object object, java.lang.String fileName, java.lang.Number atRow, boolean isReplace)
      Write the fUML runtime value to the excel file.
      void writeObjectsToSpreadSheet​(java.lang.Object object, java.lang.String fileName, java.lang.Number atRow, boolean isReplace, java.lang.Object mappingClass)
      Write the fUML runtime value to the excel file.
      void writeObjectsToSpreadSheet​(java.lang.Object object, java.lang.String fileName, java.lang.String sheetName, java.lang.Number atRow, boolean isReplace)
      Write the fUML runtime value to the excel file.
      void writeObjectsToSpreadSheet​(java.lang.Object object, java.lang.String fileName, java.lang.String sheetName, java.lang.Number atRow, boolean isReplace, java.lang.Object mappingClass)
      Write the fUML runtime value to the excel file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ExcelHelper

        public ExcelHelper​(SimulationSession session)
        constructor.
        Parameters:
        session - the running session.
      • ExcelHelper

        public ExcelHelper​(SimulationSession session,
                           Element scriptContainer)
        constructor.
        Parameters:
        session - the running session.
      • ExcelHelper

        public ExcelHelper​(fUML.Semantics.Classes.Kernel.Object_ context)
        constructor.
        Parameters:
        context - the context of caller
    • Method Detail

      • getLatestRowNum

        public int getLatestRowNum​(java.lang.String fileName,
                                   java.lang.String sheetName)
        Get the latest row number of the sheet in the excel file.
        Parameters:
        fileName - the excel file name
        sheetName - the sheet name
        Returns:
        the latest row number of the sheet in the excel file
      • readObjectFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet​(java.lang.String fileName,
                                                                                 java.lang.Number rowIndex)
                                                                          throws java.lang.Exception
        Read the excel file and create the fUML ValueList.
        Parameters:
        fileName - the excel file name
        rowIndex - the index of row
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • readObjectFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet​(java.lang.String fileName,
                                                                                 java.lang.Number rowIndex,
                                                                                 java.lang.Object mappingClass)
                                                                          throws java.lang.Exception
        Read the excel file and create the fUML ValueList.
        Parameters:
        fileName - the excel file name
        rowIndex - the index of row
        mappingClass - the mapping class name String or mapping class Element
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • readObjectFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet​(java.lang.String fileName,
                                                                                 java.lang.String sheetName,
                                                                                 java.lang.Number rowIndex)
                                                                          throws java.lang.Exception
        Read the excel file and create the fUML ValueList.
        Parameters:
        fileName - the excel file name
        sheetName - the sheet name
        rowIndex - the index of row
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • readObjectFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet​(java.lang.String fileName,
                                                                                 java.lang.String sheetName,
                                                                                 java.lang.Number rowIndex,
                                                                                 java.lang.Object mappingClass)
                                                                          throws java.lang.Exception
        Read the excel file and create the fUML ValueList.
        Parameters:
        fileName - the excel file name
        sheetName - the sheet name
        rowIndex - the index of row
        mappingClass - the mapping class name String or mapping class Element
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • readObjectsFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName,
                                                                                  java.lang.Number startRow,
                                                                                  java.lang.Number endRow)
                                                                           throws java.lang.Exception
        Read the excel file and create the fUML ValueList.
        Parameters:
        fileName - the excel file name
        startRow - the start row number
        endRow - the end row number
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • readObjectsFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName,
                                                                                  java.lang.Number startRow,
                                                                                  java.lang.Number endRow,
                                                                                  java.lang.Object mappingClass)
                                                                           throws java.lang.Exception
        Read the excel file and create the fUML ValueList.
        Parameters:
        fileName - the excel file name
        startRow - the start row number
        endRow - the end row number
        mappingClass - the mapping class name String or mapping class Element
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • readObjectsFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName,
                                                                                  java.lang.String sheetName,
                                                                                  java.lang.Number startRow,
                                                                                  java.lang.Number endRow)
                                                                           throws java.lang.Exception
        Read the excel file and create the fUML ValueList.
        Parameters:
        fileName - the excel file name
        sheetName - the sheet name
        startRow - the start row number
        endRow - the end row number
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • readObjectsFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName,
                                                                                  java.lang.Object mappingClass)
                                                                           throws java.lang.Exception
        Read the excel file and create the fUML ValueList for all rows in excel.
        Parameters:
        fileName - the excel file name
        mappingClass - the mapping class name String or mapping class Element
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • readObjectsFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName,
                                                                                  java.lang.String name)
                                                                           throws java.lang.Exception
        Read the excel file and create the fUML ValueList for all rows in excel.
        Parameters:
        fileName - the excel file name
        name - the name of Mapping Class or sheet name.
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • readObjectsFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName,
                                                                                  java.lang.String sheetName,
                                                                                  java.lang.Object mappingClass)
                                                                           throws java.lang.Exception
        Read the excel file and create the fUML ValueList for all rows in excel.
        Parameters:
        fileName - the excel file name
        sheetName - the sheet name
        mappingClass - the mapping class name String or mapping class Element
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • readObjectsFromSpreadSheet

        public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet​(java.lang.String fileName,
                                                                                  java.lang.String sheetName,
                                                                                  java.lang.Number startRow,
                                                                                  java.lang.Number endRow,
                                                                                  java.lang.Object mappingClass)
                                                                           throws java.lang.Exception
        Read the excel file and create the fUML ValueList.
        Parameters:
        fileName - the excel file name
        sheetName - the sheet name
        startRow - the start row number
        endRow - the end row number
        mappingClass - the mapping class name String or mapping class Element
        Returns:
        the fUML ValueList of the data in the excel file
        Throws:
        java.lang.Exception - could be thrown if problem occurs when reading excel data
      • setCellValue

        public void setCellValue​(java.lang.Object object,
                                 java.lang.String fileName,
                                 java.lang.String sheetName,
                                 java.lang.Number atRow,
                                 java.lang.Number atCol)
        Set fUML runtime value to specific row and column in the excel file.
        Parameters:
        object - the fUML runtime value (ValueList/Value)
        fileName - the excel file name
        sheetName - the sheet name
        atRow - the row index number
        atCol - the column index number
      • getCellValue

        @CheckForNull
        public java.lang.Object getCellValue​(java.lang.String fileName,
                                             java.lang.String sheetName,
                                             java.lang.Number atRow,
                                             java.lang.Number atCol)
        get value by specific row and column in the excel file.
        Parameters:
        fileName - the excel file name
        sheetName - the sheet name
        atRow - the row index number
        atCol - the column index number
        Returns:
        the value of cell
      • updatefUMLValueFromSpreadSheet

        public void updatefUMLValueFromSpreadSheet​(fUML.Semantics.Classes.Kernel.StructuredValue value,
                                                   java.lang.String fileName,
                                                   java.lang.Number rowIndex)
                                            throws java.lang.Exception
        update the value of SpreadSheet to fUML runtime object.
        Parameters:
        value - the runtime object
        fileName - the spreadSheet file path
        rowIndex - the row index
        Throws:
        java.lang.Exception
      • updatefUMLValueFromSpreadSheet

        public void updatefUMLValueFromSpreadSheet​(fUML.Semantics.Classes.Kernel.StructuredValue value,
                                                   java.lang.String fileName,
                                                   java.lang.String sheetName,
                                                   java.lang.Number rowIndex)
                                            throws java.lang.Exception
        update the value of SpreadSheet to fUML runtime object.
        Parameters:
        value - the runtime object
        fileName - the spreadSheet file path
        sheetName - the sheet name
        rowIndex - the row index
        Throws:
        java.lang.Exception
      • updatefUMLValueFromSpreadSheet

        public void updatefUMLValueFromSpreadSheet​(fUML.Semantics.Classes.Kernel.StructuredValue value,
                                                   java.lang.String fileName,
                                                   java.lang.Number rowIndex,
                                                   java.lang.Object mappingClass)
                                            throws java.lang.Exception
        update the value of SpreadSheet to fUML runtime object.
        Parameters:
        value - the runtime object
        fileName - the spreadSheet file path
        rowIndex - the row index
        mappingClass - the mapping class name String or mapping class Element
        Throws:
        java.lang.Exception
      • updatefUMLValueFromSpreadSheet

        public void updatefUMLValueFromSpreadSheet​(fUML.Semantics.Classes.Kernel.StructuredValue value,
                                                   java.lang.String fileName,
                                                   java.lang.String sheetName,
                                                   java.lang.Number rowIndex,
                                                   @CheckForNull
                                                   java.lang.Object mappingClass)
                                            throws java.lang.Exception
        update the value of SpreadSheet to fUML runtime object.
        Parameters:
        value - the runtime object
        fileName - the spreadSheet file path
        sheetName - the sheet name
        rowIndex - the row index
        mappingClass - the mapping class name String or mapping class Element
        Throws:
        java.lang.Exception
      • writeObjectsToSpreadSheet

        public void writeObjectsToSpreadSheet​(java.lang.Object object,
                                              java.lang.String fileName,
                                              java.lang.Number atRow,
                                              boolean isReplace,
                                              java.lang.Object mappingClass)
                                       throws java.lang.Exception
        Write the fUML runtime value to the excel file.
        Parameters:
        object - the fUML runtime value (ValueList/Value)
        fileName - the excel file name
        atRow - the row number to write the data
        isReplace - if true, it will replace the existing data if false, it will insert the data at atRow
        mappingClass - the mapping class name String or mapping class Element
        Throws:
        java.lang.Exception
      • writeObjectsToSpreadSheet

        public void writeObjectsToSpreadSheet​(java.lang.Object object,
                                              java.lang.String fileName,
                                              java.lang.String sheetName,
                                              java.lang.Number atRow,
                                              boolean isReplace)
                                       throws java.lang.Exception
        Write the fUML runtime value to the excel file.
        Parameters:
        object - the fUML runtime value (ValueList/Value)
        fileName - the excel file name
        sheetName - the sheet name
        atRow - the row number to write the data
        isReplace - if true, it will replace the existing data if false, it will insert the data at atRow
        Throws:
        java.lang.Exception
      • writeObjectsToSpreadSheet

        public void writeObjectsToSpreadSheet​(java.lang.Object object,
                                              java.lang.String fileName,
                                              java.lang.Number atRow,
                                              boolean isReplace)
                                       throws java.lang.Exception
        Write the fUML runtime value to the excel file.
        Parameters:
        object - the fUML runtime value (ValueList/Value)
        fileName - the excel file name
        atRow - the row number to write the data
        isReplace - if true, it will replace the existing data if false, it will insert the data at atRow
        Throws:
        java.lang.Exception
      • writeObjectsToSpreadSheet

        public void writeObjectsToSpreadSheet​(java.lang.Object object,
                                              java.lang.String fileName,
                                              java.lang.String sheetName,
                                              java.lang.Number atRow,
                                              boolean isReplace,
                                              @CheckForNull
                                              java.lang.Object mappingClass)
                                       throws java.lang.Exception
        Write the fUML runtime value to the excel file.
        Parameters:
        object - the fUML runtime value (ValueList/Value)
        fileName - the excel file name
        sheetName - the sheet name
        atRow - the row number to write the data
        isReplace - if true, it will replace the existing data if false, it will insert the data at atRow
        mappingClass - the mapping class name String or mapping class Element
        Throws:
        java.lang.Exception