亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? excel_automation.shtml

?? mfc資源大全包含MFC編程各個方面的源碼
?? SHTML
?? 第 1 頁 / 共 2 頁
字號:
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Zafir Anjum">
   <TITLE>Misc - Doing Excel Automation witch MSVC</TITLE>
</HEAD>
<body background="../fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000" bgproperties="fixed">
<table WIDTH="100%">
<tr WIDTH="100%">
<td><!--#exec cgi="/cgi/ads.cgi"--><td>
</tr>
</table>

<CENTER>
<H3>
<FONT COLOR="#AOAO99">Doing Excel Automation witch MSVC</FONT></H3></CENTER>
<HR>


This article was contributed by <A HREF="mailto:blenkers@anachem.ruhr-uni-bochum.de"> Thomas Blenkers</A>.


<P>Now fasten your seatbelt and be prepared for a real fast flight across
MSVC, Excel and Automation. I don't really want to teach you understanding
automation, rather I like to have your job done. :)

<P>Please bear in mind, that I will describe one special task here: storing
some information as an Excel sheet with auto-sized coloumns. I am using
MSVC 5.0 and the MFC.

<P>I already have a prepared text file containing the information I would
like to store. I did this using semikolon (;) separated ascii-output with
new-line\carriage-return pairs at the end of each line. (To say it in plain
MFC, I used the CStdioFile class with the WriteString method)

<P>If you are working with the Excel classes, you need to deal with the
VARIANT data type or, more convient when using MFC, with the COleDispatch
class, which has a built-in interface and is more easy to use.

<P>A caveat of this approach that you have to modify the automation classes
by hand, but this caveat is supersed by the ability of removing unneeded
(and sometime ununderstood) parameters from the method calls.

<P>Before going through the step-by-step procedure, something tells me
that you probably like to <A HREF="excel_automation.zip">download my project
file</A> (96K).

<H4>Step zero: Record your task as Excel macro</H4>
First of all, you will have to be used to Excel's VBA macro language. It
is VERY helpful if you first do the task you'd like to do in Excel while
recording this task as a macro.

<P>The macro will look somewhat like this, hence, that VBA is nicely object
oriented:

<FONT COLOR="#990000">
<P><TT>Sub Macro1()</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; Workbooks.OpenText Filename:="C:\Example.txt",
Origin:= _</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlWindows, StartRow:=1,
DataType:=xlDelimited, TextQualifier _</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :=xlDoubleQuote, ConsecutiveDelimiter:=False,
Tab:=False, _</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Semicolon:=True, Comma:=False,
Space:=False, Other:=False, _</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FieldInfo:=Array(1,
1)</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; Cells.Select</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; Selection.Columns.AutoFit</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; Workbook(1).SaveAs Filename:="C:\temp\README.xls",
FileFormat:= _</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlNormal, Password:="",
WriteResPassword:="", _</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReadOnlyRecommended:=False,
CreateBackup:=False</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; ActiveWindow.Close</TT>
<BR><TT>End Sub</TT>
</FONT>


<BR>&nbsp;
<H4>Step one: Create the Excel automation classes</H4>
In your Excel program directory you will find the Type Library for the
Excel automation. I think, all of you will have the english version, Xl5en32.olb,
along with perhaps some localized version of this (e.g. the german version
is shipped with a Xl5de32.olb).

<P>Using the Class Wizard, choose "New Class" and "from a type library"
(I have the german version, so I don't know the exact english menu commands).
You are then asked to enter the path and filename of the type library.
Having done you get a list of classes. Looking at the Excel macro you see
which classes are needed. I needed five flasses (Application, Range, Workbook,
Workbooks, Worksheet). When in doubt you may choose all classes, but then
you have a bunch of classes that you don't need.
<BR>&nbsp;

<H4>Step two: Add methods for opening and closing Excel</H4>
In your class needing Excel create a member variable holding the Excel's
application object

<FONT COLOR="#990000">
<P><TT><FONT COLOR="#3366FF">class</FONT> CMyDemoDlg : <FONT COLOR="#3366FF">public
</FONT>CDialog</TT>
<BR><TT>{</TT>
<BR><TT><FONT COLOR="#009900">&nbsp;// the ususal things</FONT></TT>
<BR><TT>&nbsp;...</TT>

<P><TT><FONT COLOR="#3366FF">private:</FONT></TT>
<BR><TT>&nbsp;Application m_Excel_en;</TT>

<P><TT>&nbsp;...</TT>
<BR><TT><FONT COLOR="#009900">&nbsp;// other usual things</FONT></TT>
<BR><TT>}</TT>
</FONT>

<P>and the two functions OpenExcel() and CloseExcel() as follows:

<FONT COLOR="#990000">
<P><TT><FONT COLOR="#3366FF">bool </FONT>CMyDemoDlg::OpenExcel()</TT>
<BR><TT>{</TT>
<BR><TT><FONT COLOR="#3366FF">&nbsp;&nbsp;&nbsp; if </FONT>(!m_bExcelStarted)
<FONT COLOR="#009900">// this is a member-variable of type bool</FONT></TT>
<BR><TT><FONT COLOR="#3333FF">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if </FONT>(m_Excel.CreateDispatch("Excel.Application"))</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{</TT>
<BR><TT><FONT COLOR="#009900">//</FONT></TT>
<BR><TT><FONT COLOR="#009900">// un-comment these lines, is you want to
see what Excel is doing</FONT></TT>
<BR><TT><FONT COLOR="#009900">//</FONT></TT>
<BR><TT><FONT COLOR="#009900">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CWnd *pExelWnd = CWnd::FindWindow("XLMAIN", NULL);</FONT></TT>
<BR><TT><FONT COLOR="#009900">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (pExelWnd )</FONT></TT>
<BR><TT><FONT COLOR="#009900">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{</FONT></TT>
<BR><TT><FONT COLOR="#009900">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pExelWnd->ShowWindow(SW_SHOWNORMAL);</FONT></TT>
<BR><TT><FONT COLOR="#009900">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pExelWnd->UpdateWindow();</FONT></TT>
<BR><TT><FONT COLOR="#009900">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pExelWnd->BringWindowToTop();</FONT></TT>
<BR><TT><FONT COLOR="#009900">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</FONT></TT>
<BR><TT><FONT COLOR="#009900">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
BringWindowToTop();</FONT></TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
m_bExcelStarted=<FONT COLOR="#3366FF">true</FONT>;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</TT>
<BR><TT><FONT COLOR="#3366FF">&nbsp;&nbsp;&nbsp; return </FONT>m_bExcelStarted;</TT>
<BR><TT>}</TT>

<P><TT><FONT COLOR="#3333FF">bool </FONT>CMyDemoDlg::CloseExcel()</TT>
<BR><TT>{</TT>
<BR><TT><FONT COLOR="#3333FF">&nbsp;&nbsp;&nbsp; if </FONT>(m_bExcelStarted)</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Excel_en.Quit();</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Excel_en.ReleaseDispatch();</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bExcelStarted=false;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; <FONT COLOR="#3333FF">return </FONT>m_bExcelStarted;</TT>
<BR><TT>}</TT>
</FONT>

<P>In you application class add to the following lines to InitInstance():

<FONT COLOR="#990000">
<BR><TT>BOOL CMyDemoApp::InitInstance()</TT>
<BR><TT>{</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; // initialize OLE libraries</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; <FONT COLOR="#3333FF">if </FONT>(!AfxOleInit())</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AfxMessageBox(IDP_OLE_INIT_FAILED);</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#3333FF">return</FONT>
FALSE;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; }</TT><TT></TT>

<P><TT>&nbsp;&nbsp;&nbsp; // do all the other things</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; ...</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; <FONT COLOR="#3333FF">return </FONT>TRUE;</TT>
<BR><TT>}</TT><TT></TT>
</FONT>

<P>In your stdafx-Header you need to add the following line to include
the MFC automation support

<FONT COLOR="#990000">
<BR><TT>...</TT>
<BR><TT><FONT COLOR="#3333FF">#include </FONT>&lt;afxdisp.h>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<FONT COLOR="#009900">// MFC OLE-automation classes</FONT></TT>
<BR><TT>...</TT>
<BR><TT></TT>&nbsp;
</FONT>


<H4>Step three-and-four-combined: Start building the Excel macro as C++ Code while modifying the automation classes.</H4>
For every parameter you need, create a local variable of type COleVariant.
In Excel's VBA you can omit parameter not needed. In the Excel automation
classes you can omit the parameters you do not need IF AND ONLY IF they
are at the end of the method's parameters list. In the Excel-class create
a new overloaded member function with fewer parameters.

<P>All automation functions, whose return value is used to create another automation
object should be modified to return a LPDISPATCH pointer rather than a VARIANT!

<P>So, for example, you should take the method

<FONT COLOR="#990000">
<BR><TT>VARIANT Application::Worksheets(<FONT COLOR="#3366FF">const </FONT>VARIANT&amp;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久99精品免费观看| 久久亚洲精品国产精品紫薇| 免费成人美女在线观看.| 国产精品视频九色porn| 欧美精品一区二区久久久| 欧美精品视频www在线观看| av高清不卡在线| 夫妻av一区二区| 成人自拍视频在线观看| 99久久精品99国产精品| 色视频欧美一区二区三区| 国产99久久精品| 91精品国产91综合久久蜜臀| 69av一区二区三区| 精品久久久久久久一区二区蜜臀| 日韩精品一区二区三区中文不卡| 精品国产一区二区三区久久久蜜月 | 欧美亚洲免费在线一区| 色哟哟一区二区在线观看 | 欧美伊人久久久久久久久影院| 久久久99久久| 紧缚奴在线一区二区三区| 国产在线不卡一卡二卡三卡四卡| 久久国内精品自在自线400部| 国产成人高清视频| 色老综合老女人久久久| 精品久久五月天| 久久国产婷婷国产香蕉| 91麻豆精品国产91久久久久久久久 | 麻豆中文一区二区| 成人精品国产免费网站| 欧美日韩国产不卡| 国产亚洲婷婷免费| 国产成人精品免费看| 国产精品三级电影| 97se亚洲国产综合自在线不卡| 国产精品国产三级国产专播品爱网 | 2021国产精品久久精品| 九色综合国产一区二区三区| 久久综合成人精品亚洲另类欧美| 黄色小说综合网站| 一本一本久久a久久精品综合麻豆| 亚洲视频在线观看三级| 日本不卡一区二区三区高清视频| 成人免费视频免费观看| 亚洲色图欧洲色图| 欧美午夜片在线看| 日本午夜一本久久久综合| 精品免费一区二区三区| 不卡视频一二三| 亚洲综合无码一区二区| 国产精品中文字幕日韩精品| 在线综合亚洲欧美在线视频| 精品在线观看视频| 国产精品女主播av| 欧美羞羞免费网站| 久久激情五月激情| 日韩毛片在线免费观看| 欧美放荡的少妇| 国产成人超碰人人澡人人澡| 一区二区三区免费网站| www.成人网.com| 午夜激情一区二区三区| 在线视频欧美区| 亚洲精品免费电影| 91亚洲精品久久久蜜桃| 中文字幕制服丝袜一区二区三区 | 日韩精品色哟哟| 欧美三级资源在线| 亚洲精品久久嫩草网站秘色| 91精品久久久久久久久99蜜臂| 国产成人亚洲综合a∨婷婷图片| 亚洲黄色在线视频| 久久尤物电影视频在线观看| 欧美无乱码久久久免费午夜一区 | 激情综合一区二区三区| 亚洲欧洲成人精品av97| 99久久er热在这里只有精品66| 日韩福利电影在线观看| 中文字幕乱码亚洲精品一区 | 欧美色综合网站| 国产麻豆视频精品| 婷婷激情综合网| 亚洲免费视频成人| 欧美日韩精品一二三区| 成人小视频在线观看| 免费高清视频精品| 亚洲一区二区中文在线| 国产精品日产欧美久久久久| 精品美女在线播放| 欧美日韩免费不卡视频一区二区三区| 成人夜色视频网站在线观看| 美女精品一区二区| 午夜激情一区二区| 亚洲国产欧美另类丝袜| 日韩午夜在线播放| 国产在线不卡一卡二卡三卡四卡| 亚洲成年人影院| 久久综合久久综合久久| 制服视频三区第一页精品| 欧美在线你懂得| 色婷婷久久99综合精品jk白丝| 成人av第一页| 成人黄色小视频| 粉嫩av一区二区三区在线播放| 国产一区二区三区久久悠悠色av| 免费不卡在线视频| 美脚の诱脚舐め脚责91| 麻豆91在线播放| 男男gaygay亚洲| 精品一区二区三区在线观看| 久久精品国产一区二区三 | 亚洲国产成人91porn| 亚洲三级视频在线观看| 中文字幕一区二区三中文字幕| 久久九九久久九九| 中文一区在线播放| 国产精品久久久久久久岛一牛影视| 国产欧美va欧美不卡在线| 欧美视频日韩视频在线观看| 欧美在线制服丝袜| 3d动漫精品啪啪1区2区免费| 日韩欧美自拍偷拍| 国产欧美精品一区二区三区四区| 国产亚洲一区二区三区在线观看| 中文在线资源观看网站视频免费不卡 | 欧美日韩美女一区二区| 欧美日本不卡视频| 日韩天堂在线观看| 国产性色一区二区| 成人欧美一区二区三区黑人麻豆 | www.在线欧美| 91久久精品网| 欧美一级日韩免费不卡| 久久久精品综合| 欧美一区二区精品| 久久久亚洲精华液精华液精华液 | 丝袜美腿一区二区三区| 久久99深爱久久99精品| 国产风韵犹存在线视精品| 色成年激情久久综合| 日韩欧美色综合网站| 国产欧美精品国产国产专区 | 亚洲视频在线观看三级| 天天综合网天天综合色| 国内成人精品2018免费看| 97久久人人超碰| 日韩你懂的在线观看| 免播放器亚洲一区| 国产91对白在线观看九色| 91成人免费在线视频| 亚洲精品一区二区三区精华液 | 欧日韩精品视频| 欧美电影免费观看高清完整版在线观看 | 欧美喷潮久久久xxxxx| 亚洲精品老司机| 色综合天天视频在线观看| 亚洲欧洲精品成人久久奇米网| 国产91精品欧美| 国产日韩欧美高清在线| 国产麻豆精品在线| 久久久国产午夜精品| 国产成人在线看| 国产欧美日韩在线看| 成人av电影在线网| 中文字幕日韩一区二区| 成人av网站在线| 亚洲欧美精品午睡沙发| 在线免费观看成人短视频| 亚洲午夜在线视频| 欧美美女bb生活片| 日韩成人一级大片| 日韩免费成人网| 国产呦精品一区二区三区网站| 26uuu国产在线精品一区二区| 国产精品综合视频| 国产精品亲子伦对白| 97se亚洲国产综合自在线观| 亚洲一区二区在线免费观看视频| 欧美色成人综合| 蜜桃一区二区三区四区| xvideos.蜜桃一区二区| 成av人片一区二区| 亚洲激情第一区| 欧美一卡二卡在线| 国产福利一区二区三区| 亚洲精品一卡二卡| 91精品国产色综合久久久蜜香臀| 国产一区视频网站| 亚洲欧美在线视频观看| 欧美性猛片aaaaaaa做受| 日本91福利区| 欧美国产日产图区| 欧美色图天堂网| 久久99久久99小草精品免视看| 久久精品一区四区| 在线免费视频一区二区| 精品一区二区三区在线播放视频 | 久久久久综合网| aaa欧美色吧激情视频|