Search code examples
excelsimulationanylogic

AnyLogic - Excel output: delete spreadsheet before each simulation run?


After destroying my main agent I wrote a code ExcelFile.setCellValue(...) that puts parameters into an Excel.

My output function with excel works but only if I delete the whole workspace of each spreadsheet before every simulation run. Because I have a big number of sheets this is very exhausting. Is there a possibility to overwrite my output excel without deleting manually ever sheet after a simulation run? This would save me a ton of work.


Solution

  • I do it this way:

    //--Clearing the file------------------
    excelFileOutput.readFile();
    
    for (int m=1;m<6;m++){ //for each sheet
        for (int i=0;i<15;i++){      //for each column  
            for (int j=2;j<50000;j++){   //for each row 
                excelFileOutput.clearCell(m,j,i);   
        }       
                
    }
    }