public static XtraReport CreateQueryReport(QueryMunicipalitySummaryModel model)
 {
     var municipalities = model.MunicipalityList;
     var queries = model.QueryList;
     var year = model.Year;
     var form = model.Form;
     var reportDataList = new QueryReportDataCollection();
     using (var spreadsheetControl = new SpreadsheetControl() { AllowDrop = false })
     {
         foreach (var munit in municipalities)
         {
             var formData = munit.municipality_form_data.FirstOrDefault(t => t.form == form && t.send_date.Year == year);
             if (formData != null)
             {
                 var excelData = formData.file.contents;
                 var format = formData.document_format.IsOpenXml()
                     ? DocumentFormat.OpenXml
                     : DocumentFormat.Xls;
                 spreadsheetControl.LoadDocument(excelData, format);
             }
             foreach (var query in queries)
             {
                 var stringValue = "";
                 try
                 {
                     var content = query.content;
                     if (content.StartsWith("@"))
                     {
                         var propName = content.Substring(1);
                         var propInfo = typeof(municipality).GetProperty(propName);
                         var value = propInfo.GetValue(munit);
                         var valueType = value.GetType();
                         if (valueType.GetInterface("System.Collections.IEnumerable") != null && valueType != typeof(String))
                         {
                             var collection = (IEnumerable<object>)value;
                             stringValue = collection.Join(", ");
                         }
                         else if (valueType == typeof(bool))
                         {
                             stringValue = (bool)value ? "Да" : "Нет";
                         }
                         else
                         {
                             stringValue = value.ToString();
                         }
                     }
                     else
                     {
                         var value = spreadsheetControl.Document.Range[content].Value;
                         stringValue = GetStringValueFromCell(value);
                     }
                 }
                 catch (Exception ex)
                 {
                     stringValue = "Не удалось";
                 }
                 reportDataList.Add(new QueryReportMunicipalityData(munit, query, stringValue));
             }
         }
     }
     var groupedList = reportDataList.Group().ToList();
     var report = new QueryReport { ReportData = groupedList };
     Reports.Add(report);
     return report;
 }
 public static Task<XtraReport> CreateQueryReportAsync(QueryMunicipalitySummaryModel model)
 {
     return Task.Run(() => CreateQueryReport(model));
 }