///------------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> формировать документ </summary> private void CreateDocument(List <Storage> tasks, string template) { Db DB = new Db(); var task2 = new List <Storage>(); arrAttributes = DB.GetAtributes(Obj); arrVersion = DB.GetVersion(Obj, 0); foreach (var item in tasks) { task2.Add(item); task2.AddRange(item.GetChild()); } System.Reflection.PropertyInfo[] array = typeof(Storage).GetProperties(); string[,] table = new string[task2.Count, array.Length]; for (int i = 0; i < task2.Count(); i++) { Storage storage = task2[i]; for (int j = 0; j < array.Length; j++) { System.Reflection.PropertyInfo item = array[j]; var res = item.GetValue(storage, null); if (res != null) { table[i, j] = res.ToString(); } } } Microsoft.Office.Interop.Excel.Application application = null; Microsoft.Office.Interop.Excel.Workbook xlsBook = null; switch (Path.GetExtension(template).ToLower()) { case ".xlt": case ".xltm": case ".xltx": application = new Microsoft.Office.Interop.Excel.Application(); xlsBook = application.Workbooks.Open(template); application.Visible = true; break; default: MessageBox.Show("Не распознан формат шаблона"); break; } if (application != null) { RunMacro(application, new Object[] { "StartMacrosLOODSMAN", // имя макроса task2.Count, array.Length, table, arrAttributes, arrAttributes.Length, arrVersion, "" /// template }); } }