function export_report(filepath)
%[file,path]=uigetfile;
%filepath=[path file];
load(filepath,'report');
report_text=[];

fileID = fopen([filepath(1:end-3) 'csv'],'w');

for i=2:length(report.data)
    % шапка 1
    writeline=['F=;',num2str(report.data(i).N_sat),';R=;',num2str(report.data(i).R),'\n'];
    fprintf(fileID,writeline);
    % шапка 2
    writeline=['N;Date;H-He+;O2;E;E_temp;Limit(H-He+);Limit(O2);Limit(E);Limit(E_temp);\n'];
    fprintf(fileID,writeline);
    % данные
    for j=1:length(report.data(i).date)
        writeline=[num2str(j),';',report.data(i).date{j},';'];
        writeline=[writeline,num2str(report.data(i).RPA_HHeden(j)),';'];
        writeline=[writeline,num2str(report.data(i).RPA_O2den(j)),';'];
        writeline=[writeline,num2str(report.data(i).EP_Eden(j)),';'];
        writeline=[writeline,num2str(report.data(i).EP_Etemp(j)),';'];
        writeline=[writeline,num2str(report.data(i).RPA_HHeden_lim(j)),';'];
        writeline=[writeline,num2str(report.data(i).RPA_O2den_lim(j)),';'];
        writeline=[writeline,num2str(report.data(i).EP_Eden_lim(j)),';'];
        writeline=[writeline,num2str(report.data(i).EP_Etemp_lim(j)),'\n'];
        fprintf(fileID,writeline);
    end   
end
writeline=['Correlation\n'];
fprintf(fileID,writeline);
for i=1:length(report.corr_table)
    
    writeline=['R=;',num2str(report.corr_table(i).R),';H-He\n'];
    fprintf(fileID,writeline);
    temp=report.corr_table(i).RPA_HHeden;
    [a,b]=size(temp);    
    for j=1:a
        writeline=[];
        for k=1:b
            writeline=[writeline,temp{j,k},';'];
        end
        writeline=[writeline,'\n'];
        fprintf(fileID,writeline);
    end
    
    writeline=['R=;',num2str(report.corr_table(i).R),';O2\n'];
    fprintf(fileID,writeline);
    temp=report.corr_table(i).RPA_O2den;
    [a,b]=size(temp);
    for j=1:a
        writeline=[];
        for k=1:b
            writeline=[writeline,temp{j,k},';'];
        end
        writeline=[writeline,'\n'];
        fprintf(fileID,writeline);
    end
    
    writeline=['R=;',num2str(report.corr_table(i).R),';E\n'];
    fprintf(fileID,writeline);
    temp=report.corr_table(i).EP_Eden;
    [a,b]=size(temp);    
    for j=1:a
        writeline=[];
        for k=1:b
            writeline=[writeline,temp{j,k},';'];
        end
        writeline=[writeline,'\n'];
        fprintf(fileID,writeline);
    end
    
    writeline=['R=;',num2str(report.corr_table(i).R),';E_temp\n'];
    fprintf(fileID,writeline);
    temp=report.corr_table(i).EP_Etemp;
    [a,b]=size(temp);    
    for j=1:a
        writeline=[];
        for k=1:b
            writeline=[writeline,temp{j,k},';'];
        end
        writeline=[writeline,'\n'];
        fprintf(fileID,writeline);
    end
    
end
fclose(fileID);
end