private void отобразитьВExcelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExcelClass InformationAboutElements = new ExcelClass();

            Font HeadFont = new Font(" Times New Roman ", 12.0f, FontStyle.Bold);

            try
            {

                int CurrentCell=0;
                InformationAboutElements.NewDocument();

                InformationAboutElements.AddNewPageAtTheStart("Параметры элемента УСП");
                InformationAboutElements.SelectCells("A1", Type.Missing);
                InformationAboutElements.SetColumnWidth(20);
                InformationAboutElements.SetFont(HeadFont, 0);
                InformationAboutElements.SetBorderStyle(0, Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick);
                InformationAboutElements.WriteDataToCell("Параметр");
                InformationAboutElements.SelectCells("B1", Type.Missing);
                InformationAboutElements.SetColumnWidth(30);
                InformationAboutElements.SetFont(HeadFont, 0);
                InformationAboutElements.SetBorderStyle(0, Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick);
                InformationAboutElements.WriteDataToCell("Значение");

                for (int i = 0; i < DataInformTable.RowCount; i++)
                {
                    CurrentCell = i + 2;
                    InformationAboutElements.SelectCells(("A" + CurrentCell.ToString()), Type.Missing);
                    InformationAboutElements.WriteDataToCell(DataInformTable[0,i].Value.ToString());
                    InformationAboutElements.SetHorisontalAlignment(2);
                    InformationAboutElements.SetBorderStyle(0, Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick);

                    InformationAboutElements.SelectCells(("B" + CurrentCell.ToString()), Type.Missing);
                    InformationAboutElements.WriteDataToCell(DataInformTable[1, i].Value.ToString());
                    InformationAboutElements.SetHorisontalAlignment(2);
                    InformationAboutElements.SetBorderStyle(0, Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,"Error");

            }
            finally {

                InformationAboutElements.Visible = true;
                InformationAboutElements.Dispose();
                HeadFont.Dispose();

            }
        }
        /// <summary>
        /// Выгрузка данных в Excel;
        /// </summary>        
        /// <returns></returns>   
        private void вExcelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExcelClass InformationAboutElements = new ExcelClass();

            HashCode.HashCode.CheckFileByHash("акт на списание.xlt");

            if (System.IO.File.Exists(Program.PathString + "\\" + "акт на списание.xlt"))
            {
                try
                {
                    HashCode.HashCode.CheckFileByHash("акт на списание.xlt");

                    InformationAboutElements.OpenDocument(Program.PathString + "\\акт на списание.xlt");
                    InformationAboutElements.Visible = false;
                    //Акт №
                    InformationAboutElements.SelectCells("J8", Type.Missing);
                    InformationAboutElements.WriteDataToCell(J8.Text.ToString());
                    //Должность оформляющего
                    InformationAboutElements.SelectCells("U4", Type.Missing);
                    InformationAboutElements.WriteDataToCell(U4.Text.ToString());
                    //Расшифровка подписи оформляющего
                    InformationAboutElements.SelectCells("U6", Type.Missing);
                    InformationAboutElements.WriteDataToCell(U6.Text.ToString());
                    //Организация
                    InformationAboutElements.SelectCells("D12", Type.Missing);
                    InformationAboutElements.WriteDataToCell(D12.Text.ToString());
                    //Структурное подразделение
                    InformationAboutElements.SelectCells("F14", Type.Missing);
                    InformationAboutElements.WriteDataToCell(F14.Text.ToString());

                    // Дата приказа
                    InformationAboutElements.SelectCells("J26", Type.Missing);
                    InformationAboutElements.WriteDataToCell(J26.Text.ToString());
                    // Год осмотра предметов
                    InformationAboutElements.SelectCells("S26", Type.Missing);
                    InformationAboutElements.WriteDataToCell(S26.Text.ToString());
                    // Форма по ОКПО
                    InformationAboutElements.SelectCells("Z10", Type.Missing);
                    InformationAboutElements.WriteDataToCell(Z10.Text.ToString());

                    //Общее количество предметов
                    InformationAboutElements.SelectCells("F86", Type.Missing);
                    InformationAboutElements.WriteDataToCell(F86.Text.ToString());

                    //Номера и акты выбытия
                    InformationAboutElements.SelectCells("F89", Type.Missing);
                    InformationAboutElements.WriteDataToCell(F89.Text.ToString());

                    //Утиль
                    InformationAboutElements.SelectCells("F112", Type.Missing);
                    InformationAboutElements.WriteDataToCell(((System.Windows.Forms.TextBox)(this.tabPage2.Controls.Find("F112", true)[0])).Text.ToString());

                    //Панели
                    for (int i = 0; i < 6; i++)
                    {
                        for (int j = 0; j < ((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panel" + i.ToString()), true)[0])).Controls.Count; j++)
                        {

                            InformationAboutElements.SelectCells(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panel" + i.ToString()), true)[0])).Controls[j].Name.ToString(), Type.Missing);
                            InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panel" + i.ToString()), true)[0])).Controls[j].Text.ToString());
                        }
                    }

                    for (int i = 7; i < 16; i++)
                    {
                        for (int j = 0; j < ((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panel" + i.ToString()), true)[0])).Controls.Count; j++)
                        {

                            InformationAboutElements.SelectCells(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panel" + i.ToString()), true)[0])).Controls[j].Name.ToString(), Type.Missing);
                            InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panel" + i.ToString()), true)[0])).Controls[j].Text.ToString());
                        }
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error");

                }
                finally
                {

                    InformationAboutElements.Visible = true;
                    InformationAboutElements.Dispose();

                }
            }
        }
        private void показатьВExcelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExcelClass InformationAboutElements = new ExcelClass();

            Font HeadFont = new Font(" Times New Roman ", 12.0f, FontStyle.Bold);

            try
            {

                string currentName = "";
                int countCell = 2;
                InformationAboutElements.NewDocument();

                InformationAboutElements.AddNewPageAtTheStart("Параметры элемента УСП");
                InformationAboutElements.SelectCells("A1", Type.Missing);
                InformationAboutElements.SetColumnWidth(20);
                InformationAboutElements.SetFont(HeadFont, 0);
                InformationAboutElements.SetBorderStyle(0, Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick);
                InformationAboutElements.WriteDataToCell("Параметр");
                InformationAboutElements.SelectCells("B1", Type.Missing);
                InformationAboutElements.SetColumnWidth(30);
                InformationAboutElements.SetFont(HeadFont, 0);
                InformationAboutElements.SetBorderStyle(0, Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick);
                InformationAboutElements.WriteDataToCell("Значение");

                for (int i = 1; i < 28; i++)
                {
                    for (int j = 0; j < this.panel1.Controls.Count; j++)
                    {
                        if ((String.Compare(this.panel1.Controls[j].Tag.ToString(), i.ToString()) == 0))
                        {
                            if ((String.Compare(this.panel1.Controls[j].Text, "") != 0)&&(String.Compare(this.panel1.Controls[j].Text, "0") != 0))
                            {

                                currentName = ((System.Windows.Forms.Label)(this.Controls.Find(("label" + i.ToString()), true)[0])).Text;

                                InformationAboutElements.SelectCells((string)(("B" + countCell.ToString())), Type.Missing);
                                InformationAboutElements.WriteDataToCell(this.panel1.Controls[j].Text);
                                InformationAboutElements.SetHorisontalAlignment(2);
                                InformationAboutElements.SetBorderStyle(0, Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick);

                                InformationAboutElements.SelectCells((string)(("A" + countCell.ToString())), Type.Missing);
                                InformationAboutElements.WriteDataToCell(currentName);
                                InformationAboutElements.SetHorisontalAlignment(2);
                                InformationAboutElements.SetBorderStyle(0, Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick);

                                countCell++;

                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");

            }
            finally
            {

                InformationAboutElements.Visible = true;
                InformationAboutElements.Dispose();
                HeadFont.Dispose();

            }
        }
        private void вExcelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExcelClass InformationAboutElements = new ExcelClass();

            HashCode.HashCode.CheckFileByHash("требование-накладная.xlt");

            if (System.IO.File.Exists(Program.PathString + "\\требование-накладная.xlt"))
            {

                try
                {

                    int TagOfObject = 0;
                    InformationAboutElements.OpenDocument(Program.PathString + "\\требование-накладная.xlt");
                    InformationAboutElements.Visible = false;
                    //перевод данных в Excel
                    //органзация
                    InformationAboutElements.SelectCells("D8", Type.Missing);
                    InformationAboutElements.WriteDataToCell(textBox1.Text.ToString());
                    //номер требование накладной
                    InformationAboutElements.SelectCells("C19", Type.Missing);
                    InformationAboutElements.WriteDataToCell(PanelN1OneA.Text.ToString());
                    //Дата составления
                    InformationAboutElements.SelectCells("F19", Type.Missing);
                    InformationAboutElements.WriteDataToCell(PanelN1One.Text.ToString());
                    //Код вида операций
                    InformationAboutElements.SelectCells("I19", Type.Missing);
                    InformationAboutElements.WriteDataToCell(PanelN1two.Text.ToString());
                    //структурное подразделение
                    InformationAboutElements.SelectCells("K19", Type.Missing);
                    InformationAboutElements.WriteDataToCell(PanelN1three.Text.ToString());
                    //вид деятельности
                    InformationAboutElements.SelectCells("N19", Type.Missing);
                    InformationAboutElements.WriteDataToCell(PanelN1four.Text.ToString());
                    //шифр получателя
                    InformationAboutElements.SelectCells("Q19", Type.Missing);
                    InformationAboutElements.WriteDataToCell(PanelN1five.Text.ToString());
                    //шифр потребителя
                    InformationAboutElements.SelectCells("S19", Type.Missing);
                    InformationAboutElements.WriteDataToCell(PanelN1FiveA.Text.ToString());
                    //вид деятельности
                    InformationAboutElements.SelectCells("U19", Type.Missing);
                    InformationAboutElements.WriteDataToCell(PanelN1Six.Text.ToString());
                    //Учетная ед. выпуска продукции (работ. услуг)
                    InformationAboutElements.SelectCells("X19", Type.Missing);
                    InformationAboutElements.WriteDataToCell(PanelN1Seven.Text.ToString());
                    //Порядковый но-мер, по склад. картотеке
                    InformationAboutElements.SelectCells("AA19", Type.Missing);
                    InformationAboutElements.WriteDataToCell(PanelN1sevenA.Text.ToString());
                    //Через кого
                    InformationAboutElements.SelectCells("C23", Type.Missing);
                    InformationAboutElements.WriteDataToCell(textBox2.Text.ToString());
                    //Затребовал
                    InformationAboutElements.SelectCells("C25", Type.Missing);
                    InformationAboutElements.WriteDataToCell(textBox3.Text.ToString());
                    //Разрешил
                    InformationAboutElements.SelectCells("W25", Type.Missing);
                    InformationAboutElements.WriteDataToCell(textBox4.Text.ToString());
                    //Отпустил дата
                    InformationAboutElements.SelectCells("C111", Type.Missing);
                    InformationAboutElements.WriteDataToCell(dateTimePicker1.Text.ToString());
                    //Отпустил фамилия
                    InformationAboutElements.SelectCells("H111", Type.Missing);
                    InformationAboutElements.WriteDataToCell(textBox245.Text.ToString());
                    //Получил фамилия
                    InformationAboutElements.SelectCells("V111", Type.Missing);
                    InformationAboutElements.WriteDataToCell(textBox246.Text.ToString());
                    //Получил дата
                    InformationAboutElements.SelectCells("R111", Type.Missing);
                    InformationAboutElements.WriteDataToCell(dateTimePicker2.Text.ToString());

                    for (int i = 0; i < 5; i++)
                        for (int j = 0; j < ((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls.Count; j++)
                        {

                            TagOfObject = (Convert.ToInt32(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Tag));

                            if (TagOfObject == 0)
                            {
                                //Корресп. Счет, суб-счет, код аналит. Учета
                                InformationAboutElements.SelectCells("A" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 1)
                            {
                                //Материальные ценности наименование (9)
                                InformationAboutElements.SelectCells("C" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 2)
                            {
                                //код материала
                                InformationAboutElements.SelectCells("C" + (i * 4 + 38).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 3)
                            {
                                //заводской номер
                                InformationAboutElements.SelectCells("F" + (i * 4 + 38).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 4)
                            {
                                //Ед. изм. Наимен. Код
                                InformationAboutElements.SelectCells("I" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 5)
                            {
                                //Ед. изм. Наимен. Код
                                InformationAboutElements.SelectCells("I" + (i * 4 + 38).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 6)
                            {
                                //затребовано
                                InformationAboutElements.SelectCells("K" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 7)
                            {
                                //отпущено
                                InformationAboutElements.SelectCells("M" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 8)
                            {
                                //Цена (руб., коп.)
                                InformationAboutElements.SelectCells("O" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 9)
                            {
                                //Сумма без расчета НДС, руб. коп.
                                InformationAboutElements.SelectCells("Q" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 10)
                            {
                                //Корреспон. счет, суб-счет, код аналит. учета
                                InformationAboutElements.SelectCells("S" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 11)
                            {
                                //Обесп. Серийн. № машины
                                InformationAboutElements.SelectCells("U" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 12)
                            {
                                //Некомп-плектный остаток
                                InformationAboutElements.SelectCells("W" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 13)
                            {
                                //Код издел. ШР, БЛ, № с/з
                                InformationAboutElements.SelectCells("Y" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 14)
                            {
                                //Признак раздела
                                InformationAboutElements.SelectCells("AA" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 15)
                            {
                                //Код основ. Матер.
                                InformationAboutElements.SelectCells("AC" + (i * 4 + 36).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage1.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                        }

                    for (int i = 5; i < 16; i++)
                        for (int j = 0; j < ((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls.Count; j++)
                        {

                            TagOfObject = (Convert.ToInt32(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Tag));

                            if (TagOfObject == 0)
                            {
                                //Корресп. Счет, суб-счет, код аналит. Учета
                                InformationAboutElements.SelectCells("A" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 1)
                            {
                                //Материальные ценности наименование (9)
                                InformationAboutElements.SelectCells("C" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 2)
                            {
                                //код материала
                                InformationAboutElements.SelectCells("C" + ((i - 5) * 4 + 67).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 3)
                            {
                                //заводской номер
                                InformationAboutElements.SelectCells("F" + ((i - 5) * 4 + 67).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 4)
                            {
                                //Ед. изм. Наимен. Код
                                InformationAboutElements.SelectCells("I" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 5)
                            {
                                //Ед. изм. Наимен. Код
                                InformationAboutElements.SelectCells("I" + ((i - 5) * 4 + 67).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 6)
                            {
                                //затребовано
                                InformationAboutElements.SelectCells("K" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 7)
                            {
                                //отпущено
                                InformationAboutElements.SelectCells("M" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());

                            }
                            else if (TagOfObject == 8)
                            {
                                //Цена (руб., коп.)
                                InformationAboutElements.SelectCells("O" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 9)
                            {
                                //Сумма без расчета НДС, руб. коп.
                                InformationAboutElements.SelectCells("Q" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 10)
                            {
                                //Корреспон. счет, суб-счет, код аналит. учета
                                InformationAboutElements.SelectCells("S" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 11)
                            {
                                //Обесп. Серийн. № машины
                                InformationAboutElements.SelectCells("U" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 12)
                            {
                                //Некомп-плектный остаток
                                InformationAboutElements.SelectCells("W" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 13)
                            {
                                //Код издел. ШР, БЛ, № с/з
                                InformationAboutElements.SelectCells("Y" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 14)
                            {
                                //Признак раздела
                                InformationAboutElements.SelectCells("AA" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                            else if (TagOfObject == 15)
                            {
                                //Код основ. Матер.
                                InformationAboutElements.SelectCells("AC" + ((i - 5) * 4 + 65).ToString(), Type.Missing);
                                InformationAboutElements.WriteDataToCell(((System.Windows.Forms.Panel)(this.tabPage2.Controls.Find(("panelN" + (i + 2).ToString()), true)[0])).Controls[j].Text.ToString());
                            }
                        }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error");

                }
                finally
                {

                    InformationAboutElements.Visible = true;
                    InformationAboutElements.Dispose();

                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Выгрузка данных в Excel;
        /// </summary>        
        /// <returns></returns> 
        public void createXLS()
        {
            ExcelClass TZExcel = new ExcelClass();

            HashCode.HashCode.CheckFileByHash("техническое задание.xlt");

            if (System.IO.File.Exists(Program.PathString + "\\техническое задание.xlt"))
            {

                try
                {
                    TZExcel.OpenDocument(Program.PathString + "\\техническое задание.xlt");
                    TZExcel.Visible = false;

                    if ((BMPIsLoad == 1) || (BMPIsLoad == 3))
                    {
                        if (this.SCETCH1.Image != null)
                        {
                            using (TemporaryFile tempFile = new TemporaryFile())
                            {
                                this.SCETCH1.Image.Save(tempFile.FilePath.ToString(), System.Drawing.Imaging.ImageFormat.Bmp);

                                TZExcel.SelectCells(this.SCETCH1.Name, Type.Missing);

                                TZExcel.WritePictureToCell(tempFile.FilePath.ToString());

                            }

                        }

                    }
                    else if ((BMPIsLoad == 0) || (BMPIsLoad == 2))
                    {

                        if (this.SCETCH1.Image != null)
                        {
                            TZExcel.SelectCells(this.SCETCH1.Name, Type.Missing);

                            TZExcel.WritePictureToCell(SQLOracle.LoadImageToTemp("Select SCETCH1 FROM USP_TZ_DATA WHERE ID_DOC = '" + number + "'"));

                        }
                    }

                    if ((BMPIsLoad == 2) || (BMPIsLoad == 3))
                    {
                        if (this.SCETCH2.Image != null)
                        {
                            using (TemporaryFile tempFile = new TemporaryFile())
                            {
                                this.SCETCH2.Image.Save(tempFile.FilePath.ToString(), System.Drawing.Imaging.ImageFormat.Bmp);

                                TZExcel.SelectCells(this.SCETCH2.Name, Type.Missing);

                                TZExcel.WritePictureToCell(tempFile.FilePath.ToString());

                            }

                        }

                    }
                    else if ((BMPIsLoad == 0) || (BMPIsLoad == 1))
                    {

                        if (this.SCETCH2.Image != null)
                        {
                            TZExcel.SelectCells(this.SCETCH2.Name, Type.Missing);

                            TZExcel.WritePictureToCell(SQLOracle.LoadImageToTemp("Select SCETCH2 FROM USP_TZ_DATA WHERE ID_DOC = '" + number + "'"));

                        }
                    }

                    for (int i = 0; i < this.tabPage1.Controls.Count; i++)
                    {

                        if (this.tabPage1.Controls[i].Controls.Count == 0)
                        {

                            if ((this.tabPage1.Controls[i].GetType() == typeof(DateTimePicker)) || (this.tabPage1.Controls[i].GetType() == typeof(TextBox)) || (this.tabPage1.Controls[i].GetType() == typeof(ComboBox)))
                            {
                                TZExcel.SelectCells(this.tabPage1.Controls[i].Name, Type.Missing);
                                TZExcel.WriteDataToCell(this.tabPage1.Controls[i].Text.ToString());
                            }

                        }
                        else if (this.tabPage1.Controls[i].Controls.Count > 0)
                        {
                            ExcelExport(this.tabPage1.Controls[i], ref TZExcel);
                        }
                    }

                    for (int i = 0; i < this.tabPage2.Controls.Count; i++)
                    {
                        if (this.tabPage2.Controls[i].Controls.Count == 0)
                        {

                            if ((this.tabPage2.Controls[i].GetType() == typeof(DateTimePicker)) || (this.tabPage2.Controls[i].GetType() == typeof(TextBox)) || (this.tabPage2.Controls[i].GetType() == typeof(ComboBox)))
                            {
                                TZExcel.SelectCells(this.tabPage2.Controls[i].Name, Type.Missing);
                                TZExcel.WriteDataToCell(this.tabPage2.Controls[i].Text.ToString());
                            }

                        }
                        else if (this.tabPage2.Controls[i].Controls.Count > 0)
                        {
                            ExcelExport(this.tabPage2.Controls[i], ref TZExcel);
                        }
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error");

                }
                finally
                {
                    TZExcel.Visible = true;
                    TZExcel.Dispose();
                }
            }
        }
Exemple #6
0
        private void ExcelExport(System.Windows.Forms.Control control,ref ExcelClass TZExcel)
        {
            for (int i = 0; i < control.Controls.Count; i++)
            {
                if (control.Controls[i].Controls.Count == 0)
                {

                    if ((control.Controls[i].GetType() == typeof(DateTimePicker)) || (control.Controls[i].GetType() == typeof(TextBox)) || (control.Controls[i].GetType() == typeof(ComboBox)))
                    {
                        TZExcel.SelectCells(control.Controls[i].Name, Type.Missing);
                        TZExcel.WriteDataToCell(control.Controls[i].Text.ToString());
                    }

                }
                else if (control.Controls[i].Controls.Count > 0)
                {
                    ExcelExport(control.Controls[i],ref TZExcel);
                }

            }
        }
        void ExportDGVToExcel(DataGridView dgv)
        {
            ExcelClass InformationAboutElements = new ExcelClass();

            Font HeadFont = new Font(" Times New Roman ", 12.0f, FontStyle.Bold);

            int iterator = 0;

            try
            {
                char[] alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
                int CurrentCell = 0;
                InformationAboutElements.NewDocument();
                InformationAboutElements.AddNewPageAtTheStart("Данные");

                for (int i = 0; i < dgv.Columns.Count; i++)
                {
                    if (dgv.Columns[i].Visible == true)
                    {

                        InformationAboutElements.SelectCells(alpha[iterator] + (1).ToString(), Type.Missing);
                        InformationAboutElements.SetFont(HeadFont, 0);
                        InformationAboutElements.SetBorderStyle(0, Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin);

                        InformationAboutElements.WriteDataToCell(dgv.Columns[i].HeaderText);

                        for (int j = 0; j < dgv.Rows.Count; j++)
                        {

                            InformationAboutElements.SelectCells(alpha[iterator] + (j + 2).ToString(), Type.Missing);
                            InformationAboutElements.SetFont(HeadFont, 0);
                            InformationAboutElements.SetBorderStyle(0, Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin);
                            InformationAboutElements.setAutoFit(alpha[iterator] + (j + 2).ToString());
                            InformationAboutElements.WriteDataToCell(dgv[i, j].Value.ToString());
                        }

                        if (dgv[i, 0].Value.ToString().Length > dgv.Columns[i].HeaderText.Length)
                        {
                            InformationAboutElements.setAutoFit(alpha[iterator] + (2).ToString());
                        }
                        else
                        {
                            InformationAboutElements.setAutoFit(alpha[iterator] + (1).ToString());
                        }

                        iterator++;
                    }

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");

            }
            finally
            {

                InformationAboutElements.Visible = true;
                InformationAboutElements.Dispose();
                HeadFont.Dispose();

            }
        }