コード例 #1
0
        private void executeToExcel(Record record)
        {
            string path = Application.StartupPath + ConfigurationManager.AppSettings["excelPath"].ToString();

            File.Copy(path, Application.StartupPath + @"\test.xlsx", true);
            ExcelEdit excelOperator = new ExcelEdit();

            excelOperator.Open(Application.StartupPath + @"\test.xlsx");
            Microsoft.Office.Interop.Excel.Worksheet sheet1 = excelOperator.GetSheet("Sheet1");
            sheet1.Cells[4, 5].Value = record.Operator;
            sheet1.Cells[4, 8].Value = record.CreateTime.ToString("yyyy-MM-dd");
            sheet1.Cells[6, 2].Value = record.SeriesNum;
            sheet1.Cells[6, 5].Value = record.ProName;
            sheet1.Cells[6, 8].Value = record.Result == 1 ? "合格" : "不合格";
            for (int i = 0; i < record.RecordDetailList.Count; i++)
            {
                sheet1.Cells[i + 11, 2].Value = record.RecordDetailList[i].Index;
                sheet1.Cells[i + 11, 3].Value = record.RecordDetailList[i].TestValue + " N·m";
                sheet1.Cells[i + 11, 4].Value = record.RecordDetailList[i].Standard + " N·m";
                sheet1.Cells[i + 11, 5].Value = record.RecordDetailList[i].Difference;
                sheet1.Cells[i + 11, 6].Value = record.RecordDetailList[i].Percent + "%";
                sheet1.Cells[i + 11, 7].Value = record.Result == 1 ? "合格" : "不合格";
                sheet1.Cells[i + 11, 8].Value = record.RecordDetailList[i].Upper + " N·m";
                sheet1.Cells[i + 11, 9].Value = record.RecordDetailList[i].Lower + " N·m";
            }
            if (ConfigurationManager.AppSettings["printMode"].ToString().Equals("preview"))
            {
                sheet1.PrintPreview();
            }
            else if (ConfigurationManager.AppSettings["printMode"].ToString().Equals("print"))
            {
                sheet1.PrintOutEx();
            }

            excelOperator.Save();
            excelOperator.Close();
            GC.Collect();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            onay = MessageBox.Show("Onaylıyor musunuz?", "Onay", MessageBoxButtons.YesNo);
            if (onay == DialogResult.Yes)
            {
                try
                {
                    Microsoft.Office.Interop.Excel.Application objExcel = new Microsoft.Office.Interop.Excel.Application();
                    objExcel.Visible = true;
                    Microsoft.Office.Interop.Excel.Workbook  objBook  = objExcel.Workbooks.Open("c:\\toplutasima.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                    Microsoft.Office.Interop.Excel.Worksheet objSheet = (Microsoft.Office.Interop.Excel.Worksheet)objBook.Worksheets.get_Item(1);
                    Microsoft.Office.Interop.Excel.Range     objRange;

                    objRange = objSheet.get_Range("A12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox1.Text);
                    objRange = objSheet.get_Range("B12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox2.Text);
                    objRange = objSheet.get_Range("E12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox3.Text);
                    objRange = objSheet.get_Range("H12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox4.Text);
                    objRange = objSheet.get_Range("J12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox5.Text);
                    objRange = objSheet.get_Range("K12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox6.Text);
                    objRange = objSheet.get_Range("P12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox7.Text);
                    objRange = objSheet.get_Range("Q12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox8.Text);
                    objRange = objSheet.get_Range("R12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox9.Text);
                    objRange = objSheet.get_Range("S12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox10.Text);


                    objRange = objSheet.get_Range("R2", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox11.Text);
                    objRange = objSheet.get_Range("R3", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, dateTimePicker1.Text);
                    objRange = objSheet.get_Range("R4", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, dateTimePicker2.Text);
                    objRange = objSheet.get_Range("R5", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox12.Text);
                    objRange = objSheet.get_Range("R6", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox23.Text);
                    objRange = objSheet.get_Range("R7", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox45.Text);
                    objRange = objSheet.get_Range("R8", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox34.Text);



                    objRange = objSheet.get_Range("A14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox22.Text);
                    objRange = objSheet.get_Range("B14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox21.Text);
                    objRange = objSheet.get_Range("E14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox20.Text);
                    objRange = objSheet.get_Range("H14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox19.Text);
                    objRange = objSheet.get_Range("J14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox18.Text);
                    objRange = objSheet.get_Range("K14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox17.Text);
                    objRange = objSheet.get_Range("P14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox16.Text);
                    objRange = objSheet.get_Range("Q14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox15.Text);
                    objRange = objSheet.get_Range("R14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox14.Text);
                    objRange = objSheet.get_Range("S14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox13.Text);


                    objRange = objSheet.get_Range("A16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox33.Text);
                    objRange = objSheet.get_Range("B16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox32.Text);
                    objRange = objSheet.get_Range("E16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox31.Text);
                    objRange = objSheet.get_Range("H16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox30.Text);
                    objRange = objSheet.get_Range("J16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox29.Text);
                    objRange = objSheet.get_Range("K16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox28.Text);
                    objRange = objSheet.get_Range("P16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox27.Text);
                    objRange = objSheet.get_Range("Q16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox26.Text);
                    objRange = objSheet.get_Range("R16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox25.Text);
                    objRange = objSheet.get_Range("S16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox24.Text);


                    objRange = objSheet.get_Range("A18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox44.Text);
                    objRange = objSheet.get_Range("B18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox43.Text);
                    objRange = objSheet.get_Range("E18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox42.Text);
                    objRange = objSheet.get_Range("H18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox41.Text);
                    objRange = objSheet.get_Range("J18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox40.Text);
                    objRange = objSheet.get_Range("K18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox39.Text);
                    objRange = objSheet.get_Range("P18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox38.Text);
                    objRange = objSheet.get_Range("Q18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox37.Text);
                    objRange = objSheet.get_Range("R18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox36.Text);
                    objRange = objSheet.get_Range("S18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox35.Text);


                    objRange = objSheet.get_Range("A20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox55.Text);
                    objRange = objSheet.get_Range("B20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox54.Text);
                    objRange = objSheet.get_Range("E20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox53.Text);
                    objRange = objSheet.get_Range("H20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox52.Text);
                    objRange = objSheet.get_Range("J20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox51.Text);
                    objRange = objSheet.get_Range("K20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox50.Text);
                    objRange = objSheet.get_Range("P20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox49.Text);
                    objRange = objSheet.get_Range("Q20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox48.Text);
                    objRange = objSheet.get_Range("R20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox47.Text);
                    objRange = objSheet.get_Range("S20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox46.Text);


                    objRange = objSheet.get_Range("A22", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox66.Text);
                    objRange = objSheet.get_Range("B22", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox65.Text);
                    objRange = objSheet.get_Range("E22", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox64.Text);
                    objRange = objSheet.get_Range("H22", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox63.Text);
                    objRange = objSheet.get_Range("J22", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox62.Text);
                    objRange = objSheet.get_Range("K22", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox61.Text);
                    objRange = objSheet.get_Range("P22", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox60.Text);
                    objRange = objSheet.get_Range("Q22", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox59.Text);
                    objRange = objSheet.get_Range("R22", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox58.Text);
                    objRange = objSheet.get_Range("S22", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox57.Text);


                    objRange = objSheet.get_Range("A24", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox77.Text);
                    objRange = objSheet.get_Range("B24", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox76.Text);
                    objRange = objSheet.get_Range("E24", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox75.Text);
                    objRange = objSheet.get_Range("H24", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox74.Text);
                    objRange = objSheet.get_Range("J24", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox73.Text);
                    objRange = objSheet.get_Range("K24", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox72.Text);
                    objRange = objSheet.get_Range("P24", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox71.Text);
                    objRange = objSheet.get_Range("Q24", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox70.Text);
                    objRange = objSheet.get_Range("R24", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox69.Text);
                    objRange = objSheet.get_Range("S24", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox68.Text);



                    objRange = objSheet.get_Range("A26", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox88.Text);
                    objRange = objSheet.get_Range("B26", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox87.Text);
                    objRange = objSheet.get_Range("E26", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox86.Text);
                    objRange = objSheet.get_Range("H26", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox85.Text);
                    objRange = objSheet.get_Range("J26", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox84.Text);
                    objRange = objSheet.get_Range("K26", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox83.Text);
                    objRange = objSheet.get_Range("P26", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox82.Text);
                    objRange = objSheet.get_Range("Q26", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox81.Text);
                    objRange = objSheet.get_Range("R26", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox80.Text);
                    objRange = objSheet.get_Range("S26", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox79.Text);


                    objRange = objSheet.get_Range("A28", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox99.Text);
                    objRange = objSheet.get_Range("B28", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox98.Text);
                    objRange = objSheet.get_Range("E28", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox97.Text);
                    objRange = objSheet.get_Range("H28", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox96.Text);
                    objRange = objSheet.get_Range("J28", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox95.Text);
                    objRange = objSheet.get_Range("K28", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox94.Text);
                    objRange = objSheet.get_Range("P28", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox93.Text);
                    objRange = objSheet.get_Range("Q28", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox92.Text);
                    objRange = objSheet.get_Range("R28", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox91.Text);
                    objRange = objSheet.get_Range("S28", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox90.Text);


                    objRange = objSheet.get_Range("a30", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox110.Text);
                    objRange = objSheet.get_Range("b30", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox109.Text);
                    objRange = objSheet.get_Range("E30", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox108.Text);
                    objRange = objSheet.get_Range("H30", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox107.Text);
                    objRange = objSheet.get_Range("J30", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox106.Text);
                    objRange = objSheet.get_Range("K30", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox105.Text);
                    objRange = objSheet.get_Range("P30", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox104.Text);
                    objRange = objSheet.get_Range("Q30", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox103.Text);
                    objRange = objSheet.get_Range("R30", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox102.Text);
                    objRange = objSheet.get_Range("S30", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox101.Text);


                    objRange = objSheet.get_Range("a32", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox121.Text);
                    objRange = objSheet.get_Range("b32", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox120.Text);
                    objRange = objSheet.get_Range("E32", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox119.Text);
                    objRange = objSheet.get_Range("H32", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox118.Text);
                    objRange = objSheet.get_Range("J32", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox117.Text);
                    objRange = objSheet.get_Range("K32", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox116.Text);
                    objRange = objSheet.get_Range("P32", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox115.Text);
                    objRange = objSheet.get_Range("Q32", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox114.Text);
                    objRange = objSheet.get_Range("R32", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox113.Text);
                    objRange = objSheet.get_Range("S32", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox112.Text);


                    objRange = objSheet.get_Range("a34", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox132.Text);
                    objRange = objSheet.get_Range("b34", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox131.Text);
                    objRange = objSheet.get_Range("E34", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox130.Text);
                    objRange = objSheet.get_Range("H34", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox129.Text);
                    objRange = objSheet.get_Range("J34", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox128.Text);
                    objRange = objSheet.get_Range("K34", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox127.Text);
                    objRange = objSheet.get_Range("P34", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox126.Text);
                    objRange = objSheet.get_Range("Q34", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox125.Text);
                    objRange = objSheet.get_Range("R34", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox124.Text);
                    objRange = objSheet.get_Range("S34", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox123.Text);


                    objRange = objSheet.get_Range("a36", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox143.Text);
                    objRange = objSheet.get_Range("b36", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox142.Text);
                    objRange = objSheet.get_Range("E36", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox141.Text);
                    objRange = objSheet.get_Range("H36", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox140.Text);
                    objRange = objSheet.get_Range("J36", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox139.Text);
                    objRange = objSheet.get_Range("K36", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox138.Text);
                    objRange = objSheet.get_Range("P36", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox137.Text);
                    objRange = objSheet.get_Range("Q36", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox136.Text);
                    objRange = objSheet.get_Range("R36", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox135.Text);
                    objRange = objSheet.get_Range("S36", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox134.Text);


                    objRange = objSheet.get_Range("a38", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox154.Text);
                    objRange = objSheet.get_Range("b38", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox153.Text);
                    objRange = objSheet.get_Range("E38", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox152.Text);
                    objRange = objSheet.get_Range("H38", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox151.Text);
                    objRange = objSheet.get_Range("J38", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox150.Text);
                    objRange = objSheet.get_Range("K38", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox149.Text);
                    objRange = objSheet.get_Range("P38", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox148.Text);
                    objRange = objSheet.get_Range("Q38", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox147.Text);
                    objRange = objSheet.get_Range("R38", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox146.Text);
                    objRange = objSheet.get_Range("S38", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox145.Text);


                    objRange = objSheet.get_Range("a40", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox165.Text);
                    objRange = objSheet.get_Range("b40", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox164.Text);
                    objRange = objSheet.get_Range("E40", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox163.Text);
                    objRange = objSheet.get_Range("H40", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox162.Text);
                    objRange = objSheet.get_Range("J40", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox161.Text);
                    objRange = objSheet.get_Range("K40", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox160.Text);
                    objRange = objSheet.get_Range("P40", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox159.Text);
                    objRange = objSheet.get_Range("Q40", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox158.Text);
                    objRange = objSheet.get_Range("R40", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox157.Text);
                    objRange = objSheet.get_Range("S40", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox156.Text);


                    objRange = objSheet.get_Range("a42", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox176.Text);
                    objRange = objSheet.get_Range("b42", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox175.Text);
                    objRange = objSheet.get_Range("E42", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox174.Text);
                    objRange = objSheet.get_Range("H42", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox173.Text);
                    objRange = objSheet.get_Range("J42", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox172.Text);
                    objRange = objSheet.get_Range("K42", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox171.Text);
                    objRange = objSheet.get_Range("P42", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox170.Text);
                    objRange = objSheet.get_Range("Q42", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox169.Text);
                    objRange = objSheet.get_Range("R42", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox168.Text);
                    objRange = objSheet.get_Range("S42", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox167.Text);


                    objRange = objSheet.get_Range("a44", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox187.Text);
                    objRange = objSheet.get_Range("b44", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox186.Text);
                    objRange = objSheet.get_Range("E44", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox185.Text);
                    objRange = objSheet.get_Range("H44", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox184.Text);
                    objRange = objSheet.get_Range("J44", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox183.Text);
                    objRange = objSheet.get_Range("K44", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox182.Text);
                    objRange = objSheet.get_Range("P44", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox181.Text);
                    objRange = objSheet.get_Range("Q44", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox180.Text);
                    objRange = objSheet.get_Range("R44", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox179.Text);
                    objRange = objSheet.get_Range("S44", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox178.Text);

                    objRange = objSheet.get_Range("a46", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox198.Text);
                    objRange = objSheet.get_Range("b46", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox197.Text);
                    objRange = objSheet.get_Range("E46", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox196.Text);
                    objRange = objSheet.get_Range("H46", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox195.Text);
                    objRange = objSheet.get_Range("J46", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox194.Text);
                    objRange = objSheet.get_Range("K46", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox193.Text);
                    objRange = objSheet.get_Range("P46", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox192.Text);
                    objRange = objSheet.get_Range("Q46", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox191.Text);
                    objRange = objSheet.get_Range("R46", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox190.Text);
                    objRange = objSheet.get_Range("S46", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox189.Text);


                    objRange = objSheet.get_Range("a48", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox209.Text);
                    objRange = objSheet.get_Range("b48", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox208.Text);
                    objRange = objSheet.get_Range("E48", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox207.Text);
                    objRange = objSheet.get_Range("H48", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox206.Text);
                    objRange = objSheet.get_Range("J48", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox205.Text);
                    objRange = objSheet.get_Range("K48", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox204.Text);
                    objRange = objSheet.get_Range("P48", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox203.Text);
                    objRange = objSheet.get_Range("Q48", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox202.Text);
                    objRange = objSheet.get_Range("R48", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox201.Text);
                    objRange = objSheet.get_Range("S48", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox200.Text);



                    objSheet.PrintOutEx(1, 1, 2, true);

                    Form anasayfa = new anasayfa();
                    anasayfa.Show();
                    this.Hide();
                }
                catch (Exception)
                {
                }
            }
        }
コード例 #3
0
ファイル: Table_ToExcel.cs プロジェクト: xinqishiyin/BR300-
        /// <summary>
        /// 打印Excel (打印设置列宽不能出现E:F)
        /// </summary>
        /// <param name="isLandscape">是否所有Sheet横向打印(true为横向打印)</param>
        public void PrintExcel(bool isLandscape)
        {
            try
            {
                Microsoft.Office.Interop.Excel.Workbook wb = GetExcelWorkbook();
                if (wb == null)
                {
                    return;
                }

                foreach (var v in wb.Worksheets)
                {
                    try
                    {
                        Microsoft.Office.Interop.Excel.Worksheet wsheet = ((Microsoft.Office.Interop.Excel.Worksheet)v);
                        //无数据表无需打印
                        if (SheetTable[wsheet.Name].Rows.Count > 0)
                        {
                            if (isLandscape)
                            {
                                //设置横向打印,默认纵向
                                wsheet.PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;   //横向打印
                            }
                            //设置纸张类型
                            wsheet.PageSetup.PaperSize = Microsoft.Office.Interop.Excel.XlPaperSize.xlPaperA4;
                            //设置打印边距
                            wsheet.PageSetup.TopMargin    = _pageMargin.Top;
                            wsheet.PageSetup.BottomMargin = _isPrintFooter ? 12.00 : _pageMargin.Bottom;
                            wsheet.PageSetup.LeftMargin   = _pageMargin.Left;
                            wsheet.PageSetup.RightMargin  = _pageMargin.Right;
                            //wsheet.PageSetup.CenterHorizontally = true;
                            //wsheet.PageSetup.CenterVertically = true;   //这2句是居中打印
                            //wsheet.PageSetup.CenterFooter = "&\"Arial\"&12 " + obj.pageid.ToString();//页脚字体和大小
                            wsheet.PageSetup.FooterMargin = 1;
                            if (_isPrintFooter)
                            {
                                //打印页脚
                                wsheet.PageSetup.LeftFooter   = wsheet.Name;
                                wsheet.PageSetup.CenterFooter = @"第 &P 页/共 &N 页";
                                wsheet.PageSetup.RightFooter  = "打印时间:" + DateTime.Now.ToString();
                            }
                            //列宽自适应 (中英文数字混排的时候,如果不设置自动适应列宽的话,有的时候打印会缺字)
                            wsheet.Columns.AutoFit();
                            if (!String.IsNullOrEmpty(_expandColumnName)) //如果有扩大的列
                            {
                                float swidth = 0;                         //目前实际宽度
                                float ywidth = 0;                         //应该显示的宽度
                                foreach (var vk in _columnswidth)
                                {
                                    object obj = ((Microsoft.Office.Interop.Excel.Range)wsheet.Columns[vk.Key, Type.Missing]).ColumnWidth;
                                    swidth += float.Parse(obj.ToString());
                                    ywidth += vk.Value;  //设置的列宽总和
                                }
                                //自适应宽度后,总宽度小于我打印时设置的总宽度,则把缩小的宽度添加到可以扩大的列上
                                //扩大某列的宽度
                                Microsoft.Office.Interop.Excel.Range colrange = (Microsoft.Office.Interop.Excel.Range)wsheet.Columns[_expandColumnName, Type.Missing];
                                float cwidth = float.Parse(colrange.ColumnWidth.ToString());  //列当前宽度
                                if (swidth < ywidth)
                                {
                                    colrange.ColumnWidth = (cwidth + (ywidth - swidth));
                                }
                                else
                                {
                                    colrange.ColumnWidth = (cwidth - (swidth - ywidth));
                                }
                            }
                            //自适应行
                            wsheet.Rows.AutoFit();
                            //打印
                            wsheet.PrintOutEx();
                        }
                    }
                    catch
                    { }
                }
                //打印整个Workbook(所有Sheet表都打印出来)
                //wb.PrintOutEx();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Close();
            }
        }
コード例 #4
0
        public void yazdir()
        {
            Microsoft.Office.Interop.Excel.Application objExcel = new Microsoft.Office.Interop.Excel.Application();
            objExcel.Visible = true;
            Microsoft.Office.Interop.Excel.Workbook  objBook  = objExcel.Workbooks.Open("c:\\ambartesellum.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            Microsoft.Office.Interop.Excel.Worksheet objSheet = (Microsoft.Office.Interop.Excel.Worksheet)objBook.Worksheets.get_Item(1);
            Microsoft.Office.Interop.Excel.Range     objRange;


            objRange = objSheet.get_Range("J4", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, dateTimePicker2.Text);
            objRange = objSheet.get_Range("C4", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox7.Text);

            //ALICI BİLGİLERİ
            objRange = objSheet.get_Range("A7", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, comboBox2.Text);
            objRange = objSheet.get_Range("A8", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox1.Text);
            objRange = objSheet.get_Range("C9", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox2.Text);
            objRange = objSheet.get_Range("C10", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox4.Text);
            ///////////////////////////////////////////////////////////////////

            //GÖNDEREN BİLGİLERİ
            objRange = objSheet.get_Range("G7", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, comboBox4.Text);
            objRange = objSheet.get_Range("G8", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox6.Text);
            objRange = objSheet.get_Range("I9", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox8.Text);
            objRange = objSheet.get_Range("I10", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox5.Text);
            ///////////////////////////////////////////////////////////////////

            //MALIN ÖZELLİKLERİ
            //ADET
            objRange = objSheet.get_Range("A13", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox9.Text);
            objRange = objSheet.get_Range("A14", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox10.Text);
            objRange = objSheet.get_Range("A15", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox11.Text);
            objRange = objSheet.get_Range("A16", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox12.Text);
            ////////////////////////////////////////////////////////////////////
            //KAB
            objRange = objSheet.get_Range("B13", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox14.Text);
            objRange = objSheet.get_Range("B14", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox15.Text);
            objRange = objSheet.get_Range("B15", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox16.Text);
            objRange = objSheet.get_Range("B16", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox17.Text);
            ////////////////////////////////////////////////////////////////////
            //CİNSİ
            objRange = objSheet.get_Range("C13", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox19.Text);
            objRange = objSheet.get_Range("C14", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox20.Text);
            objRange = objSheet.get_Range("C15", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox21.Text);
            objRange = objSheet.get_Range("C16", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox22.Text);
            ////////////////////////////////////////////////////////////////////
            //KG
            objRange = objSheet.get_Range("F13", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox24.Text);
            objRange = objSheet.get_Range("F14", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox25.Text);
            objRange = objSheet.get_Range("F15", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox26.Text);
            objRange = objSheet.get_Range("F16", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox27.Text);
            ////////////////////////////////////////////////////////////////////
            objRange = objSheet.get_Range("K16", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox40.Text);
            objRange = objSheet.get_Range("G16", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox39.Text);
            objRange = objSheet.get_Range("I16", System.Reflection.Missing.Value);
            objRange.set_Value(System.Reflection.Missing.Value, textBox3.Text);

            objSheet.PrintOutEx(1, 1, 2, true);
            Form anasayfa = new anasayfa();

            anasayfa.Show();
            this.Hide();
        }
コード例 #5
0
 public void SheetDrucken(string Drucker)
 {
     XlWorkSheet.PrintOutEx(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Drucker);
 }
コード例 #6
0
        /////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////////////////
        private void button1_Click(object sender, EventArgs e)
        {
            onay = MessageBox.Show("Onaylıyor musunuz?", "Onay", MessageBoxButtons.YesNo);

            if (onay == DialogResult.Yes)
            {
                try
                {
                    mysqlbaglan.Open();
                    string       komut = "insert into fatura(sayin,vdno,no,adres,adres2,tarih,fisNo,tarih1,aciklama,adet,kab,cins,kilo,fiyat,tutar,fisNo2,tarih2,aciklama2,adet2,kab2,cins2,kilo2,fiyat2,tutar2,fisNo3,tarih3,aciklama3,adet3,kab3,cins3,kilo3,fiyat3,tutar3,fisNo4,tarih4,aciklama4,adet4,kab4,cins4,kilo4,fiyat4,tutar4,fisNo5,tarih5,aciklama5,adet5,kab5,cins5,kilo5,fiyat5,tutar5,fisNo6,tarih6,aciklama6,adet6,kab6,cins6,kilo6,fiyat6,tutar6,toplam,genelToplam,tesellumNo) values('" + comboBox1.Text + "', '" + textBox2.Text + "','" + textBox1.Text + "','" + textBox16.Text + "','" + textBox23.Text + "', '" + dateTimePicker1.Text + "', '" + comboBox2.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "', '" + textBox6.Text + "', '" + textBox7.Text + "', '" + textBox8.Text + "', '" + textBox9.Text + "','" + textBox50.Text + "','" + textBox56.Text + "','" + comboBox3.Text + "', '" + textBox15.Text + "', '" + textBox14.Text + "', '" + textBox13.Text + "', '" + textBox12.Text + "', '" + textBox11.Text + "', '" + textBox10.Text + "','" + textBox49.Text + "','" + textBox55.Text + "','" + comboBox4.Text + "', '" + textBox22.Text + "', '" + textBox21.Text + "', '" + textBox20.Text + "', '" + textBox19.Text + "', '" + textBox18.Text + "', '" + textBox17.Text + "','" + textBox48.Text + "','" + textBox54.Text + "','" + comboBox5.Text + "', '" + textBox29.Text + "', '" + textBox28.Text + "', '" + textBox27.Text + "', '" + textBox26.Text + "', '" + textBox25.Text + "', '" + textBox24.Text + "','" + textBox47.Text + "','" + textBox53.Text + "','" + comboBox6.Text + "', '" + textBox36.Text + "', '" + textBox35.Text + "', '" + textBox34.Text + "', '" + textBox33.Text + "', '" + textBox32.Text + "', '" + textBox31.Text + "','" + textBox46.Text + "','" + textBox52.Text + "','" + comboBox7.Text + "', '" + textBox43.Text + "', '" + textBox42.Text + "', '" + textBox41.Text + "', '" + textBox40.Text + "', '" + textBox39.Text + "', '" + textBox38.Text + "','" + textBox45.Text + "','" + textBox51.Text + "','" + label1.Text + "','" + label2.Text + "','" + textBox3.Text + "')";
                    MySqlCommand kmt   = new MySqlCommand(komut, mysqlbaglan);
                    kmt.ExecuteNonQuery();

                    Microsoft.Office.Interop.Excel.Application objExcel = new Microsoft.Office.Interop.Excel.Application();
                    objExcel.Visible = true;
                    Microsoft.Office.Interop.Excel.Workbook  objBook  = objExcel.Workbooks.Open("c:\\fatura.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                    Microsoft.Office.Interop.Excel.Worksheet objSheet = (Microsoft.Office.Interop.Excel.Worksheet)objBook.Worksheets.get_Item(1);
                    Microsoft.Office.Interop.Excel.Range     objRange;


                    objRange = objSheet.get_Range("K7", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, dateTimePicker1.Text);
                    objRange = objSheet.get_Range("b7", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox2.Text);
                    objRange = objSheet.get_Range("e7", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox1.Text);
                    objRange = objSheet.get_Range("k4", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox3.Text);

                    objRange = objSheet.get_Range("b3", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, comboBox1.Text);

                    objRange = objSheet.get_Range("A4", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox16.Text);

                    objRange = objSheet.get_Range("A5", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox23.Text);

                    objRange = objSheet.get_Range("A23", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox30.Text);
                    // 1. SIRA
                    objRange = objSheet.get_Range("A10", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, comboBox2.Text);
                    objRange = objSheet.get_Range("B10", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox4.Text);
                    objRange = objSheet.get_Range("C10", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox5.Text);
                    objRange = objSheet.get_Range("F10", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox6.Text);
                    objRange = objSheet.get_Range("G10", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox7.Text);
                    objRange = objSheet.get_Range("H10", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox8.Text);
                    objRange = objSheet.get_Range("I10", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox9.Text);
                    objRange = objSheet.get_Range("J10", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox50.Text);
                    objRange = objSheet.get_Range("K10", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox56.Text);

                    // 2. SIRA
                    objRange = objSheet.get_Range("A12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, comboBox3.Text);
                    objRange = objSheet.get_Range("B12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox15.Text);
                    objRange = objSheet.get_Range("C12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox14.Text);
                    objRange = objSheet.get_Range("F12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox13.Text);
                    objRange = objSheet.get_Range("G12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox12.Text);
                    objRange = objSheet.get_Range("H12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox11.Text);
                    objRange = objSheet.get_Range("I12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox10.Text);
                    objRange = objSheet.get_Range("J12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox49.Text);
                    objRange = objSheet.get_Range("K12", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox55.Text);

                    //3. SIRA
                    objRange = objSheet.get_Range("A14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, comboBox4.Text);
                    objRange = objSheet.get_Range("B14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox22.Text);
                    objRange = objSheet.get_Range("C14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox21.Text);
                    objRange = objSheet.get_Range("F14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox20.Text);
                    objRange = objSheet.get_Range("G14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox19.Text);
                    objRange = objSheet.get_Range("H14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox18.Text);
                    objRange = objSheet.get_Range("I14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox17.Text);
                    objRange = objSheet.get_Range("J14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox48.Text);
                    objRange = objSheet.get_Range("K14", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox54.Text);

                    //4. SIRA
                    objRange = objSheet.get_Range("A16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, comboBox5.Text);
                    objRange = objSheet.get_Range("B16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox29.Text);
                    objRange = objSheet.get_Range("C16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox28.Text);
                    objRange = objSheet.get_Range("F16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox27.Text);
                    objRange = objSheet.get_Range("G16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox26.Text);
                    objRange = objSheet.get_Range("H16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox25.Text);
                    objRange = objSheet.get_Range("I16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox24.Text);
                    objRange = objSheet.get_Range("J16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox47.Text);
                    objRange = objSheet.get_Range("K16", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox53.Text);

                    //5. SIRA
                    objRange = objSheet.get_Range("A18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, comboBox6.Text);
                    objRange = objSheet.get_Range("B18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox36.Text);
                    objRange = objSheet.get_Range("C18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox35.Text);
                    objRange = objSheet.get_Range("F18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox34.Text);
                    objRange = objSheet.get_Range("G18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox33.Text);
                    objRange = objSheet.get_Range("H18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox32.Text);
                    objRange = objSheet.get_Range("I18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox31.Text);
                    objRange = objSheet.get_Range("J18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox46.Text);
                    objRange = objSheet.get_Range("K18", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox52.Text);

                    //6. SIRA
                    objRange = objSheet.get_Range("A20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, comboBox7.Text);
                    objRange = objSheet.get_Range("B20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox43.Text);
                    objRange = objSheet.get_Range("C20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox42.Text);
                    objRange = objSheet.get_Range("F20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox41.Text);
                    objRange = objSheet.get_Range("G20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox40.Text);
                    objRange = objSheet.get_Range("H20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox39.Text);
                    objRange = objSheet.get_Range("I20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox38.Text);
                    objRange = objSheet.get_Range("J20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox45.Text);
                    objRange = objSheet.get_Range("K20", System.Reflection.Missing.Value);
                    objRange.set_Value(System.Reflection.Missing.Value, textBox51.Text);

                    objSheet.PrintOutEx(1, 1, 2, true);
                    Form anasayfa = new anasayfa();
                    anasayfa.Show();
                    this.Hide();
                }
                catch (Exception h)
                {
                    MessageBox.Show("Beklenmeyen bir hata oluştu lütfen tekrar deneyiniz" + h, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }