Esempio n. 1
0
        public void AllStuInfoPrint(DataSet dsExportData, string savePath)
        {
            try
            {
                m_objExcel = new Excel.Application();
                m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
                m_objBook  = (Excel._Workbook)m_objBooks.Open(excelPath + @"report\AllStuInfo.xls",
                                                              m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt,
                                                              m_objOpt, m_objOpt, m_objOpt);
                m_objSheets = (Excel.Sheets)m_objBook.Worksheets;

                dv = dsExportData.Tables[0].DefaultView;

                for (int row = 1; row < dsExportData.Tables[1].Rows.Count; row++)
                {
                    m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(1);

                    m_objSheet.Copy(m_objOpt, m_objSheet);
                }

                for (int row = 1; row <= dsExportData.Tables[1].Rows.Count; row++)
                {
                    m_objSheet      = (Excel._Worksheet)m_objSheets.get_Item(row);
                    m_objSheet.Name = Convert.ToString(dsExportData.Tables[1].Rows[row - 1][0]);
                    BindingData(m_objSheet.Name);
                }

                m_objBook.SaveAs(savePath, m_objOpt, m_objOpt,
                                 m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
                                 m_objOpt, m_objOpt, m_objOpt, m_objOpt);
                m_objBook.Close(false, m_objOpt, m_objOpt);
                m_objExcel.Quit();

                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objRange);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheet);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheets);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBook);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBooks);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objExcel);
            }
            catch (Exception e)
            {
                Util.WriteLog(e.Message, Util.EXCEPTION_LOG_TITLE);
            }
            finally
            {
                m_objRange  = null;
                m_objSheet  = null;
                m_objSheets = null;
                m_objBook   = null;
                m_objBooks  = null;
                m_objExcel  = null;

                GC.Collect();

                KillProcess();
            }
        }
Esempio n. 2
0
		public void FinanMgmtInfoPrint(DataSet dsFinanInfo,string savePath)
		{
			int rowStart = 6;
			try
			{
				m_objExcel = new Excel.Application(); 
				m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;				
				m_objBook = (Excel._Workbook)m_objBooks.Open(excelPath+@"report\FinanMgmtInfo.xls",
					m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,
					m_objOpt,m_objOpt,m_objOpt); 

				m_objSheets = (Excel.Sheets)m_objBook.Worksheets;
				m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(1);
				m_objSheet.Copy(m_objSheet,m_objOpt);
				m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(1);
				m_objSheet.Name = dsFinanInfo.Tables[0].Rows[0][2].ToString();
				for ( int finanRow = 0;finanRow < dsFinanInfo.Tables[0].Rows.Count; finanRow ++ )
				{
					if ( !dsFinanInfo.Tables[0].Rows[finanRow][2].ToString().Equals(m_objSheet.Name) )
					{
						SetJumpBoard(rowStart,dsFinanInfo.Tables[0].Rows[finanRow-1][2].ToString());
						m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(m_objSheets.Count);
						m_objSheet.Copy(m_objSheet,m_objOpt);
						m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(m_objSheets.Count-1);
						m_objSheet.Name = dsFinanInfo.Tables[0].Rows[finanRow][2].ToString();
						rowStart = 6;
					}
					for ( int column = 1;column < dsFinanInfo.Tables[0].Columns.Count; column ++)
					{
						switch ( column )
						{
							case 1:		m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart,column],m_objSheet.Cells[rowStart+1,column]);
								m_objRange.MergeCells = true;
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								m_objRange.VerticalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 3:	    m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart,column-1],m_objSheet.Cells[rowStart+1,column-1]);
								m_objRange.MergeCells = true;
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								m_objRange.VerticalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 4:		m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart,column-1],m_objSheet.Cells[rowStart+1,column-1]);
								m_objRange.MergeCells = true;
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								m_objRange.VerticalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 5:		m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart,column-1],m_objSheet.Cells[rowStart,column-1]);
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 6:		m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart,column-1],m_objSheet.Cells[rowStart,column-1]);
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 7:		m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart,column-1],m_objSheet.Cells[rowStart,column-1]);
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 8:		m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart+1,column-4],m_objSheet.Cells[rowStart+1,column-4]);
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 9:		m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart+1,column-4],m_objSheet.Cells[rowStart+1,column-4]);
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 10:	m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart+1,column-4],m_objSheet.Cells[rowStart+1,column-4]);
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 11:	m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart,column-4],m_objSheet.Cells[rowStart,column-4]);
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 12:	m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart+1,column-5],m_objSheet.Cells[rowStart+1,column-5]);
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
							case 13:	m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rowStart,column-5],m_objSheet.Cells[rowStart+1,column-5]);
								m_objRange.MergeCells = true;
								m_objRange.Value = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
								m_objRange.Borders.LineStyle = BorderStyle.FixedSingle;
								m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
								m_objRange.VerticalAlignment = Excel.XlHAlign.xlHAlignCenter;
								break;
						}
					}
					rowStart += 2;
				}
				SetJumpBoard(rowStart,dsFinanInfo.Tables[0].Rows[dsFinanInfo.Tables[0].Rows.Count-1][2].ToString());
				m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(m_objSheets.Count);
				m_objSheet.Visible = Excel.XlSheetVisibility.xlSheetHidden;

				m_objBook.SaveAs(savePath, m_objOpt, m_objOpt,
					m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
					m_objOpt, m_objOpt, m_objOpt, m_objOpt);
				m_objBook.Close(false, m_objOpt, m_objOpt);
				m_objExcel.Quit();

				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objRange);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheet);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheets);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBook);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBooks);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objExcel);
				
			}
			catch(Exception e)
			{
				Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE);
			}
			finally
			{
				m_objRange = null;
				m_objSheet = null;
				m_objSheets = null;
				m_objBook = null;
				m_objBooks = null;
				m_objExcel = null;

				GC.Collect();

				KillProcess();
			}
		}
		public void PrintKidDetailInfo(string getGrade,string getClass,string getName,string getNumber,string savePath)
		{
			try
			{
				DataSet dsStuList_Stat = null;
				DateTime getBegDate = BegDate;
				DateTime getEndDate = EndDate;
				int mbTwoDates = (getEndDate.Year-getBegDate.Year)*12 + (getEndDate.Month-getBegDate.Month);
				int monthes = (getEndDate.Year-getBegDate.Year)*12 + (getEndDate.Month-getBegDate.Month);
				string classInfo = string.Empty;

				using ( StudentCheckInfoDataAccess stuCheckInfoDataAccess = new StudentCheckInfoDataAccess() )
				{
					if ( getName.Equals("") && getNumber.Equals("") )
					{
						dsStuList_Stat = stuCheckInfoDataAccess.GetStuList_GradeClass(getGrade,getClass);
						classInfo = new ClassesDataAccess().GetClassInfo(Convert.ToInt32(getClass),Convert.ToInt32(getGrade)).Tables[0].Rows[0][1].ToString();
					}
					else
					{
						dsStuList_Stat = stuCheckInfoDataAccess.GetStuList_NameNumber(getName,getNumber);
						classInfo = dsStuList_Stat.Tables[0].Rows[0][2].ToString();
					}
				}

				if ( dsStuList_Stat.Tables[0].Rows.Count > 0 )
				{
					m_objExcel = new Excel.Application();
					m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
					m_objBook = (Excel._Workbook)m_objBooks.Open(excelPath+@"report\MorningCheckInfoKidDetail.xls",
						m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,
						m_objOpt,m_objOpt,m_objOpt);
				
					m_objSheets = (Excel.Sheets)m_objBook.Sheets;						

					for ( int i=0; i<=monthes; i++ )
					{
						GetExcelEndDate(getBegDate,ref getEndDate);

						m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(i+1));

						if ( mbTwoDates >= 1 )
							m_objSheet.Copy(m_objOpt,m_objSheet);

						m_objRange = m_objSheet.get_Range("AE2",m_objOpt);
						m_objRange.Value = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString();
						m_objRange = m_objSheet.get_Range("AE3",m_objOpt);
						m_objRange.Value = classInfo;
						m_objRange = m_objSheet.get_Range("AE4",m_objOpt);
						m_objRange.Value = "'" + getBegDate.ToString("yyyy.MM");

						WriteMonth(getBegDate);

						for ( int nameRow=0; nameRow<dsStuList_Stat.Tables[0].Rows.Count; nameRow++ )
						{
							DataSet dsStuCheckInfo_Detail = null;
								
							using ( StudentCheckInfoDataAccess stuCheckInfoDataAccess = new StudentCheckInfoDataAccess() )
							{
								dsStuCheckInfo_Detail = stuCheckInfoDataAccess.GetStuCheckInfo_Detail(dsStuList_Stat.Tables[0].Rows[nameRow][0].ToString(),getBegDate,getEndDate);
								WriteExcelForDetail(getBegDate,getEndDate,dsStuCheckInfo_Detail,nameRow,
									dsStuList_Stat.Tables[0].Rows[nameRow][1].ToString());
							}
						}

						mbTwoDates--;
						getBegDate = getEndDate.AddDays(1);
						getEndDate = EndDate;
					}

					m_objBook.SaveAs(savePath, m_objOpt, m_objOpt,
						m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
						m_objOpt, m_objOpt, m_objOpt, m_objOpt);
					m_objBook.Close(false, m_objOpt, m_objOpt);
					m_objExcel.Quit();

					System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objRange);
					System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheet);
					System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheets);
					System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBook);
					System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBooks);
					System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objExcel);
				}		
			}
			catch(Exception e)
			{
				Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE);
			}
			finally
			{
				m_objRange = null;
				m_objSheet = null;
				m_objSheets = null;
				m_objBook = null;
				m_objBooks = null;
				m_objExcel = null;

				GC.Collect();

				KillProcess();
			}
		}
Esempio n. 4
0
        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();
                }
            }
        }
		public void PrintNchsHealthPersonal(string getOutputClass,string getOutputName,string getOutputNumber,DataSet dsHealthOutput,
			string getBegDate,string getEndDate,string savePath,string getTeacher)
		{
			try
			{
				m_objExcel = new Excel.Application(); 
				m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;				
				m_objBook = (Excel._Workbook)m_objBooks.Open(excelPath+@"report\NchsHealthOutputPersonal",
					m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,
					m_objOpt,m_objOpt,m_objOpt); 

				m_objSheets = (Excel.Sheets)m_objBook.Worksheets;

				for ( int sheetNumbers=1; sheetNumbers<dsHealthOutput.Tables[0].Rows.Count; sheetNumbers++ )
				{
					m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(1);
					m_objSheet.Copy(Type.Missing,m_objSheet);
				}

				for ( int row=0; row<dsHealthOutput.Tables[0].Rows.Count; row++)
				{
					m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(row+1);
					m_objSheet.Name = dsHealthOutput.Tables[0].Rows[row]["info_stuName"].ToString()+
						"("+Convert.ToDateTime(dsHealthOutput.Tables[0].Rows[row]["nchsanaly_checktime"]).Year.ToString()+
						"."+Convert.ToDateTime(dsHealthOutput.Tables[0].Rows[row]["nchsanaly_checktime"]).Month.ToString()+")";

					m_objRange = m_objSheet.get_Range("E2",m_objOpt);
					m_objRange.Value = "  "+dsHealthOutput.Tables[0].Rows[row]["info_stuName"].ToString();

					m_objRange = m_objSheet.get_Range("G2",m_objOpt);
					m_objRange.Value = " "+dsHealthOutput.Tables[0].Rows[row]["info_stuGender"].ToString();

					m_objRange = m_objSheet.get_Range("I2",m_objOpt);
					m_objRange.Value = " "+Convert.ToDateTime(dsHealthOutput.Tables[0].Rows[row]["info_stuBirthday"]).ToString("yyyy-MM-dd");
					
					m_objRange = m_objSheet.get_Range("B6",m_objOpt);
					
					string realAge = dsHealthOutput.Tables[0].Rows[row]["nchsanaly_realage"].ToString();

					if ( realAge.IndexOf(".") < 0 )
					{
						m_objRange.Value = realAge;
						m_objRange = m_objSheet.get_Range("C6",m_objOpt);
						m_objRange.Value = 0;
					}
					else
					{
						m_objRange.Value = realAge.Substring(0,realAge.IndexOf("."));
						m_objRange = m_objSheet.get_Range("C6",m_objOpt);
						m_objRange.Value = realAge.Substring(realAge.IndexOf(".")+1);
					}	

					double getHeight = Convert.ToDouble(dsHealthOutput.Tables[0].Rows[row]["nchsanaly_height"]);
					m_objRange = m_objSheet.get_Range("B7",m_objOpt);
					m_objRange.Value = getHeight;

					if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_heightresult"].ToString().Equals("上") )
					{
						m_objRange = m_objSheet.get_Range("D7",m_objOpt);
						m_objRange.Value = "√";
					}
					else if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_heightresult"].ToString().Equals("中上") )
					{
						m_objRange = m_objSheet.get_Range("E7",m_objOpt);
						m_objRange.Value = "√";
					}
					else if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_heightresult"].ToString().Equals("中+") )
					{
						m_objRange = m_objSheet.get_Range("F7",m_objOpt);
						m_objRange.Value = "√";
					}
					else if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_heightresult"].ToString().Equals("中-") )
					{
						m_objRange = m_objSheet.get_Range("H7",m_objOpt);
						m_objRange.Value = "√";
					}
					else if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_heightresult"].ToString().Equals("中下") )
					{
						m_objRange = m_objSheet.get_Range("J7",m_objOpt);
						m_objRange.Value = "√";
					}
					else
					{
						m_objRange = m_objSheet.get_Range("L7",m_objOpt);
						m_objRange.Value = "√";
					}

					double getWeight = Convert.ToDouble(dsHealthOutput.Tables[0].Rows[row]["nchsanaly_weight"]);
					m_objRange = m_objSheet.get_Range("B8",m_objOpt);
					m_objRange.Value = getWeight;

					if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_weightresult"].ToString().Equals("上") )
					{
						m_objRange = m_objSheet.get_Range("D8",m_objOpt);
						m_objRange.Value = "√";
					}
					else if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_weightresult"].ToString().Equals("中上") )
					{
						m_objRange = m_objSheet.get_Range("E8",m_objOpt);
						m_objRange.Value = "√";
					}
					else if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_weightresult"].ToString().Equals("中+") )
					{
						m_objRange = m_objSheet.get_Range("F8",m_objOpt);
						m_objRange.Value = "√";
					}
					else if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_weightresult"].ToString().Equals("中-") )
					{
						m_objRange = m_objSheet.get_Range("H8",m_objOpt);
						m_objRange.Value = "√";
					}
					else if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_weightresult"].ToString().Equals("中下") )
					{
						m_objRange = m_objSheet.get_Range("J8",m_objOpt);
						m_objRange.Value = "√";
					}
					else
					{
						m_objRange = m_objSheet.get_Range("L8",m_objOpt);
						m_objRange.Value = "√";
					}
					
					int getGender = dsHealthOutput.Tables[0].Rows[row]["info_stuGender"].ToString().Equals("男")?0:1;
					
					double ageHeightMiddleValue = Convert.ToDouble(new HealthManagementDataAccess().GetNchsAgeHeightMiddleValue(realAge,getGender).Rows[0]["nchs_middle"]);
					double ageWeightMiddleValue = Convert.ToDouble(new HealthManagementDataAccess().GetNchsAgeWeightMiddleValue(realAge,getGender).Rows[0]["nchs_middle"]);

					
					string rangeValue = string.Empty;

					if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_underweight"].Equals("中度体重低下") || dsHealthOutput.Tables[0].Rows[row]["nchsanaly_underweight"].Equals("重度体重低下") )
					{
						m_objRange = m_objSheet.get_Range("C12",m_objOpt);

						rangeValue = Math.Abs((Convert.ToDouble(dsHealthOutput.Tables[0].Rows[row]["nchsanaly_weight"])-ageWeightMiddleValue)/ageWeightMiddleValue).ToString("0.0%")+",";
						m_objRange.Value = rangeValue;

						m_objRange = m_objSheet.get_Range("A14",m_objOpt);
						m_objRange.Value = "√";
					}

					if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_stunting"].Equals("中度生长迟缓") || dsHealthOutput.Tables[0].Rows[row]["nchsanaly_stunting"].Equals("重度生长迟缓") ) 
					{
						m_objRange = m_objSheet.get_Range("C12",m_objOpt);

						rangeValue += Math.Abs((Convert.ToDouble(dsHealthOutput.Tables[0].Rows[row]["nchsanaly_height"])-ageHeightMiddleValue)/ageHeightMiddleValue).ToString("0.0%");
						m_objRange.Value = rangeValue;

						m_objRange = m_objSheet.get_Range("C14",m_objOpt);
						m_objRange.Value = "√";
					}
					else
					{
						if (rangeValue == string.Empty)
						{
							m_objRange = m_objSheet.get_Range("F11", m_objOpt);
							m_objRange.Value = "等";
							m_objRange = m_objSheet.get_Range("C12", m_objOpt);
							m_objRange.Value = ageWeightMiddleValue.ToString() + "," + ageHeightMiddleValue.ToString();
							m_objRange = m_objSheet.get_Range("E14",m_objOpt);
							m_objRange.Value = "√";
						}
						else
						{
							m_objRange = m_objSheet.get_Range("C12",m_objOpt);
							rangeValue.Replace(",","");
							m_objRange.Value = rangeValue;
						}
					}

					double heightWeightMiddleValue = Convert.ToDouble(new HealthManagementDataAccess().GetNchsHeightWeightMiddleValue(getHeight,getGender).Rows[0]["nchs_middle"]);

					if ( !dsHealthOutput.Tables[0].Rows[row]["nchsanaly_wasting"].ToString().Equals("正常") )
					{
						m_objRange = m_objSheet.get_Range("K11", m_objOpt);
						m_objRange.Value = "低于";
						m_objRange = m_objSheet.get_Range("H13",m_objOpt);
						m_objRange.Value = Math.Abs((getWeight - heightWeightMiddleValue)/heightWeightMiddleValue).ToString("0.0%");

						if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_wasting"].ToString().Equals("中度消瘦") )
						{
							m_objRange = m_objSheet.get_Range("H15",m_objOpt);
							m_objRange.Value = "√";
						}
						else
						{
							m_objRange = m_objSheet.get_Range("G15",m_objOpt);
							m_objRange.Value = "√";
						}
					}
					else
					{
						if ( !dsHealthOutput.Tables[0].Rows[row]["nchsanaly_obesity"].ToString().Equals("正常") )
						{
							m_objRange = m_objSheet.get_Range("K11", m_objOpt);
							m_objRange.Value = "高于";
							m_objRange = m_objSheet.get_Range("H13",m_objOpt);
							m_objRange.Value = Math.Abs((getWeight - heightWeightMiddleValue)/heightWeightMiddleValue).ToString("0.0%");

							if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_obesity"].ToString().Equals("轻度肥胖") )
							{
								m_objRange = m_objSheet.get_Range("I15",m_objOpt);
								m_objRange.Value = "√";
							}
							else if ( dsHealthOutput.Tables[0].Rows[row]["nchsanaly_obesity"].ToString().Equals("中度肥胖") )
							{
								m_objRange = m_objSheet.get_Range("J15",m_objOpt);
								m_objRange.Value = "√";
							}
							else
							{
								m_objRange = m_objSheet.get_Range("K15",m_objOpt);
								m_objRange.Value = "√";
							}
						}
						else
						{
							m_objRange = m_objSheet.get_Range("H13", m_objOpt);
							m_objRange.Value = heightWeightMiddleValue.ToString();
							m_objRange = m_objSheet.get_Range("L15", m_objOpt);
							m_objRange.Value = "√";
						}
					}

					m_objRange = m_objSheet.get_Range("H17",m_objOpt);
					m_objRange.Value = getTeacher;

					m_objRange = m_objSheet.get_Range("H19",m_objOpt);
					m_objRange.Value = DateTime.Now;

					m_objRange = m_objSheet.get_Range("H21", m_objOpt);
					m_objRange.Value = dsHealthOutput.Tables[0].Rows[row]["nchsanaly_checktime"].ToString();

				}

				m_objBook.SaveAs(savePath, m_objOpt, m_objOpt,
					m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
					m_objOpt, m_objOpt, m_objOpt, m_objOpt);
				m_objBook.Close(false, m_objOpt, m_objOpt);
				m_objExcel.Quit();

				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objRange);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheet);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheets);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBook);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBooks);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objExcel);
			}
			catch(Exception e)
			{
				Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE);
			}
			finally
			{
				m_objRange = null;
				m_objSheet = null;
				m_objSheets = null;
				m_objBook = null;
				m_objBooks = null;
				m_objExcel = null;

				GC.Collect();

				KillProcess();
			}
		}
Esempio n. 6
0
		public void AllStuInfoPrint(DataSet dsExportData,string savePath)
		{
			try
			{
				m_objExcel = new Excel.Application();
				m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
				m_objBook = (Excel._Workbook)m_objBooks.Open(excelPath+@"report\AllStuInfo.xls",
					m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,m_objOpt,
					m_objOpt,m_objOpt,m_objOpt);
				m_objSheets = (Excel.Sheets)m_objBook.Worksheets;

				dv = dsExportData.Tables[0].DefaultView;
	
				for (int row = 1; row < dsExportData.Tables[1].Rows.Count; row++)
				{
					m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(1);
					
					m_objSheet.Copy(m_objOpt,m_objSheet);	
				}

				for (int row = 1; row <= dsExportData.Tables[1].Rows.Count; row++)
				{
					m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(row);
					m_objSheet.Name = Convert.ToString(dsExportData.Tables[1].Rows[row-1][0]);
					BindingData(m_objSheet.Name);
				}

				m_objBook.SaveAs(savePath, m_objOpt, m_objOpt,
				m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
				m_objOpt, m_objOpt, m_objOpt, m_objOpt);
				m_objBook.Close(false, m_objOpt, m_objOpt);
				m_objExcel.Quit();

				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objRange);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheet);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheets);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBook);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBooks);
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objExcel);
			}
			catch(Exception e)
			{
				Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE);
			}
			finally
			{
				m_objRange = null;
				m_objSheet = null;
				m_objSheets = null;
				m_objBook = null;
				m_objBooks = null;
				m_objExcel = null;

				GC.Collect();

				KillProcess();
			}
		}
Esempio n. 7
0
        public void FinanMgmtInfoPrint(DataSet dsFinanInfo, string savePath)
        {
            int rowStart = 6;

            try
            {
                m_objExcel = new Excel.Application();
                m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
                m_objBook  = (Excel._Workbook)m_objBooks.Open(excelPath + @"report\FinanMgmtInfo.xls",
                                                              m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt,
                                                              m_objOpt, m_objOpt, m_objOpt);

                m_objSheets = (Excel.Sheets)m_objBook.Worksheets;
                m_objSheet  = (Excel._Worksheet)m_objSheets.get_Item(1);
                m_objSheet.Copy(m_objSheet, m_objOpt);
                m_objSheet      = (Excel._Worksheet)m_objSheets.get_Item(1);
                m_objSheet.Name = dsFinanInfo.Tables[0].Rows[0][2].ToString();
                for (int finanRow = 0; finanRow < dsFinanInfo.Tables[0].Rows.Count; finanRow++)
                {
                    if (!dsFinanInfo.Tables[0].Rows[finanRow][2].ToString().Equals(m_objSheet.Name))
                    {
                        SetJumpBoard(rowStart, dsFinanInfo.Tables[0].Rows[finanRow - 1][2].ToString());
                        m_objSheet = (Excel._Worksheet)m_objSheets.get_Item(m_objSheets.Count);
                        m_objSheet.Copy(m_objSheet, m_objOpt);
                        m_objSheet      = (Excel._Worksheet)m_objSheets.get_Item(m_objSheets.Count - 1);
                        m_objSheet.Name = dsFinanInfo.Tables[0].Rows[finanRow][2].ToString();
                        rowStart        = 6;
                    }
                    for (int column = 1; column < dsFinanInfo.Tables[0].Columns.Count; column++)
                    {
                        switch (column)
                        {
                        case 1: m_objRange                 = m_objSheet.get_Range((Excel.Range)m_objSheet.Cells[rowStart, column], (Excel.Range)m_objSheet.Cells[rowStart + 1, column]);
                            m_objRange.MergeCells          = true;
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            m_objRange.VerticalAlignment   = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 3: m_objRange                 = m_objSheet.get_Range((Excel.Range)m_objSheet.Cells[rowStart, column - 1], (Excel.Range)m_objSheet.Cells[rowStart + 1, column - 1]);
                            m_objRange.MergeCells          = true;
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            m_objRange.VerticalAlignment   = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 4: m_objRange                 = m_objSheet.get_Range((Excel.Range)m_objSheet.Cells[rowStart, column - 1], (Excel.Range)m_objSheet.Cells[rowStart + 1, column - 1]);
                            m_objRange.MergeCells          = true;
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            m_objRange.VerticalAlignment   = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 5:         m_objRange         = m_objSheet.get_Range(m_objSheet.Cells[rowStart, column - 1], m_objSheet.Cells[rowStart, column - 1]);
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 6:         m_objRange         = m_objSheet.get_Range(m_objSheet.Cells[rowStart, column - 1], m_objSheet.Cells[rowStart, column - 1]);
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 7:         m_objRange         = m_objSheet.get_Range(m_objSheet.Cells[rowStart, column - 1], m_objSheet.Cells[rowStart, column - 1]);
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 8:         m_objRange         = m_objSheet.get_Range(m_objSheet.Cells[rowStart + 1, column - 4], m_objSheet.Cells[rowStart + 1, column - 4]);
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 9:         m_objRange         = m_objSheet.get_Range(m_objSheet.Cells[rowStart + 1, column - 4], m_objSheet.Cells[rowStart + 1, column - 4]);
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 10:        m_objRange         = m_objSheet.get_Range(m_objSheet.Cells[rowStart + 1, column - 4], m_objSheet.Cells[rowStart + 1, column - 4]);
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 11:        m_objRange         = m_objSheet.get_Range(m_objSheet.Cells[rowStart, column - 4], m_objSheet.Cells[rowStart, column - 4]);
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 12:        m_objRange         = m_objSheet.get_Range(m_objSheet.Cells[rowStart + 1, column - 5], m_objSheet.Cells[rowStart + 1, column - 5]);
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            break;

                        case 13:        m_objRange         = m_objSheet.get_Range(m_objSheet.Cells[rowStart, column - 5], m_objSheet.Cells[rowStart + 1, column - 5]);
                            m_objRange.MergeCells          = true;
                            m_objRange.Value               = dsFinanInfo.Tables[0].Rows[finanRow][column].ToString();
                            m_objRange.Borders.LineStyle   = BorderStyle.FixedSingle;
                            m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            m_objRange.VerticalAlignment   = Excel.XlHAlign.xlHAlignCenter;
                            break;
                        }
                    }
                    rowStart += 2;
                }
                SetJumpBoard(rowStart, dsFinanInfo.Tables[0].Rows[dsFinanInfo.Tables[0].Rows.Count - 1][2].ToString());
                m_objSheet         = (Excel._Worksheet)m_objSheets.get_Item(m_objSheets.Count);
                m_objSheet.Visible = Excel.XlSheetVisibility.xlSheetHidden;

                m_objBook.SaveAs(savePath, m_objOpt, m_objOpt,
                                 m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
                                 m_objOpt, m_objOpt, m_objOpt, m_objOpt);
                m_objBook.Close(false, m_objOpt, m_objOpt);
                m_objExcel.Quit();

                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objRange);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheet);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheets);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBook);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBooks);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objExcel);
            }
            catch (Exception e)
            {
                Util.WriteLog(e.Message, Util.EXCEPTION_LOG_TITLE);
            }
            finally
            {
                m_objRange  = null;
                m_objSheet  = null;
                m_objSheets = null;
                m_objBook   = null;
                m_objBooks  = null;
                m_objExcel  = null;

                GC.Collect();

                KillProcess();
            }
        }