-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathExcelProcess.h
More file actions
116 lines (110 loc) · 4.44 KB
/
Copy pathExcelProcess.h
File metadata and controls
116 lines (110 loc) · 4.44 KB
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
#pragma once
#include "TLH/mso.h"
using namespace Office;
#include "TLH/vbe6ext.h"
using namespace VBIDE;
#include "TLH/excel.h"
using namespace Excel;
#include "CRange.h"
#include "CApplication.h"
#include "CWorkbook.h"
#include "CWorkbooks.h"
#include "CWorksheet.h"
#include "CWorksheets.h"
#include "CValidation.h"
#include "CInterior.h"
#include "CFont0.h"
#include "CNames.h"
#include <vector>
enum FormulaType
{
cellFromRange = 1
};
class ExcelProcess
{
private:
ExcelProcess();
// ExcelProcess(CString filePath);
~ExcelProcess();
static ExcelProcess* excel;
public:
static ExcelProcess* getInstance();
static void destroyInstance();
BOOL init();
BOOL setExcelExportSheets(CString filePath);
BOOL setExcelImportSheets(CString filePath);
BOOL getSheet(CString sheetName);
BOOL deleteSheet(CString sheetName);
BOOL judgeExcelVer(int Ver);
CString getEndCell(CString cellBegin, int rows, int cols);
BOOL createServer(CString officeVer);
BOOL setCellsTypeToNum(CString cellBegin, CString cellEnd, int min, int max, int defValue);
BOOL setCellsTypeToNum(CString cellBegin, CString cellEnd, int min, int max);
BOOL setCellsTypeToNum( CString cellBegin, CString cellEnd, double min, double max );
BOOL setCellsToStringList(CString cellBegin, CString cellEnd, const std::vector<CString>& strList, unsigned int defValueIndex);
BOOL setCellsToStringList(CString cellBegin, CString cellEnd, const std::vector<CString>& strList);
BOOL setCellsToStringList(CString cellBegin, CString cellEnd, CString sheetName, CString valueCellBegin, CString valueCellEnd);
BOOL setCellsToStringList(CString cellBegin, CString cellEnd, const CString* strList, unsigned int len, unsigned int defValueIndex);
BOOL setCellsToStringList(CString cellBegin, CString cellEnd, const CString* strList, unsigned int len);
BOOL setCellsColor(CString cellBegin, CString cellEnd, int colorIndex);
BOOL setCellsValue(CString cellBegin, long** nums, int rows, int cols);
BOOL setCellsValue(CString cellBegin, CString** nums, int rows, int cols);
BOOL setCellsValue( CString cellBegin, vector<vector<CString>>& nums );
BOOL setCellsValue( CString cellBegin, vector<int>& nums );
BOOL setRowColor(UINT rowIndex, int colorIndex);
BOOL setCellsBold(CString cellBegin, CString cellEnd, BOOL bold);
BOOL setCellsFont(CString cellBegin, CString cellEnd, CString fontName, int fontSize, BOOL bold = FALSE);
BOOL splitComBox(CString comBox, std::vector<CString>& strList);
BOOL getComBoxValue(CString comBox, const CString& key, CString& value);
BOOL getComBoxKey( CString comBox, const CString& value, CString& key );
void getValue( vector<vector<CString>>& data, CString cellBegin, int rows, int cols);
void saveExcel();
void saveExcelAs(CString savePath);
void savaExcelToXml(CString savePath);
long getCellRowIndex(CString cellIndex);
void setCellsFormat( CString cellBegin, CString cellEnd, CString format );
void setCellsAlignLeft(CString cellBegin, CString cellEnd);
void setCellsAlignLeft(CRange range);
void setCellsLength(CString cellBegin, CString cellEnd, UINT length);
void setCellsLength( CString cellBegin, CString cellEnd, UINT lengthMin, UINT lengthMax );
void setCellValue(CString cellIndex, CString value);
void setCellsToText(CString cellBegin, CString cellEnd);
CString getCellValue(CString cellIndex);
void setView();
void createSheet(CString sheetName);
void setColumnWidth(CString cellIndex, int width);
int getOfficeVer();
void closeExcel();
void unlockALL();
void lockCells( CString cellBegin, CString cellEnd );
void setSheetProtect(CString sheetName);
void setSheetUnprotect();
void lockRow(CString cellIndex);
void lockRows(CString cellBegin, CString cellEnd);
void addFormula(CString name, CString formula);
void setCellsToFormula(CString cellBegin, CString cellEnd, CString formulaName);
CString getFormula(CString sheetName, CString cellBegin, CString cellEnd, FormulaType type);
void getMaxRange(UINT& row, UINT& column);
BOOL openExcelFile( CString filePath );
void getColValue(vector<CString>& outData, CString cellBegin, int count);
BOOL createFakeServer();
BOOL getActiveSheet();
BOOL setColValue( CString cellBegin, const vector<CString>& nums );
private:
CApplication ExcelApp;
CWorkbooks books;
CWorkbook book;
CWorksheets sheets;
CWorksheet sheet;
CRange range;
CValidation validation;
CInterior interior;
CFont0 font;
CNames names;
//CString filePath;
LPDISPATCH lpDisp;
//αÔìµÄExcelApp
CApplication ExcelApp_fake;
CWorkbooks books_fake;
int excelVer;
};