Class ExcelHelper
- java.lang.Object
-
- com.nomagic.magicdraw.simulation.excelimport.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
-
-
Constructor Summary
Constructors Constructor Description ExcelHelper(SimulationSession session)
constructor.ExcelHelper(SimulationSession session, Element scriptContainer)
constructor.ExcelHelper(fUML.Semantics.Classes.Kernel.Object_ context)
constructor.
-
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.
-
-
-
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 namesheetName
- 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 namerowIndex
- 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 namerowIndex
- the index of rowmappingClass
- the mapping class nameString
or mapping classElement
- 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 namesheetName
- the sheet namerowIndex
- 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 namesheetName
- the sheet namerowIndex
- the index of rowmappingClass
- the mapping class nameString
or mapping classElement
- 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 namestartRow
- the start row numberendRow
- 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 namestartRow
- the start row numberendRow
- the end row numbermappingClass
- the mapping class nameString
or mapping classElement
- 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 namesheetName
- the sheet namestartRow
- the start row numberendRow
- 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 namemappingClass
- the mapping class nameString
or mapping classElement
- 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 namename
- 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 namesheetName
- the sheet namemappingClass
- the mapping class nameString
or mapping classElement
- 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 namesheetName
- the sheet namestartRow
- the start row numberendRow
- the end row numbermappingClass
- the mapping class nameString
or mapping classElement
- 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 namesheetName
- the sheet nameatRow
- the row index numberatCol
- 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 namesheetName
- the sheet nameatRow
- the row index numberatCol
- 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 objectfileName
- the spreadSheet file pathrowIndex
- 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 objectfileName
- the spreadSheet file pathsheetName
- the sheet namerowIndex
- 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 objectfileName
- the spreadSheet file pathrowIndex
- the row indexmappingClass
- the mapping class nameString
or mapping classElement
- 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 objectfileName
- the spreadSheet file pathsheetName
- the sheet namerowIndex
- the row indexmappingClass
- the mapping class nameString
or mapping classElement
- 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 nameatRow
- the row number to write the dataisReplace
- if true, it will replace the existing data if false, it will insert the data at atRowmappingClass
- the mapping class nameString
or mapping classElement
- 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 namesheetName
- the sheet nameatRow
- the row number to write the dataisReplace
- 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 nameatRow
- the row number to write the dataisReplace
- 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 namesheetName
- the sheet nameatRow
- the row number to write the dataisReplace
- if true, it will replace the existing data if false, it will insert the data at atRowmappingClass
- the mapping class nameString
or mapping classElement
- Throws:
java.lang.Exception
-
-