//Ref: cfd-online.com/Forums/star-ccm/90846-automatically-export-all-reports-batch.html package macro; import java.util.*; import java.io.*; import java.nio.*; import star.common.*; import star.base.neo.*; import star.base.report.*; import star.flow.*; public class exportReportsToCsv extends StarMacro { BufferedWriter bwout = null; public void execute() { try { Simulation sim_1 = getActiveSimulation(); // Collecting the simualtion file name String simulationName = sim_1.getPresentationName(); sim_1.println("Simulation Name:" + simulationName); // Open Buffered Input and Output Readers // Create file with name " + _report.csv" bwout = new BufferedWriter(new FileWriter(resolvePath(simulationName +"_report.csv"))); bwout.write("Report Name, Value, Unit, \n"); Collection reportCollection = sim_1.getReportManager().getObjects(); for (Report thisReport : reportCollection){ String fieldLocationName = thisReport.getPresentationName(); Double fieldValue = thisReport.getReportMonitorValue(); String fieldUnits = thisReport.getUnits().toString(); // Print to output window sim_1.println("Field Location :" + fieldLocationName); sim_1.println(" Field Value :" + fieldValue); sim_1.println(" Field Units :" + fieldUnits); sim_1.println(""); // Write Output file as "sim file name" + _report.csv bwout.write(fieldLocationName + ", " +fieldValue + ", " + fieldUnits +"\n"); } bwout.close(); } catch (IOException err) { err.printStackTrace(); } } }