Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

excel.h

Go to the documentation of this file.
00001 
00002 // Name:        excel.h
00003 // Author:      Joe Yates
00004 // Purpose:     A wrapper for Excel Automation
00005 // Created:     2004-11-25
00006 // Copyright:   (c) Joe Yates
00007 // License:     BSD license (see the file 'LICENSE.txt')
00009 
00010 #ifdef __WXMSW__
00011 
00012 #ifndef __msw_excel_h__
00013 #define __msw_excel_h__
00014 
00015 #include "wx/wxprec.h"
00016 
00017 #ifndef WX_PRECOMP
00018   #include "wx/wx.h"
00019 #endif
00020 
00021 #include <wx/msw/ole/automtn.h>
00022 
00023 #include <wx/exception.h>
00024 
00025 namespace wx
00026 {
00027 
00028 namespace Excel
00029 {
00030 
00031 enum XlFileFormat
00032   {
00033   xlExcel9795       = 0x0000002b,
00034   xlWorkbookNormal  = 0xffffefd1,
00035   };
00036 
00037 class Worksheet : public wxAutomationObject
00038   {
00039   public:
00040     Worksheet();
00041     ~Worksheet()
00042       {}
00043 
00044   public:
00045     void PrintPreview();
00046     void PrintOut(long nFrom = 1, long nTo = -1, long nCopies = 1, bool bPreview = false);
00047   };
00048  
00049 class Sheets : public wxAutomationObject
00050   {
00051   public:
00052     Sheets();
00053     ~Sheets()
00054       {}
00055 
00056   public:
00057     void GetItem(long nIndex, Worksheet& wsh);
00058     long GetCount();
00059   };
00060 
00061 class Workbook : public wxAutomationObject
00062   {
00063   public:
00064     Workbook();
00065     ~Workbook()
00066       {}
00067 
00068   public:
00069     // Propery accessors
00070     Sheets&     GetWorksheets();
00071     wxString    GetFullName();
00072     bool        GetOpen()
00073       {
00074       return (GetDispatchPtr() != NULL)? true : false;
00075       }
00076     // Method accessors
00077     void        Close();
00078     void        PrintOut(long nFrom = 1, long nTo = -1, long nCopies = 1, bool bPreview = false);
00079     void        PrintPreview();
00080     void        SaveAs(const wxString& sFileName, XlFileFormat fft = xlWorkbookNormal);
00081 
00082   // Members
00083   private:
00084     Sheets    m_shs;
00085   };
00086 
00087 class Application;
00088 class Workbooks : public wxAutomationObject
00089   {
00090   public:
00091     Workbooks();
00092     ~Workbooks();
00093 
00094   public:
00095     void          Open(const wxString& sFileName, Workbook& wbk);
00096     void          Add(Workbook& wbk);
00097     void          Close();
00098     void          GetItem(long nIndex, Workbook& wbk);
00099     long          GetCount();
00100     Application * GetApplication();
00101 
00102   private:
00103     Application * m_app;
00104   };
00105 
00106 class Application : public wxAutomationObject
00107   {
00108   // friends, classes, enums and types
00109   
00110   // Constructors/destructors
00111   public:
00112     Application(bool bUseExisting = false) :
00113       m_bUseExisting(bUseExisting)
00114       {}
00115     ~Application()
00116       {}
00117 
00118   // Operators
00119   
00120   // Slots
00121   private:
00122     
00123   // Methods
00124   public:
00125     // Propery accessors
00126     Workbooks&  GetWorkbooks();
00127     Sheets&     GetWorksheets();
00128     wxString    GetVersion();
00129     void        SetVisible(bool bVisible);
00130     // Method accessors
00131 
00132   private:
00133     void Create();
00134 
00135   // Members
00136   private:
00137     bool      m_bUseExisting;
00138     Workbooks m_wbs;
00139     Sheets    m_shs;
00140   };
00141 
00142 } // namespace Excel
00143   
00144 } // namespace wx
00145 
00146 #endif // ndef __msw_excel_h__
00147 
00148 #endif
00149   // def __WXMSW__

Generated on Wed Jan 25 08:13:08 2006 for Sherpa wxWidgets Classes by doxygen 1.3.6