java.lang.Object
com.nomagic.magicdraw.simulation.excelimport.ExcelHelper

@OpenApiAll public class ExcelHelper extends Object
The helper class being used in the scripts for handling data transformation and other utilities between fUML runtime object and Excel file.
  • Constructor Details

    • 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 Details

    • getLatestRowNum

      public int getLatestRowNum(String fileName, 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

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet(String fileName, int rowIndex) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet(String fileName, Number rowIndex) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet(String fileName, int rowIndex, Object mappingClass) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet(String fileName, Number rowIndex, Object mappingClass) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet(String fileName, String sheetName, int rowIndex) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet(String fileName, String sheetName, Number rowIndex) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet(String fileName, String sheetName, int rowIndex, Object mappingClass) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectFromSpreadSheet(String fileName, String sheetName, Number rowIndex, Object mappingClass) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectsFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet(String fileName, int startRow, int endRow) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectsFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet(String fileName, Number startRow, Number endRow) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectsFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet(String fileName, Number startRow, Number endRow, Object mappingClass) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectsFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet(String fileName, String sheetName, int startRow, int endRow) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectsFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet(String fileName, String sheetName, Number startRow, Number endRow) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectsFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet(String fileName, Object mappingClass) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectsFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet(String fileName, String name) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectsFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet(String fileName, String sheetName, Object mappingClass) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectsFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet(String fileName, String sheetName, Number startRow, Number endRow, @CheckForNull Object mappingClass) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • readObjectsFromSpreadSheet

      @CheckForNull public fUML.Semantics.Classes.Kernel.ValueList readObjectsFromSpreadSheet(String fileName, String sheetName, int startRow, int endRow, @CheckForNull Object mappingClass) throws 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:
      Exception - could be thrown if problem occurs when reading excel data
    • setCellValue

      public void setCellValue(Object object, String fileName, String sheetName, int atRow, int 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
    • setCellValue

      public void setCellValue(Object object, String fileName, String sheetName, Number atRow, 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 Object getCellValue(String fileName, String sheetName, int atRow, int 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
    • getCellValue

      @CheckForNull public Object getCellValue(String fileName, String sheetName, Number atRow, 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, String fileName, int rowIndex) throws 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:
      Exception - exception
    • updatefUMLValueFromSpreadSheet

      public void updatefUMLValueFromSpreadSheet(fUML.Semantics.Classes.Kernel.StructuredValue value, String fileName, Number rowIndex) throws 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:
      Exception - exception
    • updatefUMLValueFromSpreadSheet

      public void updatefUMLValueFromSpreadSheet(fUML.Semantics.Classes.Kernel.StructuredValue value, String fileName, String sheetName, int rowIndex) throws 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:
      Exception - exception
    • updatefUMLValueFromSpreadSheet

      public void updatefUMLValueFromSpreadSheet(fUML.Semantics.Classes.Kernel.StructuredValue value, String fileName, String sheetName, Number rowIndex) throws 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:
      Exception - exception
    • updatefUMLValueFromSpreadSheet

      public void updatefUMLValueFromSpreadSheet(fUML.Semantics.Classes.Kernel.StructuredValue value, String fileName, int rowIndex, @CheckForNull Object mappingClass) throws 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:
      Exception - exception
    • updatefUMLValueFromSpreadSheet

      public void updatefUMLValueFromSpreadSheet(fUML.Semantics.Classes.Kernel.StructuredValue value, String fileName, Number rowIndex, @CheckForNull Object mappingClass) throws 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:
      Exception - exception
    • updatefUMLValueFromSpreadSheet

      public void updatefUMLValueFromSpreadSheet(fUML.Semantics.Classes.Kernel.StructuredValue value, String fileName, String sheetName, Number rowIndex, @CheckForNull Object mappingClass) throws 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:
      Exception - exception
    • updatefUMLValueFromSpreadSheet

      public void updatefUMLValueFromSpreadSheet(fUML.Semantics.Classes.Kernel.StructuredValue value, String fileName, String sheetName, int rowIndex, @CheckForNull Object mappingClass) throws 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:
      Exception - exception
    • writeObjectsToSpreadSheet

      public void writeObjectsToSpreadSheet(Object object, String fileName, int atRow, boolean isReplace, Object mappingClass) throws 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:
      Exception
    • writeObjectsToSpreadSheet

      public void writeObjectsToSpreadSheet(Object object, String fileName, Number atRow, boolean isReplace, Object mappingClass) throws 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:
      Exception
    • writeObjectsToSpreadSheet

      public void writeObjectsToSpreadSheet(Object object, String fileName, String sheetName, int atRow, boolean isReplace) throws 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:
      Exception
    • writeObjectsToSpreadSheet

      public void writeObjectsToSpreadSheet(Object object, String fileName, String sheetName, Number atRow, boolean isReplace) throws 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:
      Exception
    • writeObjectsToSpreadSheet

      public void writeObjectsToSpreadSheet(Object object, String fileName, int atRow, boolean isReplace) throws 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:
      Exception
    • writeObjectsToSpreadSheet

      public void writeObjectsToSpreadSheet(Object object, String fileName, Number atRow, boolean isReplace) throws 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:
      Exception
    • writeObjectsToSpreadSheet

      public void writeObjectsToSpreadSheet(Object object, String fileName, String sheetName, Number atRow, boolean isReplace, @CheckForNull Object mappingClass) throws 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:
      Exception
    • writeObjectsToSpreadSheet

      public void writeObjectsToSpreadSheet(Object object, String fileName, String sheetName, int atRow, boolean isReplace, @CheckForNull Object mappingClass) throws 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:
      Exception