请教如何保存excel文档而不弹出保存对话框,谢谢
小弟使用的代码如下:
bool __fastcall TWMain::PaintExcelImage(AnsiString strFile)
{
Variant ExcelApp, WorkBook1, Sheet1, Range1, Chart1;
int iCount;
String strInfo;
try
{
ExcelApp = Variant::CreateObject("Excel.Application");
}
catch (...)
{
strInfo = "无法创建excel对象,请确认本机已正确安装excel。";
MessageBox(this->Handle, strInfo.c_str(), "警告", MB_OK + MB_ICONWARNING);
return false;
}
ExcelApp.PS("Visible", (Variant)false);
WorkBook1 = ExcelApp.PG("workbooks").FN("open", strFile);
Sheet1 = WorkBook1.PG("ActiveSheet");
// 读取行数
iCount = Sheet1.PG("UsedRange").PG("Rows").PG("Count");
// 选择数据区
strInfo = "A1:B" + String(iCount);
Range1 = Sheet1.PG("Range", strInfo.c_str());
//Range1 = Sheet1.Exec(PropertyGet("Range")<<strInfo);
// 插入Chart对象
Chart1 = ExcelApp.Exec(PropertyGet("Charts")).Exec(Function("Add"));
// 显示到当前Sheet上
Chart1.FN("Location", 2, Sheet1.PG("Name")); // ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet2"
Chart1 = ExcelApp.PG("ActiveChart");
Chart1.PS("ChartType", 65);
//Chart1.FN("SetSourceData", Range1, 0);
Chart1.Exec(Function("SetSourceData")<<Range1<<2);
// 保存工作簿
WorkBook1.FN("Save");
// 退出excel
ExcelApp.Exec(Procedure("Quit"));
//ExcelApp.FN ("Quit");
//ExcelApp = Unassigned;
return true;
}
在执行退出excel的语句(ExcelApp.Exec(Procedure("Quit")))后,软件弹出了是否保存excel的提示框,我上面已经调用了save方法,为什么还会提示保存呢?
请高人指点,不胜感激。