private void ExportSingle( DateTime startDate, DateTime endDate, Excel._Workbook m_objBook, Excel.Sheets m_objSheets, Excel._Worksheet m_objSheet, Excel.Range m_objRange, Excel.Font m_objFont, System.Reflection.Missing m_objOpt) { using (DataTable dt = new DutyInfoDA().GetTeaDutyNormal(string.Empty, string.Empty, string.Empty, string.Empty, startDate, endDate, 100).Tables[0]) { if (dt != null && dt.Rows.Count > 0) { DataView dv = dt.DefaultView; using (DataTable dtBaseInfo = new TeacherBaseDataAccess().GetTcBaseInfo(string.Empty, string.Empty, string.Empty, string.Empty).Tables[0]) { object[, ] objData = null; foreach (DataRow dr in dtBaseInfo.Rows) { dv.RowFilter = "T_Number = " + dr[1].ToString(); objData = new object[dv.Count, 6]; if (dv.Count > 0) { for (int i = 0; i < dv.Count; i++) { objData[i, 0] = dv[i][3].ToString(); objData[i, 1] = dv[i][2].ToString(); objData[i, 2] = dv[i][0].ToString(); objData[i, 3] = dv[i][1].ToString(); objData[i, 4] = dv[i][4].ToString(); objData[i, 5] = dv[i][5].ToString(); } m_objSheets = (Excel.Sheets)m_objBook.Sheets; m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(4)); m_objSheet.Copy(Type.Missing, m_objSheet); m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(5)); m_objSheet.Name = objData[0, 0].ToString() + string.Format("({0})", objData[0, 1]); m_objRange = m_objSheet.get_Range("A3", m_objOpt); m_objRange = m_objRange.get_Resize(dv.Count, 6); m_objRange.Value = objData; m_objRange.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter; m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; m_objRange.WrapText = true; m_objRange.Borders.LineStyle = System.Windows.Forms.BorderStyle.FixedSingle; m_objFont = m_objRange.Font; m_objFont.Size = 9; m_objRange = m_objSheet.get_Range("A" + (dv.Count + 4).ToString(), m_objOpt); m_objRange.Value = "园所:"; m_objRange.Font.Bold = true; m_objRange.Font.Size = 9; m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft; m_objRange = m_objSheet.get_Range("B" + (dv.Count + 4).ToString(), m_objOpt); m_objRange.Value = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString(); m_objRange.Font.Bold = true; m_objRange.Font.Size = 9; m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft; m_objRange = m_objSheet.get_Range("A" + (dv.Count + 5).ToString(), m_objOpt); m_objRange.Value = "统计开始日期:"; m_objRange.Font.Bold = true; m_objRange.Font.Size = 9; m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft; m_objRange = m_objSheet.get_Range("B" + (dv.Count + 5).ToString(), m_objOpt); m_objRange.Value = startDate.ToString("yyyy.MM.dd"); m_objRange.Font.Bold = true; m_objRange.Font.Size = 9; m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft; m_objRange = m_objSheet.get_Range("A" + (dv.Count + 6).ToString(), m_objOpt); m_objRange.Value = "统计结束日期:"; m_objRange.Font.Bold = true; m_objRange.Font.Size = 9; m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft; m_objRange = m_objSheet.get_Range("B" + (dv.Count + 6).ToString(), m_objOpt); m_objRange.Value = endDate.ToString("yyyy.MM.dd"); m_objRange.Font.Bold = true; m_objRange.Font.Size = 9; m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft; } } } m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(4)); m_objSheet.Delete(); } } }