Click here to Skip to main content
15,898,942 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionexport to excel Pin
hellogany16-Nov-08 22:54
hellogany16-Nov-08 22:54 
AnswerRe: export to excel Pin
Garth J Lancaster16-Nov-08 23:29
professionalGarth J Lancaster16-Nov-08 23:29 
GeneralRe: export to excel Pin
hellogany16-Nov-08 23:40
hellogany16-Nov-08 23:40 
GeneralRe: export to excel [modified] Pin
Garth J Lancaster17-Nov-08 0:08
professionalGarth J Lancaster17-Nov-08 0:08 
JokeRe: export to excel Pin
CPallini17-Nov-08 0:40
mveCPallini17-Nov-08 0:40 
GeneralRe: export to excel Pin
Garth J Lancaster17-Nov-08 0:46
professionalGarth J Lancaster17-Nov-08 0:46 
GeneralRe: export to excel Pin
CPallini17-Nov-08 7:47
mveCPallini17-Nov-08 7:47 
GeneralRe: export to excel Pin
hellogany17-Nov-08 17:33
hellogany17-Nov-08 17:33 
HI all,
i m using the below code , but the result saves in another excel file.
can anyone suggest y it happens?

_Application app;
Workbooks books;
_Workbook book;

Worksheets sheets;
_Worksheet s;
Range range;
Font font;
Range cols;
LPDISPATCH lpDisp; // Often reused variable.


// Commonly used OLE variants.

COleVariant
covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);


// Start Excel and get Application object.

if(!app.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Couldn't start Excel and get Application object.");
return;
}


lpDisp = app.GetWorkbooks(); // Get an IDispatch pointer.
ASSERT(lpDisp);
books.AttachDispatch(lpDisp); // Attach the IDispatch pointer
// to the books object.

// Open a new workbook and attach that IDispatch pointer to the
// Workbook object


lpDisp = books.Add( covOptional );
ASSERT(lpDisp);
book.AttachDispatch( lpDisp );

lpDisp = books.Open("D:\\test.xls",
covOptional, covFalse, covTrue, covOptional,
covOptional, covTrue, covOptional, covOptional,
covTrue, covOptional, covOptional, covOptional,
covOptional, covOptional);
// Get the Sheets collection and attach the IDispatch pointer to your
// sheets object.
*/

/* lpDisp = book.GetSheets();
ASSERT(lpDisp);
sheets.AttachDispatch(lpDisp);


// Get *** #1 and attach the IDispatch pointer to your ***
// object.
lpDisp = sheets.GetItem( COleVariant((short)(1)) );
//GetItem(const VARIANT &index)
ASSERT(lpDisp);
s.AttachDispatch(lpDisp);



// Fill range A1 with "1/25/98", the settlement date.
lpDisp =s.GetRange(COleVariant("A1"), COleVariant("A1"));
ASSERT(lpDisp);
range.AttachDispatch(lpDisp);
range.SetValue2(COleVariant("change")); // Excel 2002 and Excel 2003

// checking for the particular cell if it's empty

VARIANT value1;
char str[]="A";
char strf[]="";
int i = 1;
char str1[10];
_itoa(i,str1,10);
strcpy(strf,str);
strcat(strf,str1);
range = s.GetRange(COleVariant(strf),COleVariant(strf));
value1 = range.GetValue2();


while(!value1.vt == VT_EMPTY)
{
i++;
_itoa(i,str1,10);
strcpy(strf,str);
strcat(strf,str1);
range = s.GetRange(COleVariant(strf),COleVariant(strf));
value1 = range.GetValue2();

}

range.SetValue2(COleVariant("Country"));
book.Save();
{
COleSafeArray saRet;

saRet.Detach();
}
app.SetVisible(TRUE);
app.SetUserControl(TRUE);

QuestionERROR when accessing data from multiple tables in oracle to SDI Application with database support Pin
Divya Lalwani16-Nov-08 22:10
Divya Lalwani16-Nov-08 22:10 
QuestionRe: ERROR when accessing data from multiple tables in oracle to SDI Application with database support Pin
David Crow17-Nov-08 3:25
David Crow17-Nov-08 3:25 
Questioni need to RelayEvent,but cannot override PreTranslateMessage.... Pin
kaviniswell16-Nov-08 21:03
kaviniswell16-Nov-08 21:03 
AnswerRe: i need to RelayEvent,but cannot override PreTranslateMessage.... Pin
dupenf116-Nov-08 21:19
dupenf116-Nov-08 21:19 
GeneralRe: i need to RelayEvent,but cannot override PreTranslateMessage.... Pin
kaviniswell16-Nov-08 21:47
kaviniswell16-Nov-08 21:47 
GeneralRe: i need to RelayEvent,but cannot override PreTranslateMessage.... Pin
Roger Allen17-Nov-08 12:21
Roger Allen17-Nov-08 12:21 
GeneralRe: i need to RelayEvent,but cannot override PreTranslateMessage.... Pin
kaviniswell18-Nov-08 22:41
kaviniswell18-Nov-08 22:41 
GeneralRe: i need to RelayEvent,but cannot override PreTranslateMessage.... Pin
dupenf118-Nov-08 14:25
dupenf118-Nov-08 14:25 
GeneralRe: i need to RelayEvent,but cannot override PreTranslateMessage.... Pin
kaviniswell18-Nov-08 22:35
kaviniswell18-Nov-08 22:35 
GeneralRe: i need to RelayEvent,but cannot override PreTranslateMessage.... Pin
dupenf118-Nov-08 22:43
dupenf118-Nov-08 22:43 
GeneralRe: i need to RelayEvent,but cannot override PreTranslateMessage.... Pin
kaviniswell18-Nov-08 23:01
kaviniswell18-Nov-08 23:01 
QuestionDecryption question Pin
monsieur_jj16-Nov-08 20:49
monsieur_jj16-Nov-08 20:49 
QuestionDose someone be familar with cgfxoutbarctrl? Pin
Meng Jun16-Nov-08 19:54
Meng Jun16-Nov-08 19:54 
QuestionHow can save COLORREF value in access database ? Pin
Le@rner16-Nov-08 19:52
Le@rner16-Nov-08 19:52 
AnswerRe: How can save COLORREF value in access database ? Pin
MANISH RASTOGI16-Nov-08 20:04
MANISH RASTOGI16-Nov-08 20:04 
AnswerRe: How can save COLORREF value in access database ? Pin
Saurabh.Garg16-Nov-08 20:16
Saurabh.Garg16-Nov-08 20:16 
AnswerRe: How can save COLORREF value in access database ? Pin
CPallini16-Nov-08 21:38
mveCPallini16-Nov-08 21:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.