|
Hello people,
I wish to save an excel sheet programmatically
I tried using the following:
_Application app;<br />
.<br />
.<br />
COleVariant strFile(_T("C:\\Temp\\Disc.xls"));<br />
app.SaveWorkspace(strFile);
BUt this does not save it by itself, it instead opens a 'Save As' box when i had expected it save it automatically as Disc.xls at location C:\Temp\
Is there something wrong in waht i m doing?? Or how do i achieve it...
|
|
|
|
|
There are normally 3 objects of interest when automating excel the Application, the Workbook, and the Worksheet. Instead of trying to save the Workspace why not save the Worksheet or Workbook. Both of those objects have a SaveAs method.
|
|
|
|
|
i tried using workbook.SaveAs()....but i am not getting the hang of parameters i need to pass...i tried searching on the net too.....didnt find anything...can you help??
All i want to do is save in a specified path as a specified type..
Can you provide me an example??
|
|
|
|
|
Try this
<br />
COleVariant varFile(_T("C:\\Temp\\Disc.xls"));<br />
COleVariant varFileFormat((long)0xFFFFEFD1);<br />
COleVariant varTRUE((short)-1,VT_BOOL);<br />
COleVariant varFALSE((short)0,VT_BOOL);<br />
COleVariant varOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);<br />
workbook.SaveAs(varFile, varFileFormat, varOptional, varOptional, varTRUE, varFALSE, 1, varOptional, varTRUE, varOptional, varOptional);<br />
|
|
|
|
|
Thanks a lot it worked[ ]
|
|
|
|
|
I am using a two dimensional array to read the image data.If i increase the indexes to large value >500 i am getting Unhandled exception:stack overflow.How to overcome this problem.
Regards
|
|
|
|
|
Some code and more detailed informations would be welcome.
|
|
|
|
|
Firstly, show some details or you have little hope of getting help. I would guess you're storing the array on the stack; if it's a really big array the heap is the correct choice. Let’s do some calculations. Assume a 2D array of int s with each dimension set to 500. The space required is: sizeof(int) *500*500 = 4*500*500 = 1,000,000. That’s nearly a megabyte on the stack! The default stack size used by the linker is 1 MB. If I’m correct nearly all your stack is being used by one variable!
Steve
|
|
|
|
|
Hi all. I've been trying to use openmp directives to boost preformance. I've managed to make it work, by using stuff like #pragma omp parallel for . But it doesn't work correctly: instead of improving performance, i get better results without it. I've tried different scenarios without results. Has anyone encountered such problems, or used OpenMP successfully so I may get some tips ?
there are no facts, only interpretations
|
|
|
|
|
Maybe your parallelization strategy for this specific loop is causing cache misses. Try redesigning the loop and see if you can improve cache hits. Its very important to test several variations of the critical loop. Also test both shared and privatization clauses on some variables, you may get better performance through selective privatization. Keep in mind not all nested loops benefit from parallelization.
Best Wishes,
-David Delaune
|
|
|
|
|
on windows platform,how to program judge Trojan wooden horse with c++.
many trojan wooden horse programs exist as dll file, how can they run?
how do trojan wooden horse infall pc.
|
|
|
|
|
NiHao, Is google translator not working again?
A dll on it's own is harmless, but when a program loads it, the bad code inside will run. A virus scanner looks at the bytes inside any memory looking for a specific sequence 's of bytes.
|
|
|
|
|
In SDI project I need to call some function that create in CView at CDocument class.
but when I declare as CMyView m_view in header file of *Doc.h I got a lot of error.
Please give me some idea for solve this problem.
|
|
|
|
|
use a forward declaration for the view...
// In the CYourDocument header file toward the top
class CYourView;
|
|
|
|
|
Also, here's a method you can create in your document class that will simplify getting the view pointer.
// Document declaration file (.h)
public:
CYourView* GetView();
// Document implementation file (.cpp)
CYourView* CYourDoc::GetView()
{
// Assumes this is an SDI app
POSITION position=GetFirstViewPosition();
if (position) {
return (CYourView*)GetNextView(position); // Get the only view
}
return NULL;
}
|
|
|
|
|
use this code may it help
CFrameWnd *pFrame = (CFrameWnd *)AfxGetApp()->m_pMainWnd;
CYourView *pView = (CYourView *)pFrame->GetActiveView();
Regards,
Pankaj Sachdeva
"There is no future lies in any job"
"but"
"future lies in the person who holds the job"
|
|
|
|
|
In my application I have to add a Menu Item in the System Pop-up Menu, just like Winzip does.
So that, I can manipulate my application from the menu, whenever I Right-clicked on any file.
I couldn't find any way out about how to do this. Please guide me to write the code in MFC and
also please tell, what are the necessary Registry Key entries for doing this during the installation of the application?
Sudipta Mukherjee
|
|
|
|
|
|
When you say "system menu" I believe you mean the right-click menu in Windows Explorer?
Search in MSDN for "Shell Basics" and then look at the "Extending the Shell" section onwards.
|
|
|
|
|
Hi~
I made Dialog Box and I put a button for creating new window named CBrowserWnd
Which has base class CFrameWnd or CWnd.
What I would like to know is how to apply the CHtmlView to CBrowserWnd.
In Single or Multiple Document CWinApp DocTemplate do this job.
but I don't know how to apply CHtmlView to CBrowserWnd without using
DocTemplate?.....
heres my signature
|
|
|
|
|
You could try reading here[^] and creating a sample BrowserApp to see what the MFC Wizard does, and/or examine the MFCIE Sample[^] for guideance
|
|
|
|
|
Thank you for your kind answer....^^
is it possible to combine CMyView with CMyFrameWnd without supporting Document/View architecture in the AppWizard...? I am using dialog based program. and I know that dialog based doesn't support the Document/View architecture.... so I put a button which creates popup window(CFrameWnd) so I need to know how to combine the CMyView(CHtmlView) and CMyFrameWnd.
-- modified at 1:30 Thursday 30th August, 2007
heres my signature
|
|
|
|
|
The MFC normally creates the View in response to the OnCreate message invoked as a result of LoadFrame. I see no reason why you couldnt do the same thing.
Alternately you could use the MFC Wizard to create a new SDI application with the Document/View architecture using CHtmlView as the view and then migrate the neccessary bits into your project (the frame, document and view).
|
|
|
|
|
Hi all,
I made a modified version of MBrooker's extended mime to extract embedded files of .eml messages, I was able to make it but unfortunately I have to break the standard content type, instead of Multipart/mixed I used Multipart/related:
virtual inline BOOL MakeMimeHeaderTwo(CStringA& header, LPCSTR szBoundary) throw()
{
_ATLTRY
{
if (!*szBoundary)
{
header.Format("X-Priority: %d\r\n%s", m_nPriority, (LPCSTR) m_XHeader);
}
else if (m_BodyParts.GetCount() > 1)
{
header.Format("X-Priority: %d\r\n%sMIME-Version: 1.0\r\nContent-Type: multipart/related;\r\n\tboundary=\"%s\"\r\n",
m_nPriority, (LPCSTR) m_XHeader, szBoundary);
}
return TRUE;
}
_ATLCATCHALL()
{
return FALSE;
}
}
Now the solution I am thinking of is to create a new boundary for the multipart/related part of the msg so I can still use the standard Multipart/mixed, now my question is how can I do that?
From my analysis there will be a lot of changes at altmime.h
Is there a way to create a new boundary?
any suggestions of course will be welcome and thanked.
Thank you,
Monsieur Jj
|
|
|
|
|
I made my own version of writedata
virtual BOOL WriteData(HANDLE hFile, LPOVERLAPPED pOverlapped, LPCSTR szBoundary=NULL, DWORD dwFlags = 0) throw()
{
if (pOverlapped == NULL)
{
return FALSE;
}
char szBoundaryBuf[ATL_MIME_BOUNDARYLEN+1];
if(MakeBoundary(szBoundaryBuf,ATL_MIME_BOUNDARYLEN+1) == FALSE)
return FALSE;
if (szBoundary && *szBoundary != '\0')
{
_ATLTRY
{
CStringA strHeader;
strHeader.Format("\r\n\r\n--%s\r\nContent-Type: message/rfc822\r\n\tname=\"%s\"\r\nContent-Transfer-Encoding: 8bit\r\n"
"Content-Disposition: attachment;\r\n\tfilename=\"%s\"\r\n\r\n",
szBoundary, m_szDisplayName, m_szDisplayName);
if (!AtlSmtpSendAndWait(hFile, ((LPCSTR)strHeader), strHeader.GetLength(), pOverlapped))
{
return FALSE;
}
}
_ATLCATCHALL()
{
return FALSE;
}
}
if (!CMimeHeader::WriteData(hFile, pOverlapped, szBoundaryBuf, dwFlags))
return FALSE;
CStringA strHeader;
char szBoundaryBufTwo[ATL_MIME_BOUNDARYLEN+1];
if (MakeMimeHeader(strHeader, szBoundaryBuf))
{
MakeBoundary(szBoundaryBufTwo,ATL_MIME_BOUNDARYLEN+1);
MakeMimeHeaderTwo(strHeader, szBoundaryBufTwo);
}
else
{
return FALSE;
}
if (!AtlSmtpSendAndWait(hFile, ((LPCSTR)strHeader), strHeader.GetLength(), pOverlapped))
{
return FALSE;
}
CMimeBodyPart* pCurrPart;
POSITION currPos = m_BodyParts.GetHeadPosition();
while (currPos != NULL)
{
pCurrPart = m_BodyParts.GetAt(currPos);
if (pCurrPart->GetContentType()== "text/html"){
if (!pCurrPart->WriteData(hFile, pOverlapped, szBoundaryBuf, dwFlags))
{
return FALSE;
}
m_BodyParts.GetNext(currPos);
}
else
{
if (!pCurrPart->WriteData(hFile, pOverlapped, szBoundaryBufTwo, dwFlags))
{
return FALSE;
}
m_BodyParts.GetNext(currPos);
}
}
char szBuf[ATL_MIME_BOUNDARYLEN+(sizeof("\r\n\r\n--%s--\r\n"))];
if (*szBoundaryBuf)
{
#if _SECURE_ATL
int nBufLen = sprintf_s(szBuf, ATL_MIME_BOUNDARYLEN+(sizeof("\r\n\r\n--%s--\r\n")),
"\r\n\r\n--%s--\r\n", szBoundaryBuf);
#else
int nBufLen = _snprintf(szBuf, ATL_MIME_BOUNDARYLEN+(sizeof("\r\n\r\n--%s--\r\n")),
"\r\n\r\n--%s--\r\n", szBoundaryBuf);
#endif
if ((nBufLen < 0) || (!AtlSmtpSendAndWait(hFile, szBuf, nBufLen, pOverlapped)))
{
return FALSE;
}
}
return TRUE;
}
Now i have a different output i have the working boundary for the whole mime unfortunately I only want them for the embedded attachments, how can I do this? Can anyone make a change to the code above?
Then it is enclosed by another boundary the first I made unfortunately it has no header content-type which i expect to be multipart/mixed, it is being over written by multipart/related eventhough i already changed the function names for them so they will be performed both, How can I write both headers?
|
|
|
|