如题,整个程序编译运行无错,但利用按钮执行这个功能的时候会出现弹窗错误,如图 请大神们看看 是什么原因 悬赏追加之。
void Cexcelt::OnDuanxingcheng()
{
int p=0,i,j,q,nrows,ncolumns=3;
for(i=0;i<4200;)
{
q=0;
while (A[i][1]==0)
{
for(j=0;j<3;j++)
B[q][j]=A[i][j];
i++;
q++;
}
while (A[i][1]!=0)
{
for(j=0;j<3;j++)
B[q][j]=A[i][j];
i++;
q++;
nrows=q;
}
p++;//数短行程个数
Cp=(double **)malloc(nrows*sizeof(double *));
for(i=0;i<nrows;i++)
Cp[i]=(double *)malloc(ncolumns*sizeof(double));
//保存为excel
CMyExcel ExcelMain;
MyAlignment Xalign;
CString strTex;
CString strp;
strp.Format("%d",p);
CString strw="C";
MyNumberFormat Xnumber;
MyBorder Xborder;
MyFont Xfont;
//边框线
Xborder.Color=RGB(0,0,0);
Xborder.LineStyle=xlContinuous;
Xborder.Weight=xlThin;
//对齐方式
Xalign.HorizontalAlignment=xlCenter;
Xalign.VerticalAlignment=xlTop;
//数据类型
Xnumber.GetText();
//字体
Xfont.Bold=TRUE;
Xfont.ForeColor=RGB(64,130,230);
Xfont.Shadow=TRUE;
//字体大小
Xfont.size=20;
ExcelMain.Open();
ExcelMain.AddSheet("修正数据");
ExcelMain.GetRange("A1","L1");
ExcelMain.SetAlignment(Xalign);
ExcelMain.SetNumberFormat(Xnumber);
Xfont.size=16;
Xfont.ForeColor=RGB(0,0,0);
ExcelMain.SetFont(Xfont);
ExcelMain.SetItemText(1,1,"t/s");
ExcelMain.SetItemText(1,2,"V/(km/h)");
ExcelMain.SetItemText(1,3,"a/(m/s2)");
ExcelMain.GetRange("A2","strp");
Xborder.Color=RGB(0,0,0);//边框颜色
Xborder.Weight=xlThin;//边框厚度
ExcelMain.AutoRange();//自动量程
for(i=1;i<=nrows;i++)
{
for(j=1;j<=3;j++)
{
strTex.Format("%.9lf",Cp[i-1][j-1]);
strTex=ExcelMain.SetItemText(i+1,j,strTex);
}
}
ExcelMain.AutoColFit();
CString strPath;//定义字符串变量
CFileDialog dlg(TRUE);
if (dlg.DoModal() == IDOK)
{
strPath = dlg.GetPathName();
}
ExcelMain.SaveAs(strPath+=".xls");
MessageBox("已保存","提示",MB_OK|MB_ICONINFORMATION);
memset(B,0,sizeof(B));
free(Cp);
}