Reading Excel files in VC
-
You can use Excel automation also. Make a search on google (or this website)
-
You can find info on many file formats here inclusing Excel. http://www.wotsit.org/[^] If you vote me down, my score will only get lower
-
use Excel automation CApplication app; CRange range; CWorkbook book; CWorkbooks books; CWorksheet sheet; CWorksheets sheets; VARIANT ret; COleVariant covTrue((short)TRUE),covFalse((short)FALSE),covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR); try { CoInitialize(NULL); if(!app.CreateDispatch("Excel.Application")) { AfxMessageBox("Cannot start Excel"); return; } books = app.get_Workbooks(); book = books.Open(fname,covOptional,covOptional,covOptional,covOptional ,covOptional,covOptional,covOptional,covOptional ,covOptional,covOptional,covOptional,covOptional ,covOptional,covOptional); // different for different ver of Excel // check msdn website sheets = book.get_Worksheets(); sheet = sheets.get_Item(COleVariant((short)1)); sprintf(cell,"%c%d",alpha[k],j); // eg A1, A2, etc range = sheet.get_Range(COleVariant(cell),COleVariant(cell)); ret = range.get_Value2(); CString t = ret.bstrVal; // t will hold the value of the cell books.Close(); app.Quit(); // close excel application remember to close application } catch(COleException *e) { char buf[1024]; sprintf(buf, "COleException %081x.", (long)e->m_sc); } catch(COleDispatchException *e) { char buf[1024]; sprintf(buf, "COleDispatchException %081x.", (long)e->m_wCode); } catch(...) { char buf[1024]; sprintf(buf, "General Exception"); } hope tis helps Thomas