After studying Excel for a while, I also know that the worksheet can be deleted by calling the delete method of the _ worksheet object. However, I tried it many times but it failed. After repeated tests, you must clear the data in the worksheet before deleting the worksheet. Some people say no. I think it may be the difference between Office versions. I must use office2003, and 2007 may be unnecessary. Paste the code out, and the method is correct. Int cioexcel: deleteworksheet (cstring strfilepath, cstring strsheetname) {int nretval = 0; // open the file and obtain the activated sheet lpdispatch lpdisp = NULL; colevariant covoptional, vt_error); // open the file lpdisp = m_oworkbooks.open (strfilepath, _ variant_t (vtmissing ), _ variant_t (vtmissing), _ variant_t (vtmissing), _ variant_t (vt Missing), _ variant_t (vtmissing), _ variant_t (vtmissing ), _ variant_t (vtmissing); // obtain the active workbook (workbook) m_oworkbook.attachdispatch (lpdisp, true); // obtain the worksheet set values (m_oworkbook.getsheets (), true ); // obtain the specified worksheet m_oworksheet.attachdispatch (m_oworksheets.getitem (colevariant (strsheetna Me), true); values (m_oworksheet.getusedrange (), true); // clear the data m_ocurrrange.clear (); // save m_oworkbook.saveas (colevariant (strfilepath) first ), _ variant_t (vtmissing), 0, _ variant_t (vtmissing ), _ variant_t (vtmissing), _ variant_t (vtmissing )); // Delete the worksheet m_oworksheet.delete (); // Save the cursor (colevariant (strfilepath), _ variant_t (vtmissing ), _ variant_t (vtmissing), _ variant_t (vtmissing), 0, _ variant_t (vtmissing), _ variant_t (vtmissing ), _ variant_t (vtmissing); m_oworkbook.close (covoptional, colevariant (strfilepath), covoptional); M _ Oworkbooks. Close (); Return 0;} the two parameters of the function are respectively the path of the Excel file and the name of the worksheet.