public void Save_BnOplGroupInXLS(System.DateTime Date) { try { object obj2 = System.Reflection.Missing.Value; string str = ""; object obj3 = DALSql.ExecuteScalar("select val from kod_rep", null).ToString(); if (obj3.ToString() == "1") { str = "Порт"; } if (obj3.ToString() == "2") { str = "Соцгород"; } if (obj3.ToString() == "3") { str = "Центр"; } Application application = new ApplicationClass(); _Worksheet worksheet = (_Worksheet) application.Workbooks.Add(XlWBATemplate.xlWBATWorksheet).Worksheets.get_Item(1); application.set_Visible(true); worksheet.Columns.set_ColumnWidth(0x20); worksheet.get_Range("A1", obj2).set_Value2(str); worksheet.get_Range("A1", obj2).Font.set_Bold(true); worksheet.get_Range("C1", obj2).set_Value2("Г. ДИМИТРОВГРАД"); worksheet.get_Range("C1", obj2).Font.set_Bold(true); worksheet.get_Range("B3", obj2).set_Value2("КРАТКАЯ СПРАВКА по безналичному расчету"); worksheet.get_Range("B3", obj2).Font.set_Bold(true); worksheet.get_Range("B1", obj2).set_ColumnWidth(14); worksheet.get_Range("B4", obj2).set_Value2("за " + Date.ToString("MMMM yyyy")); worksheet.get_Range("B4", obj2).Font.set_Bold(true); worksheet.get_Range("A5", obj2).set_Value2("Наименование группы услуг"); worksheet.get_Range("A5", obj2).BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null); worksheet.get_Range("B5", obj2).set_Value2("Кол-во л/счетов"); worksheet.get_Range("B5", obj2).BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null); worksheet.get_Range("C5", obj2).set_Value2("Cумма для безналичного удержания"); worksheet.get_Range("C5", obj2).BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null); System.DateTime time = new System.DateTime(Date.get_Year(), Date.get_Month(), 1, 0, 0, 0, 0); System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@d_prd", System.Data.SqlDbType.DateTime) }; parameters[0].set_Value(time); System.Data.DataTable table = DALSql.ExecuteDataTable("\r\n select gr,count(*) ls,sum(summa) summa from bn \r\n where d_prd=@d_prd group by gr order by gr", parameters); int num = 0; System.Data.DataRow row = null; if (table.Rows.get_Count() > 0) { for (int i = 0; i < table.Rows.get_Count(); i = (int) (i + 1)) { row = table.Rows.get_Item(i); int num3 = (int) (6 + i); worksheet.get_Range("A" + ((int) num3).ToString(), obj2).set_Value2(row.get_Item("gr").ToString()); int num4 = (int) (6 + i); worksheet.get_Range("A" + ((int) num4).ToString(), obj2).BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null); int num5 = (int) (6 + i); worksheet.get_Range("B" + ((int) num5).ToString(), obj2).set_Value2(row.get_Item("ls").ToString()); int num6 = (int) (6 + i); worksheet.get_Range("B" + ((int) num6).ToString(), obj2).BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null); int num7 = (int) (6 + i); worksheet.get_Range("C" + ((int) num7).ToString(), obj2).EntireColumn.set_NumberFormatLocal("0,00"); int num8 = (int) (6 + i); worksheet.get_Range("C" + ((int) num8).ToString(), obj2).set_Value2(System.Convert.ToDecimal(row.get_Item("summa").ToString())); int num9 = (int) (6 + i); worksheet.get_Range("C" + ((int) num9).ToString(), obj2).BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null); num = i; } } int num10 = (int) (7 + num); worksheet.get_Range("A" + ((int) num10).ToString(), obj2).set_Value2("ИТОГО"); int num11 = (int) (7 + num); worksheet.get_Range("A" + ((int) num11).ToString(), obj2).Font.set_Bold(true); int num12 = (int) (7 + num); worksheet.get_Range("A" + ((int) num12).ToString(), obj2).BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null); int num13 = (int) (7 + num); worksheet.get_Range("B" + ((int) num13).ToString(), obj2).Select(); int num14 = (int) (7 + num); worksheet.get_Range("B" + ((int) num14).ToString(), obj2).BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null); int num15 = (int) (7 + num); worksheet.get_Range("B" + ((int) num15).ToString(), obj2).Font.set_Bold(true); int num16 = (int) (6 + num); application.ActiveCell.set_Formula("=СУММ(B6:B" + ((int) num16).ToString() + ")"); int num17 = (int) (7 + num); worksheet.get_Range("C" + ((int) num17).ToString(), obj2).Select(); int num18 = (int) (7 + num); worksheet.get_Range("C" + ((int) num18).ToString(), obj2).BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, null); int num19 = (int) (7 + num); worksheet.get_Range("C" + ((int) num19).ToString(), obj2).Font.set_Bold(true); int num20 = (int) (6 + num); application.ActiveCell.set_Formula("=СУММ(C6:C" + ((int) num20).ToString() + ")"); int num21 = (int) (9 + num); worksheet.get_Range("A" + ((int) num21).ToString(), obj2).set_Value2("Директор ДФ ООО \"РИЦ\""); int num22 = (int) (9 + num); worksheet.get_Range("A" + ((int) num22).ToString(), obj2).Font.set_Bold(true); int num23 = (int) (9 + num); worksheet.get_Range("C" + ((int) num23).ToString(), obj2).set_Value2("Малиновская Н Е"); int num24 = (int) (9 + num); worksheet.get_Range("C" + ((int) num24).ToString(), obj2).Font.set_Bold(true); } catch (System.Exception exception) { throw new System.ApplicationException("Произошла ошибка выгрузки", exception); } }