SDC C-Project CF Review 프로그램
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#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();
 
};