Search code examples
anylogic

How can i alter between database sheets in anylogic?


// Assuming you have an array or list of sheet names (e.g., sheetNames)
String[] sheetNames = {"sheet1", "sheet2", "sheet3", "sheet4", "sheet5", "sheet6", "sheet7", "sheet8", "sheet9", "sheet10", "sheet11", "sheet12", "sheet13", "sheet14", "sheet15", "sheet16", "sheet17", "sheet18", "sheet19", "sheet20" /* ... add more sheet names ... */};
int i = 0; // Initialize the index

// Loop through the sheets
while (i < sheetNames.length) {
    String currentSheetName = sheetNames[i];
    
    if (selectFrom(currentSheetName).offset(index).limit(1).firstResult(currentSheetName.takte) != "") {
        Takte = (double) selectFrom(currentSheetName).offset(index).limit(1).firstResult(currentSheetName.takte);
    }
    
    i++; // Move to the next sheet
}

I am trying to alter between 20 sheets but this approach is not allowing me to use String format as database names.


Solution

  • This is typically not possible (and not desired). There is a way but it is quite advanced Java and really not useful.

    If you have data across 20 sheets, it is likely very similar. Put it into 1 dbase table (and start to apply good dbase practices, not xls practices).