#pragma once
|
|
#include "pch.h"
|
|
#define DEFAULT_SHEET_NO 1
|
#define MAX_LENGTH_SCREENTIP 247
|
|
typedef struct _ExcelPosition
|
{
|
DWORD dwX;
|
DWORD dwY;
|
} ExcelPosition;
|
|
class AFX_EXT_CLASS CExcelAutomation
|
{
|
public:
|
CExcelAutomation();
|
virtual ~CExcelAutomation();
|
|
public:
|
CApplication m_kApp;
|
CWorksheet m_kSheet;
|
CWorksheets m_kSheets;
|
CWorkbook m_kBook;
|
CWorkbooks m_kBooks;
|
CRange m_kRange;
|
|
|
BOOL m_bIsAppEnable;
|
BOOL m_bIsOpen;
|
BOOL m_bIsSelect;
|
|
CString m_Filename;
|
CString m_szStartSel;
|
CString m_szEndSel;
|
|
protected:
|
char temp_buff[256];
|
|
DWORD m_nActiveSheetIndex; // ÇöÀç ActiveµÈ Sheet ¹øÈ£
|
ExcelPosition m_stLastPosition; // ¸¶Áö¸·À¸·Î »ç¿ëÇÑ Excel À§Ä¡
|
ExcelPosition m_stLastSearch; // ¸¶Áö¸·À¸·Î °Ë»öÇÑ Excel À§Ä¡
|
|
public:
|
BOOL CreateDispatch();
|
void ShowException(LPOLESTR szMember, HRESULT hr, EXCEPINFO *pexcep, unsigned int uiArgErr);
|
|
//-------------------------------------------------------------------------------------------------
|
// Application
|
void Init( CString strPathName = _T(""), DWORD dwSheetIndex = 1 );
|
BOOL CreateExcelFile();
|
BOOL Open( const CString strFilename );
|
BOOL Save( BOOL bIsOverWrite);
|
BOOL SaveAs( BOOL bIsOverWrite, const CString strFilename );
|
void Close();
|
|
//-------------------------------------------------------------------------------------------------
|
// Workbook(s)
|
BOOL ChangeActiveWorkbook( CString strPathName );
|
BOOL ChangeActiveWorkbook( long lBook );
|
long GetBookCount();
|
|
//-------------------------------------------------------------------------------------------------
|
// WorkSheet(s)
|
BOOL AddSheet( DWORD dwSheetIndex, CString strSheetName, BOOL bBeforeOrAfter = TRUE ); // FALSE : Before, TRUE : After
|
BOOL DeleteSheet( CString strSheetName );
|
BOOL DeleteSheet( DWORD dwSheetIndex );
|
BOOL DeleteAllSheet();
|
BOOL SetSheetName( DWORD dwSheetIndex, CString strName );
|
CString GetSheetName( DWORD dwSheetIndex );
|
BOOL ChangeSheetName( DWORD dwSheetIndex, CString strSheetName );
|
BOOL SetActiveSheet( DWORD dwSheetIndex );
|
BOOL SetActiveSheetCell( DWORD dwSheetIndex, const CString strStartSel, const CString strEndSel );
|
BOOL SetActiveSheet( CString strSheetName );
|
BOOL CopySheets( CString strPathNameSrc, CString strPathNameDest, CString strSheetNameDest, BOOL bBeforeOrAfter = TRUE ); // FALSE : Before, TRUE : After
|
BOOL CopySheets( CString strPathNameSrc, CString strPathNameDest, long lSheetDest, BOOL bBeforeOrAfter = TRUE ); // FALSE : Before, TRUE : After
|
BOOL CopySheet( CString strPathNameSrc, CString strSheetNameSrc, CString strPathNameDest, CString strSheetNameDest, BOOL bBeforeOrAfter = TRUE ); // FALSE : Before, TRUE : After
|
BOOL CopySheet( CString strPathNameSrc, long lSheetSrc, CString strPathNameDest, long lSheetDest, BOOL bBeforeOrAfter = TRUE ); // FALSE : Before, TRUE : After
|
|
long GetSheetCount();
|
void SetRowHeight(const CString strStartSel, const CString strEndSel, short sHeight);
|
float GetRangeWidth(const CString strStartSel, const CString strEndSel);
|
float GetRangeHeight(const CString strStartSel, const CString strEndSel);
|
void GetCurrentRangeTopPosition(const CString strStartSel, const CString strEndSel);
|
|
|
void SetVisible( BOOL bSet = TRUE );
|
|
long GetMaxRows(int nSheetIndex);
|
long GetMaxCols(int nSheetIndex);
|
|
BOOL Select(int nSheetIndex, const CString strStartSel, const CString strEndSel);
|
void UnSelect();
|
|
CString GetData(int nSheetIndex, const CString strSel);
|
void SetData(const CString strFillData);
|
void SetData(int nSheetIndex, const CString strSel, const CString strFillData);
|
void SetData(int nSheetIndex, const CString strStartSel, const CString strEndSel, const CString strFillData);
|
void SetData(int nSheetIndex, const CString strSel, const CString strFillData, int nFormat);
|
void SetData(int nSheetIndex, const CString strStartSel, const CString strEndSel, const CString strFillData, int nFormat);
|
|
void SetMergeColorData(int nSheetIndex, const CString strStartSel, const CString strEndSel, const CString strFillData,
|
COLORREF cBGColor = NULL, BOOL bMerge = TRUE);
|
|
void SetFormula(int nSheetIndex, const CString strSel, const CString strFillData);
|
void SetFormula(int nSheetIndex, const CString strStartSel, const CString strEndSel, const CString strFillData);
|
|
void SetDataFormat( int nFormat );
|
void SetAlign( int nHAlign, int nVAlign, BOOL bIsOrientation = FALSE );
|
void SetHorizontalAlign( int nHAlign );
|
void SetVerticalAlign( int nVAlign );
|
void SetAlignment( CString strCellAddrsrt, CString strCellAddr2end, short iHorizontal, short iVertical );
|
|
void SetFont( short nSize, const CString Fontname, BOOL bIsItalic, BOOL bIsUnderLine, BOOL bIsBold, COLORREF color = NULL );
|
void SetFont( CString strCellAddrsrt, CString strCellAddr2end, BOOL bBold, short iSize, CString strFontName, COLORREF color );
|
void SetLine( short nLineStyle, short nWeight );
|
void SetColor( int nRed, int nGreen, int nBlue );
|
void SetColor( COLORREF crColor );
|
|
void SetMerge();
|
void SetAutoFit();
|
|
void AutoFitColumns( CString strCellAddrsrt, CString strCellAddr2end );
|
void SetColumnWidth( CString strCellAddr, long lWidth );
|
void SetForeColor( CString strCellAddrsrt, CString strCellAddr2end, COLORREF color );
|
void SetBackColor( CString strCellAddrsrt, CString strCellAddr2end, COLORREF color );
|
void DrawBorders( CString strCellAddrsrt, CString strCellAddr2end, short iLineStyle, short iWeight );
|
void DrawBorder( CString strCellAddrsrt, CString strCellAddr2end, short iLineStyle, short iWeight, long lBordersIndex );
|
void SetHyperlink( CString strCellAddr, CString strCellLink, CString strScreenTip, CString strDisp );
|
void MoveToCell( CString strSheetName, CString strCellAddr );
|
void MoveToCell( long lSheet, CString strCellAddr );
|
void SetFormula( CString strCellAddrsrt, CString strCellAddr2end, CString strValue );
|
long GetNumRows();
|
long GetNumCols();
|
BOOL CopyRange( CString strPathNameSrc, long lSheetSrc, CString strCellAddrsrtSrc, CString strCellAddr2endSrc, CString strPathNameDest, long lSheetDest, CString strCellAddrDest );
|
void DeleteRange( CString strCellAddrsrt, CString strCellAddr2end, short iDeleteShiftDirection );
|
void AutoFilter( CString strCellAddrsrt, CString strCellAddr2end );
|
void AddComment( CString strSheetName, CString strCellAddr, CString strComment, float fWidth, float fHeight );
|
void SetConditionalFormat( CString strCellAddrsrt, CString strCellAddr2end, long lType, CString strFormula, COLORREF color );
|
|
void Insert( CString strCellAddrsrt, CString strCellAddr2end, short iShiftDirection, short iCopyOrigin );
|
void AutoFill( CString strCellAddrsrt1, CString strCellAddrsrt2, CString strCellAddr2end );
|
void ClearContents( CString strCellAddrsrt, CString strCellAddr2end );
|
|
BOOL GetEnableApp() { return m_bIsAppEnable; }
|
BOOL GetOpenFile() { return m_bIsOpen; }
|
BOOL GetSelect() { return m_bIsSelect; }
|
|
CString GetStartSel() { return m_szStartSel; }
|
CString GetEndSel() { return m_szEndSel; }
|
|
DWORD GetCurrentSheetIndex() { return m_nActiveSheetIndex; }
|
void SetCurrentSheetIndex( DWORD nIndex ) { m_nActiveSheetIndex = nIndex; }
|
|
char* GetSheetCellPosition(int nCellIndex);
|
|
void SetPageHeaderFooter(BOOL bIsHeader,int nAlign, int nFontSize, const CString strFont, CString strData);
|
void SetPageControl(BOOL bCenterHorizontally, BOOL bCenterVertically, int nOutDirection, int nZoom = 100);
|
void SetPageMargin(float Left=0.75, float Right=0.75, float Top=1, float Bottom=1, float Header=0.5, float Footer=0.5);
|
|
void FreezePanes( BOOL bIsValue );
|
void SetFreezePanes( CString strSheetName, CString strCellAddr, BOOL bFreezePanes );
|
void SetFreezePanes( long nSheetIndex, CString strCellAddr, BOOL bFreezePanes );
|
|
void PrintOut(int nSheetIndex, const CString strStartSel, const CString strEndSel, int nStartPage, int nEndPage, int nCopies, const CString strFileName );
|
|
void AddMemo(int nSheetIndex, const CString strSel, const CString strFillData);
|
void AddTextBox( int nSheetIndex, const CString strStartSel, const CString strEndSel,
|
float nLeft, float nTop, float nWidth, float nHeight,
|
short nSize, BOOL bIsBold, const CString strFillData );
|
|
BOOL ConvertAlphabet2Number( char *pbVal, DWORD &pdwNumber ); // Convert Alphabet to Number (A:1, AA:27, ...)
|
int ConvertAlphabet2Number( CString strAlpha ); // Convert Alphabet to Number (A:1, AA:27, ...)
|
CString ConvertNumber2Alphabet( int nNum );
|
///int ConvertAlphabet2Number(CString s);
|
|
// [2019/02/01 18:22:12 by jylee] related Picture
|
void InsertPicture( CString strPicture );
|
///void InsertPicture( int nSheetIndex, const CString strStartSel, const CString strEndSel, CString strImagePath, const int nLeft, const int nTop, const int nWidth, const int nHeight );
|
void InsertPicture( const CString strStartSel, const CString strEndSel, CString strImagePath, const int nLeft, const int nTop, const int nWidth, const int nHeight );
|
void InsertPicture( CString strImagePath, const int nLeft, const int nTop, const int nWidth, const int nHeight );
|
double GetImageWidth( CString strImagePath );
|
double GetImageHeight( CString strImagePath );
|
|
protected:
|
void Release();
|
|
};
|