Y
youhow
Hi,All, I'm using VC++ to export data to EXCEL, if i dont add sheet in
workbook, the EXCEL and QUIT normally, but when I add new sheets in
workbook, the EXCEL can not Quit, how to solve the problem.thx.
the souce code
_Application m_App;
Workbooks m_Books;
_Workbook m_Book;
Worksheets m_Sheets;
_Worksheet m_Sheet;
......
m_App.SetVisible(FALSE);
m_App.SetDisplayAlerts(FALSE);
//create a Xls file
m_Books.AttachDispatch(m_App.GetWorkbooks());
lpDisp = m_Books.Add(covOptional);
//Get workbook
m_Book.AttachDispatch(lpDisp);
//get Worksheets
m_Sheets.AttachDispatch(m_Book.GetWorksheets());
//add sheets
for(i = m_Sheets.GetCount(); i <= 10; i ++)
m_Sheets.Add(covOptional, covOptional, covOptional, covOptional);
.......
//Save excel file
m_Book.SaveAs(COleVariant(m_strXLSName),covOptional,covOptional,
covOptional,covOptional,covOptional,0,
covOptional,covOptional,covOptional,covOptional);
m_Book.Close(covOptional, COleVariant(m_strXLSName), covOptional);
m_Books.Close();
m_App.Quit();
workbook, the EXCEL and QUIT normally, but when I add new sheets in
workbook, the EXCEL can not Quit, how to solve the problem.thx.
the souce code
_Application m_App;
Workbooks m_Books;
_Workbook m_Book;
Worksheets m_Sheets;
_Worksheet m_Sheet;
......
m_App.SetVisible(FALSE);
m_App.SetDisplayAlerts(FALSE);
//create a Xls file
m_Books.AttachDispatch(m_App.GetWorkbooks());
lpDisp = m_Books.Add(covOptional);
//Get workbook
m_Book.AttachDispatch(lpDisp);
//get Worksheets
m_Sheets.AttachDispatch(m_Book.GetWorksheets());
//add sheets
for(i = m_Sheets.GetCount(); i <= 10; i ++)
m_Sheets.Add(covOptional, covOptional, covOptional, covOptional);
.......
//Save excel file
m_Book.SaveAs(COleVariant(m_strXLSName),covOptional,covOptional,
covOptional,covOptional,covOptional,0,
covOptional,covOptional,covOptional,covOptional);
m_Book.Close(covOptional, COleVariant(m_strXLSName), covOptional);
m_Books.Close();
m_App.Quit();