Tianchi  v0.0.2 build 20130701
C++ library for Qt with VC & mingW
tcmsexcel.h
1 // **************************************************************************
2 // Tianchi C++ library for Qt (open source)
3 // 天池共享源码库
4 // 版权所有 (C) 天池共享源码库开发组
5 // 授权协议:请阅读天池共享源码库附带的授权协议
6 // **************************************************************************
7 // 文档说明:通过 OLE 方式操作 Microsoft Excel(仅限 Windows 下使用,要求已安
8 // 装 Excel)
9 // ==========================================================================
10 // 开发日志:
11 // 日期 人员 说明
12 // --------------------------------------------------------------------------
13 // 2013.04.10 圣域天子 建立
14 //
15 // ==========================================================================
17 // 要求已安装 Excel)
18 // ==========================================================================
19 #ifndef TIANCHI_TCMSEXCEL_H
20 #define TIANCHI_TCMSEXCEL_H
21 
22 #include <tianchi/tcglobal.h>
23 
24 #include <QString>
25 #include <QStringList>
26 #include <QVariant>
27 
28 class TcMSExcelPrivate;
29 
35 class TIANCHI_API TcMSExcel
36 {
37 public:
39  TcMSExcel();
41  virtual ~TcMSExcel();
42 
43 private:
44  Q_DISABLE_COPY(TcMSExcel)
45  Q_DECLARE_PRIVATE(TcMSExcel)
46  TcMSExcelPrivate* const d_ptr;
47 
48 public:
50  enum Alignment
51  {
52  xlTop = -4160,
53  xlLeft = -4131,
54  xlRight = -4152,
55  xlCenter = -4108,
56  xlBottom = -4107
57  };
58 
60  bool create(const QString& filename = QString());
62  bool open(const QString& filename = QString());
64  void save(const QString& filename = QString());
66  void close();
70  void kick();
71 
73  void setVisible(bool value);
75  void setCaption(const QString& value);
76 
78  bool addBook();
79 
81  int sheetCount();
82 
84  QStringList sheetNames();
85 
87  bool currentSheet();
88 
91  bool setCurrentSheet(int index);
92 
94  QString currentSheetName();
95 
100  QVariant read(int row, int col);
101 
106  inline QVariant cell(int row, int col) { return read(row, col); }
107 
112  void write(int row, int col, const QVariant& value);
113 
114  void cellFormat(int row, int col, const QString& format);
115  void cellAlign(int row, int col, Alignment hAlign, Alignment vAlign);
116 
122  bool usedRange(int& rowStart, int& colStart, int &rowEnd, int &colEnd);
123 };
124 
125 #endif // TIANCHI_MSEXCEL_H