📄 wzjoffice.h
字号:
#if !defined(AFX_WZJOFFICE_H__5E694706_F031_4E02_9674_69A4B7300931__INCLUDED_)
#define AFX_WZJOFFICE_H__5E694706_F031_4E02_9674_69A4B7300931__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "atlbase.h"
#include "msword.h"
#include "comdef.h"
#include <afxdisp.h> //COlVirant
/**********************************************************************************
* 类名: CWzjOffice,CWzjWordOffice,CWzjExcelOffice 头文件 WzjOffice.h
* 描述: Office操作(WORD,EXCEL) 信息: 汪自军 吉林大学 2007.01
* 联系: wzj23020723@163.com TM: 39600719
* blog: www.blog.163.com/wzj23020723
*
************************************************************************************/
//============================CWzjOffice=============================================
class CWzjOffice
{
public:
CWzjOffice();
virtual ~CWzjOffice();
};
//===================================================================================
//===================================================================================
//===========================CWzjWordOffice==========================================
class CWzjWordOffice:CWzjOffice
{
private:
public:
_Application m_wdApp;
Documents m_wdDocs;
_Document m_wdDoc;
_Font m_wdFt;
Selection m_wdSel;
Table m_wdTb;
InlineShapes m_wdInlineShapes;
InlineShape m_wdInlineShape;
COleVariant vTrue;
COleVariant vFalse;
COleVariant vOpt;
public:
CWzjWordOffice();
virtual ~CWzjWordOffice();
//操作
//**********************创建新文档*******************************************
BOOL CreateApp(); //创建一个新的WORD应用程序
BOOL CreateDocumtent(); //创建一个新的Word文档
BOOL Create(); //创建新的WORD应用程序并创建一个新的文档
void ShowApp(); //显示WORD文档
//**********************文本书写操作*******************************************
void WriteText(CString szText); //写文本
void NewLine(int nLineCount); //回车换N行
void WriteNewLineText(CString szText, int nLineCount = 1); //换N行写字
//**********************表格操作*******************************************
void CreateTable(int nRow, int nColumn);
void WriteCellText(int nRow, int nColumne, CString szText); //往表格中写字
void WriteCellNewLineText(int nRow, int nColumne, CString szText, int nLineCount = 1); //表格换N行写字
void New2StringArray(CString** pszArr, int nRow, int nColumn); //创建二维字符串数组
void WriteTableText(CString** pszText, int nRow, int nColumn); //用二维字符串数组填充表格
void SelectCell(int nRow, int nColumn); //选中表格
//*********************字体设置*******************************************
void SetFont(CString szFontName, float fSize = 9, long lFontColor = 0, long lBackColor=0);
void SetFont(BOOL bBold, BOOL bItalic = FALSE, BOOL bUnderLine = FALSE);
void SetTableFont(int nRow, int nColumn, CString szFontName = "宋体", float fSize=9, long lFontColor=0, long lBackColor = 0);
void SetTableFont(int nRow, int nColumn, BOOL bBold, BOOL bItalic = FALSE, BOOL bUnderLine = FALSE);
//*********************格式设置*******************************************
void SetParaphformat(int nAlignment);//文字对齐方法
//*********************标题设置*******************************************
void SetTitle(int nStyle);// -2为一级标题,...,-10为九级标题
//*********************行间距*******************************************
void SetLineSpace(int nDistance);
//*********************保存文档*******************************************
void SaveAs(CString WordName);
//*********************关闭文档*******************************************
void Close();
//*********************插入图片*******************************************
void AddPic(CString FileName);
};
#endif // !defined(AFX_WZJOFFICE_H__5E694706_F031_4E02_9674_69A4B7300931__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -