There are two main options for getting data out of your simulation
- Using the internal AnyLogic database
- Using external files like Excel or txt
Step 1: Setup your objects
- Internal Database
Create an empty table with the columns you require

- External object
Setup either an Excel or text file using the objects provided by AnyLogic in the Connectivity palette

Step 2: Saving your data
For both cases you need to write your data to the object of your choosing, either as the data gets generated or at the end of the simulation model
- using Internal DB
The best option is to write data using the following command
insertInto(table_name)
.columns(column_name)
.values(value);
This will just insert a new line into a database table that you created, you can save multiple values to multiple columns by adding comma-separated entries into the parameters for columns and values.
e.g
insertInto(temeprature_output_table)
.columns(scenario_name, time, temperature)
.values("sceanrio1", 10,5, 102);
- External files
2.1) Using Excel
filename.setCellValue(value, sheetName, row, column);
or even better you can write out an entire dataset
excelFile.writeDataSet(dataset, sheetName, row, column);
2.2) Using a text file
fileName.println("value" + "\t" + " value 2");
You can use whatever separator you want "\t"
for tab separated or ","
for comma and so on
Step 3: Finish and export data
- Internal Database
At the end of a simulation run, you can simply export the data

See help here https://anylogic.help/anylogic/connectivity/export-excel.html#exporting-data-to-ms-excel-workbook
P.S. It is possible to automate this with some effort
- External file
On Excel you need to call .writeFile()
to finish.
On both objects, you need to call .close()
for them to be closed and saved to memory.
FYI
Excel has the option to save on termination.

Read more on using Excel here - https://anylogic.help/anylogic/connectivity/excel-file.html#writing-to-excel-file
And on text file here
https://anylogic.help/anylogic/connectivity/text-file.html#replicated
There is also an example model
