OfficeOLE/include/office/ExcelWrapper.h
2024-06-07 20:45:14 +03:00

44 lines
1.1 KiB
C++

#pragma once
#include "office/Office.h"
namespace MSO::Excel {
//! Excel API wrapper
class ExcelWrapper {
public:
ExcelWrapper() = default;
~ExcelWrapper();
ExcelWrapper(const ExcelWrapper&) = delete;
ExcelWrapper& operator=(const ExcelWrapper&) = delete;
public:
void Clear();
BOOL IsActive() noexcept { return xlApplication.m_lpDispatch != nullptr; }
EXLWorkbook GetDocument();
EXLWorkbook OpenDocument(CString docPath,
BOOL docVisible = TRUE,
BOOL docReadOnly = FALSE,
BOOL closeAfter = FALSE,
BOOL add2Recent = FALSE);
EXLWorkbook NewDocument(CString docTemplate = {}, BOOL closeAfter = FALSE);
void ReleaseDocument();
void ReleaseDocumentAndQuit();
static CString PromptUserForPath(CString text);
protected:
EXLWorkbook linkedWb{ nullptr };
EXLApplication xlApplication{ nullptr };
BOOL m_NeedClose{ TRUE };
protected:
BOOL InitApplication(BOOL isVisible = TRUE);
void CloseApplication();
};
} // namespace MSO::Excel