3119劳晓琨 实习报告Word文档格式.docx
《3119劳晓琨 实习报告Word文档格式.docx》由会员分享,可在线阅读,更多相关《3119劳晓琨 实习报告Word文档格式.docx(16页珍藏版)》请在冰点文库上搜索。
{
CStringneirong[11];
}jilu[255];
其中每个neirong的数组含义如下表所示
neirong[0]
neirong[1]
neirong[2]
neirong[3]
neirong[4]
neirong[5]
学号
姓名
性别
分数
课程名
课程编号
neirong[6]
neirong[7]
neirong[8]
neirong[9]
neirong[10]
学分
班级
年级
专业
系别
程序结构图如下图所示:
图1.1程序结构图
三、调试分析
调试过程中主要遇到的问题是程序调用的数据载入Excel的数据,在程序书写的过程中,经常遇到例如行列不对应、数据错位等问题。
主要问题在于对于两个输入循环i、j的不熟悉的原因。
经过长时间的调试,逐渐熟悉过程,最终解决了该问题,保证程序能够正常的现实。
四、使用说明
运行文件,首先显示程序的主菜单界面,如下图所示:
图4.1程序主界面
按下
,进行Excel数据的导入,导入后显示如下:
图4.2载入程序后显示情况
按下按钮
,新增项目,显示新增框:
图4.3新增内容
点击相应的项目,修改内容
图4.4修改项目
五、测试结果
对程序进行运行测试:
1.初始运行程序正常
2.新增、修改项目,程序能够正常显示修改后的内容,并显示出来。
3.从外部文件导入信息正常。
六、心得体会
这次的实习要求我用VC++编一个学生成绩管理软件,此前没有怎么接触过VC,所以在开始编程之前我通过上网和阅读相关书籍先了解了MFC的制作方法,然后根据指导开始编程,期间在调试等方面遇到了很多困难,经过上网查询和向同学老师请教解决了遇到的难题。
通过此次实验,我学习掌握了VC++设计制作小型应用软件的方法与步骤,初步学会了VC++添加、使用控件、调用、读写Excel文件,不同类数据传递的方法。
在学习的过程中,不断遇到困难、解决困难,使我受益匪浅。
七、附录
#include"
stdafx.h"
student.h"
studentDlg.h"
SpreadSheet.h"
change.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CAboutDlgdialogusedforAppAbout
classCAboutDlg:
publicCDialog
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);
//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:
:
CAboutDlg():
CDialog(CAboutDlg:
IDD)
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
voidCAboutDlg:
DoDataExchange(CDataExchange*pDX)
CDialog:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//CStudentDlgdialog
CStudentDlg:
CStudentDlg(CWnd*pParent/*=NULL*/)
:
CDialog(CStudentDlg:
IDD,pParent)
//{{AFX_DATA_INIT(CStudentDlg)
//NOTE:
theClassWizardwilladdmemberinitializationhere
//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32
m_hIcon=AfxGetApp()->
LoadIcon(IDR_MAINFRAME);
voidCStudentDlg:
//{{AFX_DATA_MAP(CStudentDlg)
DDX_Control(pDX,IDC_LIST1,m_list);
BEGIN_MESSAGE_MAP(CStudentDlg,CDialog)
//{{AFX_MSG_MAP(CStudentDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1,OnOpen)
ON_BN_CLICKED(IDC_BUTTON2,OnAdd)
ON_BN_CLICKED(IDC_BUTTON3,Onchange)
//CStudentDlgmessagehandlers
BOOLCStudentDlg:
OnInitDialog()
OnInitDialog();
//Add"
About..."
menuitemtosystemmenu.
//IDM_ABOUTBOXmustbeinthesystemcommandrange.
ASSERT((IDM_ABOUTBOX&
0xFFF0)==IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX<
0xF000);
CMenu*pSysMenu=GetSystemMenu(FALSE);
if(pSysMenu!
=NULL)
{
CStringstrAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if(!
strAboutMenu.IsEmpty())
{
pSysMenu->
AppendMenu(MF_SEPARATOR);
AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);
}
}
//Settheiconforthisdialog.Theframeworkdoesthisautomatically
//whentheapplication'
smainwindowisnotadialog
SetIcon(m_hIcon,TRUE);
//Setbigicon
SetIcon(m_hIcon,FALSE);
//Setsmallicon
//TODO:
Addextrainitializationhere
initial();
returnTRUE;
//returnTRUEunlessyousetthefocustoacontrol
OnSysCommand(UINTnID,LPARAMlParam)
if((nID&
0xFFF0)==IDM_ABOUTBOX)
CAboutDlgdlgAbout;
dlgAbout.DoModal();
else
CDialog:
OnSysCommand(nID,lParam);
//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow
//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,
//thisisautomaticallydoneforyoubytheframework.
OnPaint()
if(IsIconic())
CPaintDCdc(this);
//devicecontextforpainting
SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);
//Centericoninclientrectangle
intcxIcon=GetSystemMetrics(SM_CXICON);
intcyIcon=GetSystemMetrics(SM_CYICON);
CRectrect;
GetClientRect(&
rect);
intx=(rect.Width()-cxIcon+1)/2;
inty=(rect.Height()-cyIcon+1)/2;
//Drawtheicon
dc.DrawIcon(x,y,m_hIcon);
OnPaint();
//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags
//theminimizedwindow.
HCURSORCStudentDlg:
OnQueryDragIcon()
return(HCURSOR)m_hIcon;
OnOpen()//打开文件
CStringstrpath,str;
inti,j;
//打开文件对话框
CFileDialogdlg(TRUE,"
xls"
NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"
XLSFile(*.xls)|*.xls||"
);
//打开文件夹
if(dlg.DoModal()==IDOK)
strpath=dlg.GetPathName();
//打开Excel文件
CSpreadSheetSS(strpath,"
Sheet1"
CStringArrayRows,Column;
//将数据存储到全局数组里面
shu=SS.GetTotalRows()-1;
for(i=0;
i<
SS.GetTotalRows();
i++)
SS.ReadRow(Rows,i+1);
if(i>
0)
{
for(j=0;
j<
11;
j++)
{
jilu[i-1].neirong[j]=Rows.GetAt(j);
//读excel数据,存储到结构体中
}
}
showall();
//显示全部
initial()//初始化控件
shu=0;
m_list.InsertColumn(0,"
学号"
LVCFMT_LEFT,100,0);
m_list.InsertColumn(1,"
姓名"
m_list.InsertColumn(2,"
性别"
m_list.InsertColumn(3,"
分数"
m_list.InsertColumn(4,"
课程名"
m_list.InsertColumn(5,"
课程编号"
m_list.InsertColumn(6,"
学分"
m_list.InsertColumn(7,"
班级"
m_list.InsertColumn(8,"
年级"
m_list.InsertColumn(9,"
专业"
m_list.InsertColumn(10,"
系别"
m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT);
showall()//显示全部内容
m_list.DeleteAllItems();
for(i=0;
i<
shu;
i++)
m_list.InsertItem(i,"
"
for(j=0;
m_list.SetItemText(i,j,jilu[i].neirong[j]);
OnAdd()//添加信息
changedlg;
dlg.SURE=0;
dlg.DoModal();
if(dlg.SURE==1)//打开对话框,若按下确定了,继续
inti;
for(i=0;
jilu[shu].neirong[i]=dlg.jilu[i];
shu++;
showall();
Onchange()//修改内容
inti;
POSITIONpos;
intnum;
pos=m_list.GetFirstSelectedItemPosition();
num=(int)m_list.GetNextSelectedItem(pos);
if(num>
=0&
&
num<
shu)//查看选项是否符合要求
dlg.jilu[i]=jilu[num].neirong[i];
dlg.SURE=1;
//打开子控件,进行查找
if(dlg.SURE==1)
jilu[num].neirong[i]=dlg.jilu[i];