/// <summary> /// Prepara la vista previa /// </summary> /// <param name="_grilla" ></param>El DataGridView de donde se verifica lo que se imprime /// <param name="_BandW"></param>Ture si es en Blanco y Negro y False si es a color /// <param name="_impresora"></param>nombre de la impresora o Type.Missing si mostraremos una vista previa public void _Imprimir(DataGridView _grilla, Boolean _BandW, object _impresora) { if (!Verificar(_grilla)) { MessageBox.Show("Debe seleccionar al menos un anexo. ", "Imprimir SIPRED", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Excel.Workbook libron = Globals.ThisAddIn.Application.ActiveWorkbook; Excel.Workbook libro = libron; Generales.Proteccion(false); //Desactivamos los mensajes de Alerta del Excel Globals.ThisAddIn.Application.DisplayAlerts = false; int numhj = 0; _Cargararraynombre(_HojasSPR); for (int k = 1; k <= _grilla.RowCount; k++) { numhj = Array.IndexOf(_nombre, _grilla.Rows[k - 1].Cells["Anexo"].Value.ToString().Trim().ToUpper()); if (_grilla.Rows[k - 1].Cells["Imprimir"].Value.ToString().Trim().ToUpper() == "TRUE") { numhj = Array.IndexOf(_nombre, _grilla.Rows[k - 1].Cells["Anexo"].Value.ToString().Trim().ToUpper()); //para mantener las dos primeras filas y columnas fijas en la vista previa ((Excel.Worksheet)libro.Sheets[_grilla.Rows[k - 1].Cells["Anexo"].Value.ToString().Trim().ToUpper()]).PageSetup.PrintTitleRows = "$1:$2"; ((Excel.Worksheet)libro.Sheets[_grilla.Rows[k - 1].Cells["Anexo"].Value.ToString().Trim().ToUpper()]).PageSetup.PrintTitleColumns = "$A:$B"; ((Excel.Worksheet)libro.Sheets[_grilla.Rows[k - 1].Cells["Anexo"].Value.ToString().Trim().ToUpper()]).PageSetup.Zoom = 65; ((Excel.Worksheet)libro.Sheets[_grilla.Rows[k - 1].Cells["Anexo"].Value.ToString().Trim().ToUpper()]).PageSetup.BlackAndWhite = _BandW; //Cuando Es un Anexo: Orientacion horizontal if (_grilla.Rows[k - 1].Cells["Anexo"].Value.ToString().Trim().ToUpper().Contains("ANEXO")) { ((Excel.Worksheet)libro.Sheets[_grilla.Rows[k - 1].Cells["Anexo"].Value.ToString().Trim().ToUpper()]).PageSetup.Orientation = XlPageOrientation.xlLandscape; } else { ((Excel.Worksheet)libro.Sheets[_grilla.Rows[k - 1].Cells["Anexo"].Value.ToString().Trim().ToUpper()]).PageSetup.Orientation = XlPageOrientation.xlPortrait; } } else if (numhj != -1) { ((Excel.Worksheet)libro.Sheets[_grilla.Rows[k - 1].Cells["Anexo"].Value.ToString().Trim().ToUpper()]).Visible = XlSheetVisibility.xlSheetHidden; } //Notas a ocultar //Si se ocultaron hojas las vuelve visible todas for (int x = 1; x <= libro.Worksheets.Count; x++) { if (Array.IndexOf(_nombre, ((Excel.Worksheet)libro.Sheets[x]).Name.ToString().Trim().ToUpper()) != -1 && _HojasSPR[Array.IndexOf(_nombre, ((Excel.Worksheet)libro.Sheets[x]).Name.ToString().Trim().ToUpper()), 4].Trim().Length == 0) { ((Excel.Worksheet)libro.Sheets[x]).Visible = XlSheetVisibility.xlSheetHidden; } } } //Generales.Proteccion(false); if (_impresora == Type.Missing) { libro.PrintOut(Type.Missing, Type.Missing, Type.Missing, true, _impresora, Type.Missing, Type.Missing, Type.Missing); } else if (_impresora.ToString() == "PDF") { string _Path = Configuration.Path + "\\SIPRED" + DateTime.Now.ToString("yyyyMMdd_HHmm") + ".pdf"; libro.ExportAsFixedFormat(Type: XlFixedFormatType.xlTypePDF, Filename: _Path, Quality: XlFixedFormatQuality.xlQualityStandard, OpenAfterPublish: true); } else { libro.PrintOut(Type.Missing, Type.Missing, Type.Missing, false, _impresora, Type.Missing, Type.Missing, Type.Missing); } //Si se ocultaron hojas las vuelve visible todas for (int k = 1; k <= libro.Worksheets.Count; k++) { if (Array.IndexOf(_nombre, ((Excel.Worksheet)libro.Sheets[k]).Name.ToString().Trim().ToUpper()) != -1) { ((Excel.Worksheet)libro.Sheets[k]).Visible = XlSheetVisibility.xlSheetVisible; } else { ((Excel.Worksheet)libro.Sheets[k]).Visible = XlSheetVisibility.xlSheetHidden; } } Generales.Proteccion(true); //Activamos los mensajes de Alerta del Excel Globals.ThisAddIn.Application.DisplayAlerts = true; }
/// <summary> /// 社員出勤簿印刷・シート追加一括印刷 /// </summary> private void sReport() { // 休日テーブル読み込み MTYSDataSetTableAdapters.休日TableAdapter adpH = new MTYSDataSetTableAdapters.休日TableAdapter(); adpH.Fill(dts.休日); // 出勤日数テーブル読み込み MTYSDataSetTableAdapters.出勤日数TableAdapter adpS = new MTYSDataSetTableAdapters.出勤日数TableAdapter(); adpS.Fill(dts.出勤日数); //エクセルファイル日付明細開始行 const int S_GYO = 6; string sDate; DateTime eDate; try { //マウスポインタを待機にする this.Cursor = Cursors.WaitCursor; string sAppPath = System.AppDomain.CurrentDomain.BaseDirectory; Excel.Application oXls = new Excel.Application(); // 勤務報告書テンプレートシート Excel.Workbook oXlsBook = (Excel.Workbook)(oXls.Workbooks.Open(Properties.Settings.Default.sxlsPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)); // 勤務報告書印刷用シート Excel.Workbook oXlsPrintBook = (Excel.Workbook)(oXls.Workbooks.Open(Properties.Settings.Default.wxlsPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)); Excel.Worksheet oxlsOosaka = (Excel.Worksheet)oXlsBook.Sheets[1]; // 大阪製造部書式 Excel.Worksheet oxlsShizuoka = (Excel.Worksheet)oXlsBook.Sheets[2]; // 静岡書式 Excel.Worksheet oxlsHonsha = (Excel.Worksheet)oXlsBook.Sheets[3]; // 本社書式 Excel.Worksheet oxlsPrintSheet = null; // 印刷用ワークシート Excel.Range[] rng = new Microsoft.Office.Interop.Excel.Range[2]; string Category = string.Empty; try { int pCnt = 0; //グリッドを順番に読む for (int i = 0; i < dg1.RowCount; i++) { //チェックがあるものを対象とする if (dg1[0, i].Value.ToString() == "True") { pCnt++; // ページカウント int sRow = i; // グリッド行インデックス取得 // 帳票区分取得 Category = dg1[9, sRow].Value.ToString(); // 印刷用BOOKへシートを追加する if (Category == global.C_HONSHA) // 本社 { oxlsHonsha.Copy(Type.Missing, oXlsPrintBook.Sheets[pCnt]); } else if (Category == global.C_SHIZUOKA) // 静岡 { oxlsShizuoka.Copy(Type.Missing, oXlsPrintBook.Sheets[pCnt]); } else if (Category == global.C_OOSAKA) // 大阪 { oxlsOosaka.Copy(Type.Missing, oXlsPrintBook.Sheets[pCnt]); } // カレントのシートを設定 oxlsPrintSheet = (Excel.Worksheet)oXlsPrintBook.Sheets[pCnt + 1]; //// 印刷2件目以降はシートを追加する //if (pCnt > 1) //{ // oxlsSheet.Copy(Type.Missing, oXlsPrintBook.Sheets[pCnt - 1]); // oxlsSheet = (Excel.Worksheet)oXlsPrintBook.Sheets[pCnt]; //} // 社員番号 oxlsPrintSheet.Cells[2, 19] = dg1[1, sRow].Value.ToString().PadLeft(ShainLen, '0').Substring(0, 1); oxlsPrintSheet.Cells[2, 20] = dg1[1, sRow].Value.ToString().PadLeft(ShainLen, '0').Substring(1, 1); oxlsPrintSheet.Cells[2, 21] = dg1[1, sRow].Value.ToString().PadLeft(ShainLen, '0').Substring(2, 1); oxlsPrintSheet.Cells[2, 22] = dg1[1, sRow].Value.ToString().PadLeft(ShainLen, '0').Substring(3, 1); // 職級 oxlsPrintSheet.Cells[2, 25] = dg1[6, sRow].Value.ToString(); // 年 oxlsPrintSheet.Cells[2, 11] = string.Format("{0, 2}", int.Parse(txtYear.Text)).Substring(2, 1); oxlsPrintSheet.Cells[2, 12] = string.Format("{0, 2}", int.Parse(txtYear.Text)).Substring(3, 1); // 月 oxlsPrintSheet.Cells[2, 14] = string.Format("{0, 2}", int.Parse(txtMonth.Text)).Substring(0, 1); oxlsPrintSheet.Cells[2, 15] = string.Format("{0, 2}", int.Parse(txtMonth.Text)).Substring(1, 1); // 所属コード oxlsPrintSheet.Cells[3, 3] = dg1[4, sRow].Value.ToString().PadLeft(ShozokuLen, '0').Substring(0, 1); oxlsPrintSheet.Cells[3, 4] = dg1[4, sRow].Value.ToString().PadLeft(ShozokuLen, '0').Substring(1, 1); oxlsPrintSheet.Cells[3, 5] = dg1[4, sRow].Value.ToString().PadLeft(ShozokuLen, '0').Substring(2, 1); oxlsPrintSheet.Cells[3, 6] = dg1[4, sRow].Value.ToString().PadLeft(ShozokuLen, '0').Substring(3, 1); oxlsPrintSheet.Cells[3, 7] = dg1[4, sRow].Value.ToString().PadLeft(ShozokuLen, '0').Substring(4, 1); oxlsPrintSheet.Cells[3, 8] = dg1[4, sRow].Value.ToString().PadLeft(ShozokuLen, '0').Substring(5, 1); // 所属名 oxlsPrintSheet.Cells[3, 11] = dg1[5, sRow].Value.ToString(); // 氏名 oxlsPrintSheet.Cells[3, 19] = dg1[2, sRow].Value.ToString(); // 出勤すべき日数を取得 var h = dts.出勤日数.Where(a => a.RowState != DataRowState.Deleted && a.RowState != DataRowState.Detached && a.年.ToString() == txtYear.Text && a.月.ToString() == txtMonth.Text); string injiNisu = string.Empty; foreach (var t in h) { if (Category == global.C_HONSHA || Category == global.C_SHIZUOKA) // 本社のとき { injiNisu = t.本社静岡印字用.ToString(); } else if (Category == global.C_OOSAKA) // 大阪製造部のとき { if (dg1[10, sRow].Value.ToString() == global.OOSAKAG_A) // 大阪製造Aのとき { injiNisu = t.大阪A印字用.ToString(); } else if (dg1[10, sRow].Value.ToString() == global.OOSAKAG_B) // 大阪製造Bのとき { injiNisu = t.大阪B印字用.ToString(); } else if (dg1[10, sRow].Value.ToString() == global.OOSAKAG_C) // 大阪製造Cのとき { injiNisu = t.大阪C印字用.ToString(); } else if (dg1[10, sRow].Value.ToString() == global.OOSAKAG_D) // 大阪製造Dのとき { injiNisu = t.大阪D印字用.ToString(); } else { // 大阪製造部のとき injiNisu = t.大阪印字用.ToString(); } } } oxlsPrintSheet.Cells[3, 28] = injiNisu; // 曜日表示 int addRow = 0; for (int iX = global.MAX_MIN; iX <= global.MAX_GYO; iX++) { if (iX < 7) { addRow = iX - 1; } else if (iX < 17) { addRow = iX; } else { addRow = iX + 1; } // 暦補正値は設定ファイルから取得する 2011/03/24 sDate = txtYear.Text + "/" + txtMonth.Text + "/" + iX.ToString(); if (DateTime.TryParse(sDate, out eDate)) { //oxlsPrintSheet.Cells[S_GYO + addRow, 2] = ("日月火水木金土").Substring(int.Parse(eDate.DayOfWeek.ToString("d")), 1); oxlsPrintSheet.Cells[S_GYO + addRow, 2] = eDate.ToString("ddd"); } else { oxlsPrintSheet.Cells[S_GYO + addRow, 1] = string.Empty; } // // 網掛け処理 // rng[0] = (Excel.Range)oxlsPrintSheet.Cells[S_GYO + addRow, 1]; rng[1] = (Excel.Range)oxlsPrintSheet.Cells[S_GYO + addRow, 2]; var s = dts.休日.Where(a => a.RowState != DataRowState.Deleted && a.RowState != DataRowState.Detached && a.年月日 == eDate); foreach (var t in s) { if (Category == global.C_HONSHA && t.本社網掛け == global.flgOn) // 本社のとき { oxlsPrintSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.LightGray; } else if (Category == global.C_SHIZUOKA && t.静岡網掛け == global.flgOn) // 静岡のとき { oxlsPrintSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.LightGray; } else if (Category == global.C_OOSAKA) // 大阪製造部のとき { if (dg1[10, sRow].Value.ToString() == global.OOSAKAG_A && t.大阪A網掛け == global.flgOn) // 大阪製造Aのとき { oxlsPrintSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.LightGray; } else if (dg1[10, sRow].Value.ToString() == global.OOSAKAG_B && t.大阪B網掛け == global.flgOn) // 大阪製造Bのとき { oxlsPrintSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.LightGray; } else if (dg1[10, sRow].Value.ToString() == global.OOSAKAG_C && t.大阪C網掛け == global.flgOn) // 大阪製造Cのとき { oxlsPrintSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.LightGray; } else if (dg1[10, sRow].Value.ToString() == global.OOSAKAG_D && t.大阪D網掛け == global.flgOn) // 大阪製造Dのとき { oxlsPrintSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.LightGray; } else if (Utility.NulltoStr(dg1[10, sRow].Value) == string.Empty && t.大阪製造部網掛け == global.flgOn) // 大阪製造のとき { oxlsPrintSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.LightGray; } } } } } } //マウスポインタを元に戻す this.Cursor = Cursors.Default; // 印刷用BOOKの1番目のシートは削除する ((Excel.Worksheet)oXlsPrintBook.Sheets[1]).Delete(); //印刷 oXlsPrintBook.PrintOut(); // ウィンドウを非表示にする oXls.Visible = false; //保存処理 oXls.DisplayAlerts = false; //Bookをクローズ oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing); oXlsPrintBook.Close(Type.Missing, Type.Missing, Type.Missing); //Excelを終了 oXls.Quit(); } catch (Exception e) { MessageBox.Show(e.Message, "印刷処理", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // ウィンドウを非表示にする oXls.Visible = false; //保存処理 oXls.DisplayAlerts = false; //Bookをクローズ oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing); //Excelを終了 oXls.Quit(); } finally { // COM オブジェクトの参照カウントを解放する System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsHonsha); System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsShizuoka); System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsOosaka); System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsPrintSheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXlsBook); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXlsPrintBook); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXls); //マウスポインタを元に戻す this.Cursor = Cursors.Default; } } catch (Exception e) { MessageBox.Show(e.Message, "印刷処理", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //マウスポインタを元に戻す this.Cursor = Cursors.Default; }
/// <summary> /// 印刷 /// </summary> public void Print() { m_objBook.PrintOut(miss, miss, miss, miss, miss, miss, miss, miss); }
///---------------------------------------------------------------------- /// <summary> /// 返信FAX原稿作成 </summary> /// <param name="xlsPath"> /// エクセルシートパス</param> /// <param name="sPrinter"> /// 印刷プリンタ</param> ///---------------------------------------------------------------------- public static void sReport(string xlsPath, string sPrinter) { try { Excel.Application oXls = new Excel.Application(); Excel.Workbook oXlsBook = (Excel.Workbook)(oXls.Workbooks.Open(xlsPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)); // シート Excel.Worksheet oxlsSheet = (Excel.Worksheet)oXlsBook.Sheets[1]; Excel.Range[] rng = new Microsoft.Office.Interop.Excel.Range[2]; try { // 確認のためExcelのウィンドウを表示する //oXls.Visible = true; //印刷 oXlsBook.PrintOut(1, Type.Missing, 1, false, sPrinter, Type.Missing, Type.Missing, Type.Missing); //// ウィンドウを非表示にする //oXls.Visible = false; //保存処理 //oXls.DisplayAlerts = false; // 終了メッセージ MessageBox.Show("発行が終了しました", "返信FAX", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception e) { MessageBox.Show(e.Message, "返信FAX", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { // ウィンドウを非表示にする oXls.Visible = false; // 保存処理 oXls.DisplayAlerts = false; // Bookをクローズ oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing); // Excelを終了 oXls.Quit(); // COMオブジェクトの参照カウントを解放する System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsSheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXlsBook); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXls); // カーソルをデフォルトへ戻す Cursor.Current = Cursors.Default; } } catch (Exception e) { MessageBox.Show(e.Message, "返信FAX発行処理", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
ArrayList list = null; //定义一个集合,保存向后台传入的值。 //“打印委托单”点击事件,1、打印委托单;2、式样号信息更新。 private void cmdReport_Click(object sender, EventArgs e) { if (ss1_Sheet1.RowCount <= 0) { return; } if (txt_smp_sent_no.Text == "") { GeneralCommon.Gp_MsgBoxDisplay("请输入委托单号,再打印!", "W", "提示"); return; } string modelName = "AGC2432C.xlsx"; GeneralCommon.Gp_CopyModel(modelName); string fileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + "report" + "\\" + modelName; Microsoft.Office.Interop.Excel.Application appExcel = null; appExcel = new Microsoft.Office.Interop.Excel.Application(); appExcel.DisplayAlerts = true; appExcel.AlertBeforeOverwriting = true; Microsoft.Office.Interop.Excel.Workbook workbook = appExcel.Workbooks.Open(fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); appExcel.Cells[2, 1] = "委托单号:" + txt_smp_sent_no.Text + " 工厂:" + PLT_NAME.Text; //appExcel.Cells[2, 4] = "工厂:" + PLT_NAME.Text; appExcel.Cells[4, 1] = ss1.ActiveSheet.Cells[0, 1].Text; //试样号 appExcel.Cells[4, 2] = ss1.ActiveSheet.Cells[0, 3].Text; //钢种 //appExcel.Cells[4, 3] = ss1.ActiveSheet.Cells[0, 4].Text; //规格 appExcel.Cells[4, 3] = ss1.ActiveSheet.Cells[0, 4].Text + ",数量:" + ss1.ActiveSheet.Cells[0, 5].Text; appExcel.Cells[4, 4] = ss1.ActiveSheet.Cells[0, 6].Text; //位置 appExcel.Cells[4, 5] = ss1.ActiveSheet.Cells[0, 54].Text; //拉伸a appExcel.Cells[4, 6] = ss1.ActiveSheet.Cells[0, 7].Text; //位置 appExcel.Cells[4, 7] = ss1.ActiveSheet.Cells[0, 55].Text; //拉伸b appExcel.Cells[4, 8] = ss1.ActiveSheet.Cells[0, 8].Text; //位置 appExcel.Cells[4, 9] = ss1.ActiveSheet.Cells[0, 56].Text; //拉伸c appExcel.Cells[4, 10] = ss1.ActiveSheet.Cells[0, 9].Text; //位置 appExcel.Cells[4, 11] = ss1.ActiveSheet.Cells[0, 57].Text; //拉伸d appExcel.Cells[4, 12] = ss1.ActiveSheet.Cells[0, 10].Text; //位置 appExcel.Cells[4, 13] = ss1.ActiveSheet.Cells[0, 58].Text; //拉伸e appExcel.Cells[4, 14] = ss1.ActiveSheet.Cells[0, 11].Text; //位置 appExcel.Cells[4, 15] = ss1.ActiveSheet.Cells[0, 59].Text; //拉伸f appExcel.Cells[4, 16] = ss1.ActiveSheet.Cells[0, 12].Text; //位置 appExcel.Cells[4, 17] = ss1.ActiveSheet.Cells[0, 60].Text; //高温拉伸g appExcel.Cells[4, 18] = ss1.ActiveSheet.Cells[0, 13].Text; //位置 appExcel.Cells[4, 19] = ss1.ActiveSheet.Cells[0, 61].Text; //高温拉伸h appExcel.Cells[4, 20] = ss1.ActiveSheet.Cells[0, 14].Text; //位置 appExcel.Cells[4, 21] = ss1.ActiveSheet.Cells[0, 62].Text; //高温拉伸i appExcel.Cells[4, 22] = ss1.ActiveSheet.Cells[0, 15].Text; //位置 appExcel.Cells[4, 23] = ss1.ActiveSheet.Cells[0, 63].Text; //高温拉伸j appExcel.Cells[4, 24] = ss1.ActiveSheet.Cells[0, 16].Text; //位置 appExcel.Cells[4, 25] = ss1.ActiveSheet.Cells[0, 64].Text; //高温拉伸k appExcel.Cells[4, 26] = ss1.ActiveSheet.Cells[0, 17].Text; //位置 appExcel.Cells[4, 27] = ss1.ActiveSheet.Cells[0, 65].Text; //高温拉伸l appExcel.Cells[6, 4] = ss1.ActiveSheet.Cells[0, 19].Text; //冲击a appExcel.Cells[6, 5] = ss1.ActiveSheet.Cells[0, 67].Text; //位置 appExcel.Cells[6, 6] = ss1.ActiveSheet.Cells[0, 20].Text; //位置 appExcel.Cells[6, 7] = ss1.ActiveSheet.Cells[0, 68].Text; //冲击b appExcel.Cells[6, 8] = ss1.ActiveSheet.Cells[0, 21].Text; //位置 appExcel.Cells[6, 9] = ss1.ActiveSheet.Cells[0, 69].Text; //冲击c appExcel.Cells[6, 10] = ss1.ActiveSheet.Cells[0, 22].Text; //位置 appExcel.Cells[6, 11] = ss1.ActiveSheet.Cells[0, 70].Text; //冲击d appExcel.Cells[6, 12] = ss1.ActiveSheet.Cells[0, 23].Text; //位置 appExcel.Cells[6, 13] = ss1.ActiveSheet.Cells[0, 71].Text; //冲击e appExcel.Cells[6, 14] = ss1.ActiveSheet.Cells[0, 24].Text; //位置 appExcel.Cells[6, 15] = ss1.ActiveSheet.Cells[0, 72].Text; //冲击f appExcel.Cells[6, 16] = ss1.ActiveSheet.Cells[0, 25].Text; //位置 appExcel.Cells[6, 17] = ss1.ActiveSheet.Cells[0, 73].Text; //时效冲击g appExcel.Cells[6, 18] = ss1.ActiveSheet.Cells[0, 26].Text; //位置 appExcel.Cells[6, 19] = ss1.ActiveSheet.Cells[0, 74].Text; //时效冲击h appExcel.Cells[6, 20] = ss1.ActiveSheet.Cells[0, 27].Text; //位置 appExcel.Cells[6, 21] = ss1.ActiveSheet.Cells[0, 75].Text; //时效冲击i appExcel.Cells[6, 22] = ss1.ActiveSheet.Cells[0, 28].Text; //位置 appExcel.Cells[6, 23] = ss1.ActiveSheet.Cells[0, 76].Text; //时效冲击j appExcel.Cells[6, 24] = ss1.ActiveSheet.Cells[0, 29].Text; //位置 appExcel.Cells[6, 25] = ss1.ActiveSheet.Cells[0, 77].Text; //时效冲击k appExcel.Cells[6, 26] = ss1.ActiveSheet.Cells[0, 30].Text; //位置 appExcel.Cells[6, 27] = ss1.ActiveSheet.Cells[0, 78].Text; //时效冲击l appExcel.Cells[8, 4] = ss1.ActiveSheet.Cells[0, 32].Text; //位置 appExcel.Cells[8, 5] = ss1.ActiveSheet.Cells[0, 80].Text; //Z向a appExcel.Cells[8, 6] = ss1.ActiveSheet.Cells[0, 33].Text; //位置 appExcel.Cells[8, 7] = ss1.ActiveSheet.Cells[0, 81].Text; //Z向b appExcel.Cells[8, 8] = ss1.ActiveSheet.Cells[0, 34].Text; //位置 appExcel.Cells[8, 9] = ss1.ActiveSheet.Cells[0, 82].Text; //Z向c appExcel.Cells[8, 10] = ss1.ActiveSheet.Cells[0, 35].Text; //位置 appExcel.Cells[8, 11] = ss1.ActiveSheet.Cells[0, 83].Text; //Z向d appExcel.Cells[8, 12] = ss1.ActiveSheet.Cells[0, 36].Text; //位置 appExcel.Cells[8, 13] = ss1.ActiveSheet.Cells[0, 84].Text; //Z向e appExcel.Cells[8, 14] = ss1.ActiveSheet.Cells[0, 37].Text; //位置 appExcel.Cells[8, 15] = ss1.ActiveSheet.Cells[0, 85].Text; //Z向f appExcel.Cells[8, 16] = ss1.ActiveSheet.Cells[0, 18].Text; //位置 appExcel.Cells[8, 17] = ss1.ActiveSheet.Cells[0, 66].Text; //弯曲a appExcel.Cells[8, 18] = ss1.ActiveSheet.Cells[0, 31].Text; //位置 appExcel.Cells[8, 19] = ss1.ActiveSheet.Cells[0, 79].Text; //硬度a appExcel.Cells[8, 20] = ss1.ActiveSheet.Cells[0, 44].Text; //位置 appExcel.Cells[8, 21] = ss1.ActiveSheet.Cells[0, 92].Text; //金相a appExcel.Cells[8, 22] = ss1.ActiveSheet.Cells[0, 45].Text; //位置 appExcel.Cells[8, 23] = ss1.ActiveSheet.Cells[0, 93].Text; //夹杂a appExcel.Cells[9, 1] = "备注:" + ss1.ActiveSheet.Cells[0, 46].Text; if (ss1_Sheet1.RowCount > 1) { appExcel.Cells[11, 1] = ss1.ActiveSheet.Cells[1, 1].Text; //试样号 appExcel.Cells[11, 2] = ss1.ActiveSheet.Cells[1, 3].Text; //钢种 appExcel.Cells[11, 3] = ss1.ActiveSheet.Cells[1, 4].Text + ",数量:" + ss1.ActiveSheet.Cells[0, 5].Text; //规格 appExcel.Cells[11, 4] = ss1.ActiveSheet.Cells[1, 6].Text; //位置 appExcel.Cells[11, 5] = ss1.ActiveSheet.Cells[1, 54].Text; //拉伸a appExcel.Cells[11, 6] = ss1.ActiveSheet.Cells[1, 7].Text; //位置 appExcel.Cells[11, 7] = ss1.ActiveSheet.Cells[1, 55].Text; //拉伸b appExcel.Cells[11, 8] = ss1.ActiveSheet.Cells[1, 8].Text; //位置 appExcel.Cells[11, 9] = ss1.ActiveSheet.Cells[1, 56].Text; //拉伸c appExcel.Cells[11, 10] = ss1.ActiveSheet.Cells[1, 9].Text; //位置 appExcel.Cells[11, 11] = ss1.ActiveSheet.Cells[1, 57].Text; //拉伸d appExcel.Cells[11, 12] = ss1.ActiveSheet.Cells[1, 10].Text; //位置 appExcel.Cells[11, 13] = ss1.ActiveSheet.Cells[1, 58].Text; //拉伸e appExcel.Cells[11, 14] = ss1.ActiveSheet.Cells[1, 11].Text; //位置 appExcel.Cells[11, 15] = ss1.ActiveSheet.Cells[1, 59].Text; //拉伸f appExcel.Cells[11, 16] = ss1.ActiveSheet.Cells[1, 12].Text; //位置 appExcel.Cells[11, 17] = ss1.ActiveSheet.Cells[1, 60].Text; //高温拉伸g appExcel.Cells[11, 18] = ss1.ActiveSheet.Cells[1, 13].Text; //位置 appExcel.Cells[11, 19] = ss1.ActiveSheet.Cells[1, 61].Text; //高温拉伸h appExcel.Cells[11, 20] = ss1.ActiveSheet.Cells[1, 14].Text; //位置 appExcel.Cells[11, 21] = ss1.ActiveSheet.Cells[1, 62].Text; //高温拉伸i appExcel.Cells[11, 22] = ss1.ActiveSheet.Cells[1, 15].Text; //位置 appExcel.Cells[11, 23] = ss1.ActiveSheet.Cells[1, 63].Text; //高温拉伸j appExcel.Cells[11, 24] = ss1.ActiveSheet.Cells[1, 16].Text; //位置 appExcel.Cells[11, 25] = ss1.ActiveSheet.Cells[1, 64].Text; //高温拉伸k appExcel.Cells[11, 26] = ss1.ActiveSheet.Cells[1, 17].Text; //位置 appExcel.Cells[11, 27] = ss1.ActiveSheet.Cells[1, 65].Text; //高温拉伸l appExcel.Cells[13, 4] = ss1.ActiveSheet.Cells[1, 19].Text; //位置 appExcel.Cells[13, 5] = ss1.ActiveSheet.Cells[1, 67].Text; //冲击a appExcel.Cells[13, 6] = ss1.ActiveSheet.Cells[1, 20].Text; //位置 appExcel.Cells[13, 7] = ss1.ActiveSheet.Cells[1, 68].Text; //冲击b appExcel.Cells[13, 8] = ss1.ActiveSheet.Cells[1, 21].Text; //位置 appExcel.Cells[13, 9] = ss1.ActiveSheet.Cells[1, 69].Text; //冲击c appExcel.Cells[13, 10] = ss1.ActiveSheet.Cells[1, 22].Text; //位置 appExcel.Cells[13, 11] = ss1.ActiveSheet.Cells[1, 70].Text; //冲击d appExcel.Cells[13, 12] = ss1.ActiveSheet.Cells[1, 23].Text; //位置 appExcel.Cells[13, 13] = ss1.ActiveSheet.Cells[1, 71].Text; //冲击e appExcel.Cells[13, 14] = ss1.ActiveSheet.Cells[1, 24].Text; //位置 appExcel.Cells[13, 15] = ss1.ActiveSheet.Cells[1, 72].Text; //冲击f appExcel.Cells[13, 16] = ss1.ActiveSheet.Cells[1, 25].Text; //位置 appExcel.Cells[13, 17] = ss1.ActiveSheet.Cells[1, 73].Text; //时效冲击g appExcel.Cells[13, 18] = ss1.ActiveSheet.Cells[1, 26].Text; //位置 appExcel.Cells[13, 19] = ss1.ActiveSheet.Cells[1, 74].Text; //时效冲击h appExcel.Cells[13, 20] = ss1.ActiveSheet.Cells[1, 27].Text; //位置 appExcel.Cells[13, 21] = ss1.ActiveSheet.Cells[1, 75].Text; //时效冲击i appExcel.Cells[13, 22] = ss1.ActiveSheet.Cells[1, 28].Text; //位置 appExcel.Cells[13, 23] = ss1.ActiveSheet.Cells[1, 76].Text; //时效冲击j appExcel.Cells[13, 24] = ss1.ActiveSheet.Cells[1, 29].Text; //位置 appExcel.Cells[13, 25] = ss1.ActiveSheet.Cells[1, 77].Text; //时效冲击k appExcel.Cells[13, 26] = ss1.ActiveSheet.Cells[1, 30].Text; //位置 appExcel.Cells[13, 27] = ss1.ActiveSheet.Cells[1, 78].Text; //时效冲击l appExcel.Cells[15, 4] = ss1.ActiveSheet.Cells[1, 32].Text; //位置 appExcel.Cells[15, 5] = ss1.ActiveSheet.Cells[1, 80].Text; //Z向a appExcel.Cells[15, 6] = ss1.ActiveSheet.Cells[1, 33].Text; //位置 appExcel.Cells[15, 7] = ss1.ActiveSheet.Cells[1, 81].Text; //Z向b appExcel.Cells[15, 8] = ss1.ActiveSheet.Cells[1, 34].Text; //位置 appExcel.Cells[15, 9] = ss1.ActiveSheet.Cells[1, 82].Text; //Z向c appExcel.Cells[15, 10] = ss1.ActiveSheet.Cells[1, 35].Text; //位置 appExcel.Cells[15, 11] = ss1.ActiveSheet.Cells[1, 83].Text; //Z向d appExcel.Cells[15, 12] = ss1.ActiveSheet.Cells[1, 36].Text; //位置 appExcel.Cells[15, 13] = ss1.ActiveSheet.Cells[1, 84].Text; //Z向e appExcel.Cells[15, 14] = ss1.ActiveSheet.Cells[1, 37].Text; //位置 appExcel.Cells[15, 15] = ss1.ActiveSheet.Cells[1, 85].Text; //Z向f appExcel.Cells[15, 16] = ss1.ActiveSheet.Cells[1, 18].Text; //位置 appExcel.Cells[15, 17] = ss1.ActiveSheet.Cells[1, 66].Text; //弯曲a appExcel.Cells[15, 18] = ss1.ActiveSheet.Cells[1, 31].Text; //位置 appExcel.Cells[15, 19] = ss1.ActiveSheet.Cells[1, 79].Text; //硬度a appExcel.Cells[15, 20] = ss1.ActiveSheet.Cells[1, 44].Text; //位置 appExcel.Cells[15, 21] = ss1.ActiveSheet.Cells[1, 92].Text; //金相a appExcel.Cells[15, 22] = ss1.ActiveSheet.Cells[1, 45].Text; //位置 appExcel.Cells[15, 23] = ss1.ActiveSheet.Cells[1, 93].Text; //夹杂a appExcel.Cells[16, 1] = "备注:" + ss1.ActiveSheet.Cells[1, 46].Text; } workbook.PrintOut(); appExcel.Visible = true; appExcel = null; string plsqlPackageName = "WGC3031C.P_SMODIFY1"; string informationText = "提示信息:试样号信息已更新...!!!"; list = new ArrayList(); //初始集合。 list.Add(txt_smp_sent_no.Text); //集合中添加值。 PRINT_Click2(plsqlPackageName, list, informationText); //式样号信息更新 }
///------------------------------------------------------------------ /// <summary> /// 人件費集計一覧表印刷 </summary> ///------------------------------------------------------------------ private void sReport() { //エクセルファイル日付明細開始行 const int S_GYO = 5; const int max_GYO = 53; int item_Gyo = max_GYO - S_GYO + 1; int pCnt = 1; int eRow = 0; int colorStatus = 1; string clrCode = string.Empty; try { //マウスポインタを待機にする this.Cursor = Cursors.WaitCursor; string sAppPath = System.AppDomain.CurrentDomain.BaseDirectory; Excel.Application oXls = new Excel.Application(); // 印刷用ブック Excel.Workbook oXlsBook = (Excel.Workbook)(oXls.Workbooks.Open(Properties.Settings.Default.sxlsPrnPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)); // テンプレートブック Excel.Workbook oXlsTempBook = (Excel.Workbook)(oXls.Workbooks.Open(Properties.Settings.Default.sxlsJinPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)); Excel.Worksheet oxls1 = (Excel.Worksheet)oXlsTempBook.Sheets[1]; // 人件費集計一覧表1ページ目 Excel.Worksheet oxls2 = (Excel.Worksheet)oXlsTempBook.Sheets[2]; // 人件費集計一覧表2ページ以降 Excel.Worksheet oxlsPrintSheet = null; // 印刷用ワークシート Excel.Range[] rng = new Microsoft.Office.Interop.Excel.Range[2]; string Category = string.Empty; try { // 印刷用BOOKへシートを追加する oxls1.Copy(Type.Missing, oXlsBook.Sheets[pCnt]); // カレントのシートを設定 oxlsPrintSheet = (Excel.Worksheet)oXlsBook.Sheets[pCnt + 1]; // ヘッダ //string tittle1 = Properties.Settings.Default.gengou + txtYear.Text + "年 " + txtMonth.Text + "月分"; string tittle1 = txtYear.Text + "年 " + txtMonth.Text + "月分"; oxlsPrintSheet.Cells[1, 2] = tittle1; string tittle2 = "土木部員配置&人件費集計一覧表"; if (radioButton1.Checked) { tittle2 += "(個人毎)"; } else { tittle2 += "(工事毎)"; } oxlsPrintSheet.Cells[2, 2] = tittle2; //グリッドを順番に読む for (int i = 0; i < dg.RowCount; i++) { // ページカウント int p = 0; if (((i + 1) % item_Gyo) > 0) { p = (i + 1) / item_Gyo + 1; } else { p = (i + 1) / item_Gyo; } // 新しいページ? if (pCnt != p) { // ページカウント pCnt = p; // 2ページ以降シートを追加する oxls2.Copy(Type.Missing, oXlsBook.Sheets[pCnt]); oxlsPrintSheet = (Excel.Worksheet)oXlsBook.Sheets[pCnt + 1]; } // 印字行 eRow = S_GYO + (i - (item_Gyo * (pCnt - 1))); // セルに値をセット oxlsPrintSheet.Cells[eRow, 1] = dg[cNum, i].Value.ToString(); // 個人コード oxlsPrintSheet.Cells[eRow, 2] = dg[cName, i].Value.ToString(); // 個人名 oxlsPrintSheet.Cells[eRow, 3] = dg[cKID, i].Value.ToString(); // 工事コード oxlsPrintSheet.Cells[eRow, 4] = dg[cKName, i].Value.ToString(); // 工事名 oxlsPrintSheet.Cells[eRow, 5] = dg[cJinkenhi, i].Value.ToString(); // 人件費 oxlsPrintSheet.Cells[eRow, 6] = dg[cHaichiDays, i].Value.ToString(); // 配置日数 oxlsPrintSheet.Cells[eRow, 7] = dg[cGenbaDays, i].Value.ToString(); // 現場 oxlsPrintSheet.Cells[eRow, 8] = dg[cKinmuchiDays, i].Value.ToString(); // 勤務地 oxlsPrintSheet.Cells[eRow, 9] = dg[cStayDays, i].Value.ToString(); // 宿泊 oxlsPrintSheet.Cells[eRow, 10] = dg[cHolTM, i].Value.ToString(); // 休日出勤時間 oxlsPrintSheet.Cells[eRow, 11] = dg[cHouteiTM, i].Value.ToString(); // 法定休日勤務時間 oxlsPrintSheet.Cells[eRow, 12] = dg[cZanTM, i].Value.ToString(); // 残業時間 oxlsPrintSheet.Cells[eRow, 13] = dg[cSiTM, i].Value.ToString(); // 深夜残業 oxlsPrintSheet.Cells[eRow, 14] = dg[cJyosetsu, i].Value.ToString(); // 除雪手当 oxlsPrintSheet.Cells[eRow, 15] = dg[cTokushu, i].Value.ToString(); // 特殊勤務 oxlsPrintSheet.Cells[eRow, 16] = dg[cTooshi, i].Value.ToString(); // 通し勤務 oxlsPrintSheet.Cells[eRow, 17] = dg[cYakan, i].Value.ToString(); // 夜間手当 oxlsPrintSheet.Cells[eRow, 18] = dg[cShokumu, i].Value.ToString(); // 職務手当 if (radioButton1.Checked) { if (clrCode != dg[cNum, i].Value.ToString()) { clrCode = dg[cNum, i].Value.ToString(); colorStatus *= -1; } } else { if (clrCode != dg[cKID, i].Value.ToString()) { clrCode = dg[cKID, i].Value.ToString(); colorStatus *= -1; } } // 網掛け if (colorStatus == -1) { rng[0] = (Excel.Range)oxlsPrintSheet.Cells[eRow, 1]; rng[1] = (Excel.Range)oxlsPrintSheet.Cells[eRow, 9]; oxlsPrintSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.LightBlue; } } //マウスポインタを元に戻す this.Cursor = Cursors.Default; // 印刷用BOOKの1番目のシートは削除する ((Excel.Worksheet)oXlsBook.Sheets[1]).Delete(); // 確認のためのウィンドウを表示する oXls.Visible = true; //印刷 //oXlsBook.PrintPreview(true); oXlsBook.PrintOut(); //保存処理 oXls.DisplayAlerts = false; //Bookをクローズ oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing); //Excelを終了 oXls.Quit(); } catch (Exception e) { MessageBox.Show(e.Message, "印刷処理", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // ウィンドウを非表示にする oXls.Visible = false; //保存処理 oXls.DisplayAlerts = false; //Bookをクローズ oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing); //Excelを終了 oXls.Quit(); } finally { // COM オブジェクトの参照カウントを解放する System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsPrintSheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXlsBook); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXls); //マウスポインタを元に戻す this.Cursor = Cursors.Default; } } catch (Exception e) { MessageBox.Show(e.Message, "印刷処理", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //マウスポインタを元に戻す this.Cursor = Cursors.Default; }
///------------------------------------------------------------------ /// <summary> /// 出勤簿印刷・シート追加一括印刷 </summary> ///------------------------------------------------------------------ private void sReport() { const int S_GYO = 7; //エクセルファイル日付明細開始行 //開始日付 int StartDay = 1; //終了日付 int EndDay = DateTime.DaysInMonth(int.Parse(txtYear.Text) + Utility.GetRekiHosei(), int.Parse(txtMonth.Text)); string sDate; DateTime eDate; //////const int S_ROWSMAX = 7; //エクセルファイル列最大値 try { //マウスポインタを待機にする this.Cursor = Cursors.WaitCursor; string sAppPath = System.AppDomain.CurrentDomain.BaseDirectory; Excel.Application oXls = new Excel.Application(); Excel.Workbook oXlsBook = (Excel.Workbook)(oXls.Workbooks.Open(Properties.Settings.Default.OCR出勤簿シートパス, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)); Excel.Worksheet oxlsSheet = (Excel.Worksheet)oXlsBook.Sheets[1]; Excel.Range[] rng = new Microsoft.Office.Interop.Excel.Range[2]; try { // 休日配列インスタンス化 Config.Holiday[] Holiday = new Config.Holiday[1]; Holiday[0] = new Config.Holiday(); Holiday[0].hDate = DateTime.Parse("1900/01/01"); // ローカルデータベース接続 SysControl.SetDBConnect Con = new SysControl.SetDBConnect(); OleDbCommand sCom = new OleDbCommand(); sCom.Connection = Con.cnOpen(); OleDbDataReader dR; // 休日データを配列に読み込む int iH = 0; string sqlSTRING = string.Empty; sqlSTRING += "select * from 休日 order by 年月日"; sCom.CommandText = sqlSTRING; dR = sCom.ExecuteReader(); while (dR.Read()) { if (iH > 0) { Array.Resize(ref Holiday, iH + 1); // 配列要素数追加 Holiday[iH] = new Config.Holiday(); // 休日配列インスタンス化 } Holiday[iH].hDate = DateTime.Parse(dR["年月日"].ToString()); if (dR["月給者"].ToString() == "1") { Holiday[iH].Gekkyuu = true; } else { Holiday[iH].Gekkyuu = false; } if (dR["時給者"].ToString() == "1") { Holiday[iH].Jikyuu = true; } else { Holiday[iH].Jikyuu = false; } iH++; } dR.Close(); sCom.Connection.Close(); // ページカウント int pCnt = 0; //// 有給記号非表示設定 : 2017/11/27 //Excel.TextBox t34 = oxlsSheet.TextBoxes("Text Box 32"); //t34.Visible = false; //oxlsSheet.Cells[5, 5] = string.Empty; // パートのとき有給記号非表示設定 : 2017/11/30 if (_YakushokuType == global.STATUS_PART) { Excel.TextBox t34 = oxlsSheet.TextBoxes("Text Box 32"); t34.Visible = false; oxlsSheet.Cells[5, 5] = string.Empty; } //Excel.TextBox t14 = oxlsSheet.TextBoxes("テキスト 14"); //t14.Visible = false; //Excel.TextBox t34 = oxlsSheet.TextBoxes("yukyukigo"); //Excel.TextBox t14 = oxlsSheet.TextBoxes("kyukakigo"); //if (_tBoxStatus) //{ // t34.Visible = false; // t14.Visible = false; // oxlsSheet.Cells[5, 5] = string.Empty; //} //else //{ // t34.Visible = true; // t14.Visible = true; // oxlsSheet.Cells[5, 5] = "有給"; //} // グリッドを順番に読む for (int i = 0; i < dg1.RowCount; i++) { // チェックがあるものを対象とする if (dg1[0, i].Value.ToString() == "True") { // 印刷2件目以降はシートを追加する pCnt++; if (pCnt > 1) { oxlsSheet.Copy(Type.Missing, oXlsBook.Sheets[pCnt - 1]); oxlsSheet = (Excel.Worksheet)oXlsBook.Sheets[pCnt]; } int sRow = i; // 帳票区分(1:メイン勤務出勤簿、2:サブ勤務出勤簿) // 配列から取得 2017/05/17 //if (radioButton1.Checked) //{ // oxlsSheet.Cells[2, 1] = PR_STATUS_MAIN.ToString(); //} //else //{ // oxlsSheet.Cells[2, 1] = PR_STATUS_SUB.ToString(); //} oxlsSheet.Cells[2, 1] = dg1[5, sRow].Value.ToString(); // 年 oxlsSheet.Cells[3, 4] = string.Format("{0, 2}", int.Parse(txtYear.Text)).Substring(0, 1); oxlsSheet.Cells[3, 5] = string.Format("{0, 2}", int.Parse(txtYear.Text)).Substring(1, 1); // 月 oxlsSheet.Cells[3, 8] = string.Format("{0, 2}", int.Parse(txtMonth.Text)).Substring(0, 1); oxlsSheet.Cells[3, 9] = string.Format("{0, 2}", int.Parse(txtMonth.Text)).Substring(1, 1); // 所属名 oxlsSheet.Cells[3, 15] = dg1[2, sRow].Value.ToString(); // 所属コード string szCode = dg1[1, sRow].Value.ToString().PadLeft(global.ShozokuMaxLength, ' '); for (int ci = 0; ci < szCode.Length; ci++) { oxlsSheet.Cells[3, 25 + ci] = szCode.Substring(ci, 1); } //oxlsSheet.Cells[3, 27] = dg1[1, sRow].Value.ToString().Substring(0, 1); //oxlsSheet.Cells[3, 28] = dg1[1, sRow].Value.ToString().Substring(1, 1); //oxlsSheet.Cells[3, 29] = dg1[1, sRow].Value.ToString().Substring(2, 1); // 社員番号 //for (int ci = 0; ci < global.ShainLength; ci++) //{ // oxlsSheet.Cells[2, 25 + ci] = dg1[3, sRow].Value.ToString().Substring(ci, 1); //} oxlsSheet.Cells[2, 25] = dg1[3, sRow].Value.ToString().Substring(0, 1); oxlsSheet.Cells[2, 26] = dg1[3, sRow].Value.ToString().Substring(1, 1); oxlsSheet.Cells[2, 27] = dg1[3, sRow].Value.ToString().Substring(2, 1); oxlsSheet.Cells[2, 28] = dg1[3, sRow].Value.ToString().Substring(3, 1); oxlsSheet.Cells[2, 29] = dg1[3, sRow].Value.ToString().Substring(4, 1); // 氏名 oxlsSheet.Cells[2, 15] = dg1[4, sRow].Value.ToString(); // 日付 int addRow = 0; for (int iX = StartDay; iX <= EndDay; iX++) { // 暦補正値は設定ファイルから取得する sDate = (int.Parse(txtYear.Text) + Utility.GetRekiHosei()).ToString() + "/" + txtMonth.Text + "/" + iX.ToString(); eDate = DateTime.Parse(sDate); oxlsSheet.Cells[S_GYO + addRow, 2] = ("日月火水木金土").Substring(int.Parse(eDate.DayOfWeek.ToString("d")), 1); rng[0] = (Excel.Range)oxlsSheet.Cells[S_GYO + addRow, 1]; rng[1] = (Excel.Range)oxlsSheet.Cells[S_GYO + addRow, 2]; // 日曜日なら曜日の背景色を変える if (rng[1].Text.ToString() == "日") { oxlsSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.LightGray; } // 祝祭日なら曜日の背景色を変える for (int j = 0; j < Holiday.Length; j++) { // 休日登録されている if (Holiday[j].hDate == eDate) { // 月給者または時給者が各々休日対象となっている if (dg1[5, sRow].Value.ToString() == "社員" && Holiday[j].Gekkyuu == true || dg1[5, sRow].Value.ToString() == "パート" && Holiday[j].Jikyuu == true) { oxlsSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.LightGray; break; } else { oxlsSheet.get_Range(rng[0], rng[1]).Interior.Color = Color.White; } } } // 行数加算 addRow++; } } } // マウスポインタを元に戻す this.Cursor = Cursors.Default; // 確認のためExcelのウィンドウを表示する //oXls.Visible = true; // 印刷 oXlsBook.PrintOut(); // ウィンドウを非表示にする oXls.Visible = false; // 保存処理 oXls.DisplayAlerts = false; // Bookをクローズ oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing); // Excelを終了 oXls.Quit(); } catch (Exception e) { MessageBox.Show(e.Message, "印刷処理", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // ウィンドウを非表示にする oXls.Visible = false; // 保存処理 oXls.DisplayAlerts = false; // Bookをクローズ oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing); // Excelを終了 oXls.Quit(); } finally { // COM オブジェクトの参照カウントを解放する System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsSheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXlsBook); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXls); //マウスポインタを元に戻す this.Cursor = Cursors.Default; } } catch (Exception e) { MessageBox.Show(e.Message, "印刷処理", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // マウスポインタを元に戻す this.Cursor = Cursors.Default; }
///---------------------------------------------------------------------- /// <summary> /// 出勤簿印刷処理 </summary> /// <param name="dg"> /// DataGridViewオブジェクト</param> ///---------------------------------------------------------------------- private void prnSheet(DataGridView dg) { string kihonWorkTime = Properties.Settings.Default.基本実労時 + Properties.Settings.Default.基本実労分.PadLeft(2, '0'); // 印刷開始月 DateTime nDt; // 印刷終了月 DateTime eDt = DateTime.Parse(txtEyear.Text + "/" + txtEmonth.Text + "/01"); DateTime zDt; //マウスポインタを待機にする this.Cursor = Cursors.WaitCursor; // Excel起動 string sAppPath = System.AppDomain.CurrentDomain.BaseDirectory; Excel.Application oXls = new Excel.Application(); Excel.Workbook oXlsBook = (Excel.Workbook)(oXls.Workbooks.Open(Properties.Settings.Default.xlsFAX出勤簿, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)); Excel.Worksheet oxlsSheet = (Excel.Worksheet)oXlsBook.Sheets[1]; Excel.Worksheet oxlsMsSheet = (Excel.Worksheet)oXlsBook.Sheets[1]; // テンプレートシート oxlsSheet.Select(Type.Missing); Excel.Range rng = null; Excel.Range[] aRng = new Excel.Range[3]; int pCnt = 1; // ページカウント object[,] rtnArray = null; try { // スタッフ foreach (DataGridViewRow r in dg.Rows) { // チェックされているスタッフを対象とする if (dataGridView1[colChk, r.Index].Value.ToString() == "False") { continue; } nDt = DateTime.Parse(txtSyear.Text + "/" + txtSmonth.Text + "/01"); // 年月指定範囲でループさせる while (true) { // テンプレートシートを追加する pCnt++; oxlsMsSheet.Copy(Type.Missing, oXlsBook.Sheets[pCnt - 1]); oxlsSheet = (Excel.Worksheet)oXlsBook.Sheets[pCnt]; // シートのセルを一括して配列に取得します rng = oxlsMsSheet.Range[oxlsMsSheet.Cells[1, 1], oxlsMsSheet.Cells[oxlsMsSheet.UsedRange.Rows.Count, oxlsMsSheet.UsedRange.Columns.Count]]; rtnArray = (object[, ])rng.Value2; // 年 rtnArray[3, 14] = nDt.Year.ToString().Substring(2, 1); rtnArray[3, 20] = nDt.Year.ToString().Substring(3, 1); // 月 rtnArray[3, 32] = nDt.Month.ToString().PadLeft(2, '0').Substring(0, 1); rtnArray[3, 38] = nDt.Month.ToString().PadLeft(2, '0').Substring(1, 1); // 氏名 rtnArray[5, 18] = dg[colSName, r.Index].Value.ToString(); // スタッフ№ rtnArray[6, 106] = dg[colSCode, r.Index].Value.ToString().Substring(0, 1); rtnArray[6, 112] = dg[colSCode, r.Index].Value.ToString().Substring(1, 1); rtnArray[6, 118] = dg[colSCode, r.Index].Value.ToString().Substring(2, 1); rtnArray[6, 124] = dg[colSCode, r.Index].Value.ToString().Substring(3, 1); rtnArray[6, 130] = dg[colSCode, r.Index].Value.ToString().Substring(4, 1); // 日給者 if (dg[colKyuyoKbn, r.Index].Value.ToString() == global.NIKKYU) { // 基本労働時間 if (dg[colWorkTime, r.Index].Value.ToString() != string.Empty) { rtnArray[6, 169] = dg[colWorkTime, r.Index].Value.ToString().Substring(1, 1); rtnArray[6, 175] = dg[colWorkTime, r.Index].Value.ToString().Substring(3, 1); rtnArray[6, 181] = dg[colWorkTime, r.Index].Value.ToString().Substring(4, 1); } // 基本就業時間帯1 string tm = dg[colTime1, r.Index].Value.ToString(); if (tm.Length > 10) { rtnArray[18, 29] = tm.Substring(0, 1); rtnArray[18, 35] = tm.Substring(1, 1); rtnArray[18, 41] = tm.Substring(3, 1); rtnArray[18, 47] = tm.Substring(4, 1); rtnArray[18, 57] = tm.Substring(6, 1); rtnArray[18, 63] = tm.Substring(7, 1); rtnArray[18, 69] = tm.Substring(9, 1); rtnArray[18, 75] = tm.Substring(10, 1); } // 基本就業時間帯2 tm = dg[colTime2, r.Index].Value.ToString(); if (tm.Length > 10) { rtnArray[18, 88] = tm.Substring(0, 1); rtnArray[18, 94] = tm.Substring(1, 1); rtnArray[18, 100] = tm.Substring(3, 1); rtnArray[18, 106] = tm.Substring(4, 1); rtnArray[18, 116] = tm.Substring(6, 1); rtnArray[18, 122] = tm.Substring(7, 1); rtnArray[18, 128] = tm.Substring(9, 1); rtnArray[18, 134] = tm.Substring(10, 1); } // 基本就業時間帯3 tm = dg[colTime3, r.Index].Value.ToString(); if (tm.Length > 10) { rtnArray[18, 147] = tm.Substring(0, 1); rtnArray[18, 153] = tm.Substring(1, 1); rtnArray[18, 159] = tm.Substring(3, 1); rtnArray[18, 165] = tm.Substring(4, 1); rtnArray[18, 175] = tm.Substring(6, 1); rtnArray[18, 181] = tm.Substring(7, 1); rtnArray[18, 187] = tm.Substring(9, 1); rtnArray[18, 193] = tm.Substring(10, 1); } } else if (dg[colKyuyoKbn, r.Index].Value.ToString() == global.JIKKYU) // 時給者 { // 基本労働時間 rtnArray[6, 169] = "*"; rtnArray[6, 175] = "*"; rtnArray[6, 181] = "*"; // 基本就業時間帯1 rtnArray[18, 29] = "*"; rtnArray[18, 35] = "*"; rtnArray[18, 41] = "*"; rtnArray[18, 47] = "*"; rtnArray[18, 57] = "*"; rtnArray[18, 63] = "*"; rtnArray[18, 69] = "*"; rtnArray[18, 75] = "*"; // 基本就業時間帯2 rtnArray[18, 88] = "*"; rtnArray[18, 94] = "*"; rtnArray[18, 100] = "*"; rtnArray[18, 106] = "*"; rtnArray[18, 116] = "*"; rtnArray[18, 122] = "*"; rtnArray[18, 128] = "*"; rtnArray[18, 134] = "*"; // 基本就業時間帯3 rtnArray[18, 147] = "*"; rtnArray[18, 153] = "*"; rtnArray[18, 159] = "*"; rtnArray[18, 165] = "*"; rtnArray[18, 175] = "*"; rtnArray[18, 181] = "*"; rtnArray[18, 187] = "*"; rtnArray[18, 193] = "*"; } // 所属店名 rtnArray[11, 25] = dg[colShopName, r.Index].Value.ToString(); // 所属店コード rtnArray[12, 169] = dg[colShopCode, r.Index].Value.ToString().Substring(0, 1); rtnArray[12, 175] = dg[colShopCode, r.Index].Value.ToString().Substring(1, 1); rtnArray[12, 181] = dg[colShopCode, r.Index].Value.ToString().Substring(2, 1); rtnArray[12, 187] = dg[colShopCode, r.Index].Value.ToString().Substring(3, 1); rtnArray[12, 193] = dg[colShopCode, r.Index].Value.ToString().Substring(4, 1); // 開始月 zDt = nDt.AddMonths(-1); // 締日 string shime = dg[colShimebi, r.Index].Value.ToString(); if (shime != global.SHIME_15 && shime != global.SHIME_20) { // 締日記入がないものは15日締とする shime = global.SHIME_15; } // 締日による制御 if (shime == global.SHIME_15) { // 15日締 // 締切文言 rtnArray[25, 103] = "※ 締切 毎月16日~翌15日 ※ 送信締切日:17日迄"; // 訂正欄月区切り罫線 aRng[0] = (Excel.Range)oxlsSheet.Cells[128, 111]; aRng[1] = (Excel.Range)oxlsSheet.Cells[130, 111]; oxlsSheet.get_Range(aRng[0], aRng[1]).Borders.get_Item(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlLineStyle.xlContinuous; // 訂正欄月表示 rtnArray[128, 57] = zDt.Month.ToString(); rtnArray[128, 63] = "月"; rtnArray[128, 147] = nDt.Month.ToString(); rtnArray[128, 153] = "月"; } else { // 20日締 // 締切文言 rtnArray[25, 103] = "※ 締切 毎月21日~翌20日 ※ 送信締切日:22日迄"; // 訂正欄月区切り罫線 aRng[0] = (Excel.Range)oxlsSheet.Cells[128, 81]; aRng[1] = (Excel.Range)oxlsSheet.Cells[130, 81]; oxlsSheet.get_Range(aRng[0], aRng[1]).Borders.get_Item(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlLineStyle.xlContinuous; // 訂正欄月表示 rtnArray[128, 39] = zDt.Month.ToString(); rtnArray[128, 45] = "月"; rtnArray[128, 135] = nDt.Month.ToString(); rtnArray[128, 141] = "月"; } // 日付配列クラスを作成 clsDays cld = new clsDays(); setDayArray(cld, shime, zDt, nDt); // 日付をセット setDayToSheet(rtnArray, cld); // 下部日付欄をセット setDayToSheet2(rtnArray, cld, oxlsSheet); // 配列からシートセルに一括してデータをセットします rng = oxlsSheet.Range[oxlsSheet.Cells[1, 1], oxlsSheet.Cells[oxlsSheet.UsedRange.Rows.Count, oxlsSheet.UsedRange.Columns.Count]]; rng.Value2 = rtnArray; // 年月範囲を超えたらループからぬける nDt = nDt.AddMonths(1); bool nxt = true; switch (nDt.CompareTo(eDt)) { case -1: // 期限内 nxt = true; break; case 0: // 期限日と同日 nxt = true; break; case 1: // 期限日超過 nxt = false; break; } if (!nxt) { break; } } } // 確認のためExcelのウィンドウを表示する //oXls.Visible = true; // 1枚目はテンプレートシートなので印刷時には削除する oXls.DisplayAlerts = false; oXlsBook.Sheets[1].Delete(); //System.Threading.Thread.Sleep(1000); // 印刷 oXlsBook.PrintOut(); // 終了メッセージ MessageBox.Show("終了しました"); } catch (Exception e) { MessageBox.Show(e.Message, "印刷処理", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { // ウィンドウを非表示にする oXls.Visible = false; // 保存処理 oXls.DisplayAlerts = false; // Bookをクローズ oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing); // Excelを終了 oXls.Quit(); // COM オブジェクトの参照カウントを解放する System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsMsSheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsSheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXlsBook); System.Runtime.InteropServices.Marshal.ReleaseComObject(oXls); oXls = null; oXlsBook = null; oxlsSheet = null; oxlsMsSheet = null; GC.Collect(); //マウスポインタを元に戻す this.Cursor = Cursors.Default; } }
//打印委托单。 private void SAMPLE_SEND_PRINT(object[,] ArrayRecords) { if (TXT_CUT_PLT.Text == "") { if (txt_DH_FL.Checked) { TXT_CUT_PLT.Text = "热处理" + txt_line.Text; } else { TXT_CUT_PLT.Text = GeneralCommon.Gf_ComnNameFind(GeneralCommon.M_CN1, "C0001", txt_plt.Text, 1); } } if (null == ArrayRecords)//假如数组为空,返回 { GeneralCommon.Gp_MsgBoxDisplay("该委托单号没有数据...!", "I", "提示"); return; } object[,] ArrayRecordInputExcel = null; //定义一个二维数组,存储写入Excel表格数据。 ArrayRecordInputExcel = new object[RsRowCount, 23]; //初始化二维数组,列共有21,行根据后台传入的多少条记录赋值。 //从ArrayRecords二维数组中选取需要的数据,传入ArrayRecordInputExcel二维数组中 for (int i = 0; i < RsRowCount; i++) { ArrayRecordInputExcel[i, 0] = i + 1; ArrayRecordInputExcel[i, 1] = ArrayRecords[i, 1]; ArrayRecordInputExcel[i, 2] = ArrayRecords[i, 2]; ArrayRecordInputExcel[i, 3] = ArrayRecords[i, 3]; ArrayRecordInputExcel[i, 4] = ArrayRecords[i, 4]; ArrayRecordInputExcel[i, 5] = ArrayRecords[i, 5]; ArrayRecordInputExcel[i, 6] = ArrayRecords[i, 6]; ArrayRecordInputExcel[i, 7] = ArrayRecords[i, 7]; ArrayRecordInputExcel[i, 8] = ArrayRecords[i, 8]; ArrayRecordInputExcel[i, 9] = ArrayRecords[i, 9]; ArrayRecordInputExcel[i, 10] = ArrayRecords[i, 10]; ArrayRecordInputExcel[i, 11] = ArrayRecords[i, 11]; ArrayRecordInputExcel[i, 12] = ArrayRecords[i, 12]; ArrayRecordInputExcel[i, 13] = ArrayRecords[i, 13]; ArrayRecordInputExcel[i, 14] = ArrayRecords[i, 14]; ArrayRecordInputExcel[i, 15] = ArrayRecords[i, 15]; ArrayRecordInputExcel[i, 16] = ArrayRecords[i, 41];//H ArrayRecordInputExcel[i, 17] = ArrayRecords[i, 16]; ArrayRecordInputExcel[i, 18] = ArrayRecords[i, 17]; ArrayRecordInputExcel[i, 19] = ArrayRecords[i, 38]; ArrayRecordInputExcel[i, 20] = ArrayRecords[i, 42]; ArrayRecordInputExcel[i, 21] = ArrayRecords[i, 18]; if (ArrayRecords[i, 26].ToString() != "") { ArrayRecordInputExcel[i, 22] = "屈服类型:" + ArrayRecords[i, 26].ToString(); } else if (ArrayRecords[i, 27].ToString() != "") { ArrayRecordInputExcel[i, 22] = "追加屈服类型:" + ArrayRecords[i, 27].ToString(); } else if (ArrayRecords[i, 28].ToString() != "") { ArrayRecordInputExcel[i, 22] = "高温屈服类型:" + ArrayRecords[i, 28].ToString(); } else if (ArrayRecords[i, 29].ToString() != "") { ArrayRecordInputExcel[i, 22] = "追加高温屈服类型:" + ArrayRecords[i, 29].ToString(); } else if (ArrayRecords[i, 30].ToString() != "") { ArrayRecordInputExcel[i, 22] = "冲击开槽:" + ArrayRecords[i, 30].ToString(); } else if (ArrayRecords[i, 31].ToString() != "") { ArrayRecordInputExcel[i, 22] = "追加冲击开槽:" + ArrayRecords[i, 31].ToString(); } else if (ArrayRecords[i, 32].ToString() != "") { ArrayRecordInputExcel[i, 22] = "时效冲击开槽:" + ArrayRecords[i, 32].ToString(); } else if (ArrayRecords[i, 33].ToString() != "") { ArrayRecordInputExcel[i, 22] = "追加时效冲击开槽:" + ArrayRecords[i, 33].ToString(); } else if (ArrayRecords[i, 34].ToString() != "") { ArrayRecordInputExcel[i, 22] = "冲击尺寸:" + ArrayRecords[i, 34].ToString(); } else if (ArrayRecords[i, 35].ToString() != "") { ArrayRecordInputExcel[i, 22] = "追加冲击尺寸:" + ArrayRecords[i, 35].ToString(); } else if (ArrayRecords[i, 36].ToString() != "") { ArrayRecordInputExcel[i, 22] = "时效冲击尺寸:" + ArrayRecords[i, 36].ToString(); } else if (ArrayRecords[i, 37].ToString() != "") { ArrayRecordInputExcel[i, 22] = "追加时效冲击尺寸:" + ArrayRecords[i, 37].ToString(); } else if (ArrayRecords[i, 39].ToString() != "") { ArrayRecordInputExcel[i, 22] = "HIC试验标准:" + ArrayRecords[i, 39].ToString(); } else if (ArrayRecords[i, 40].ToString() != "") { ArrayRecordInputExcel[i, 22] = "溶液类型:" + ArrayRecords[i, 40].ToString(); } else { ArrayRecordInputExcel[i, 22] = ""; } } string dateInputExcel = curDateExcel.Substring(0, 4) + "-" + curDateExcel.Substring(4, 2) + "-" + curDateExcel.Substring(6, 2) + " " + curDateExcel.Substring(8, 2) + ":" + curDateExcel.Substring(10, 2) + ":" + curDateExcel.Substring(12, 2); string modelName = "AGC2430C.xls"; GeneralCommon.Gp_CopyModel(modelName); string fileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + "report" + "\\" + modelName; Microsoft.Office.Interop.Excel.Application appExcel = null; appExcel = new Microsoft.Office.Interop.Excel.Application(); appExcel.DisplayAlerts = true; appExcel.AlertBeforeOverwriting = true; Microsoft.Office.Interop.Excel.Workbook workbook = appExcel.Workbooks.Open(fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); Microsoft.Office.Interop.Excel.Range range = null; Worksheet worksheet1 = null; worksheet1 = (Worksheet)workbook.Sheets[1]; appExcel.Cells[3, 1] = "委托单号:" + txt_smp_sent_no.Text; appExcel.Cells[4, 1] = "委托单位:" + TXT_CUT_PLT.Text; string excelDate = curDate.Substring(0, 4) + "年" + curDate.Substring(4, 2) + "月" + curDate.Substring(6, 2) + "日"; appExcel.Cells[4, 2] = excelDate; for (int i = 0; i < RsRowCount; i++) { appExcel.Cells[7 + i, 1] = ArrayRecordInputExcel[i, 0].ToString(); appExcel.Cells[7 + i, 2] = ArrayRecordInputExcel[i, 1].ToString(); appExcel.Cells[7 + i, 3] = ArrayRecordInputExcel[i, 2].ToString(); appExcel.Cells[7 + i, 4] = ArrayRecordInputExcel[i, 3].ToString(); appExcel.Cells[7 + i, 5] = ArrayRecordInputExcel[i, 4].ToString(); appExcel.Cells[7 + i, 6] = ArrayRecordInputExcel[i, 5].ToString(); appExcel.Cells[7 + i, 7] = ArrayRecordInputExcel[i, 6].ToString(); appExcel.Cells[7 + i, 8] = ArrayRecordInputExcel[i, 7].ToString(); appExcel.Cells[7 + i, 9] = ArrayRecordInputExcel[i, 8].ToString(); appExcel.Cells[7 + i, 10] = ArrayRecordInputExcel[i, 9].ToString(); appExcel.Cells[7 + i, 11] = ArrayRecordInputExcel[i, 10].ToString(); appExcel.Cells[7 + i, 12] = ArrayRecordInputExcel[i, 11].ToString(); appExcel.Cells[7 + i, 13] = ArrayRecordInputExcel[i, 12].ToString(); appExcel.Cells[7 + i, 14] = ArrayRecordInputExcel[i, 13].ToString(); appExcel.Cells[7 + i, 15] = ArrayRecordInputExcel[i, 14].ToString(); appExcel.Cells[7 + i, 16] = ArrayRecordInputExcel[i, 15].ToString(); appExcel.Cells[7 + i, 17] = ArrayRecordInputExcel[i, 16].ToString(); appExcel.Cells[7 + i, 18] = ArrayRecordInputExcel[i, 17].ToString(); appExcel.Cells[7 + i, 19] = ArrayRecordInputExcel[i, 18].ToString(); appExcel.Cells[7 + i, 20] = ArrayRecordInputExcel[i, 19].ToString(); appExcel.Cells[7 + i, 21] = ArrayRecordInputExcel[i, 20].ToString(); appExcel.Cells[7 + i, 22] = ArrayRecordInputExcel[i, 21].ToString(); appExcel.Cells[7 + i, 23] = ArrayRecordInputExcel[i, 22].ToString(); range = (Microsoft.Office.Interop.Excel.Range)worksheet1.get_Range("A" + (7 + i), "W" + (7 + i)); range.Borders.LineStyle = 1; } appExcel.Cells[7 + RsRowCount, 2] = "委托人:" + GeneralCommon.sUsername; appExcel.Cells[7 + RsRowCount, 4] = "委托时间:" + dateInputExcel; appExcel.Cells[7 + RsRowCount, 9] = "送样人:"; appExcel.Cells[7 + RsRowCount, 14] = "送样时间:"; workbook.PrintOut(); appExcel.Visible = true; ////appExcel.Quit();//从内存中退出 appExcel = null; }