//ExcelUtil.h
#include "stdafx.h"
#include <io.h>
#include "CApplication.h"
#include "CFont0.h"
#include "CRange.h"
#include "CWorkbook.h"
#include "CWorkbooks.h"
#include "CWorksheet.h"
#include "CWorksheets.h"
#include "comdef.h"
#include "comutil.h"
//using namespace TypelibExcel;e
namespace TypelibExcel {
class CExcel{
private:
CString out_file_name;
public:
CString GetOutFileName()
{
return out_file_name;
};
void SetOutFileName(CString new_file_name)
{
if (new_file_name.GetLength()>0)
out_file_name = new_file_name;
}
CExcel()
{
;
}
~CExcel()
{
}
private:
CApplication m_excelApp;
CWorkbooks m_excelBooks;
CWorkbook m_excelBook;
CWorksheets m_excelSheets;
CWorksheet m_excelSheet;
CRange m_excelRange;
public:
void CreateExcel();
void OpenExcel(CString fileName);
bool SaveExcel();
void CloseExcel();
CWorksheet GetSheet(CString SheetName);
CWorksheet GetSheet(int index);
CWorksheet AddSheet(CString SheetName);
int GetSheetNum();
CString GetCell(int ColNum, int RowNum);
void SetRange(int ColNum, int RowNum);
void SetRange(int StartColNum, int StartRowNum, int EndColNum, int EndRowNum);
void Merge(int startRowIndex, int startColIndex, int endRowIndex, int endColIndex);
void SetCellValue(CString value);
void SetCellValue(int row, int col, CString value);
void SetCellStringFormat();
void SetCellValue( int startRow,int startCol, int endRow, int endCol, CString value );
CString GetCellValue( int row, int col );
void SetBoldFontAndSize( int size );
void SetAutoFitColumns( int startRow, int startCol, int endRow, int endCol );
void SetCenterAlign();
// void SetBorder()
// {
// Borders borders = m_excelRange.GetBorders();
// borders.SetLineStyle(COleVariant((short)1));
//
// Border border = borders.GetItem(7);
// border.SetWeight(COleVariant((short)4));
// border = borders.GetItem(8);
// border.SetWeight(COleVariant((short)4));
// border = borders.GetItem(10);
// border.SetWeight(COleVariant((short)4));
// border = borders.GetItem(9);
// border.SetWeight(COleVariant((short)4));
// }
};
};
#include "stdafx.h"
#include <io.h>
#include "CApplication.h"
#include "CFont0.h"
#include "CRange.h"
#include "CWorkbook.h"
#include "CWorkbooks.h"
#include "CWorksheet.h"
#include "CWorksheets.h"
#include "comdef.h"
#include "comutil.h"
//using namespace TypelibExcel;e
namespace TypelibExcel {
class CExcel{
private:
CString out_file_name;
public:
CString GetOutFileName()
{
return out_file_name;
};
void SetOutFileName(CString new_file_name)
{
if (new_file_name.GetLength()>0)
out_file_name = new_file_name;
}
CExcel()
{
;
}
~CExcel()
{
}
private:
CApplication m_excelApp;
CWorkbooks m_excelBooks;
CWorkbook m_excelBook;
CWorksheets m_excelSheets;
CWorksheet m_excelSheet;
CRange m_excelRange;
public:
void CreateExcel();
void OpenExcel(CString fileName);
bool SaveExcel();
void CloseExcel();
CWorksheet GetSheet(CString SheetName);
CWorksheet GetSheet(int index);
CWorksheet AddSheet(CString SheetName);
int GetSheetNum();
CString GetCell(int ColNum, int RowNum);
void SetRange(int ColNum, int RowNum);
void SetRange(int StartColNum, int StartRowNum, int EndColNum, int EndRowNum);
void Merge(int startRowIndex, int startColIndex, int endRowIndex, int endColIndex);
void SetCellValue(CString value);
void SetCellValue(int row, int col, CString value);
void SetCellStringFormat();
void SetCellValue( int startRow,int startCol, int endRow, int endCol, CString value );
CString GetCellValue( int row, int col );
void SetBoldFontAndSize( int size );
void SetAutoFitColumns( int startRow, int startCol, int endRow, int endCol );
void SetCenterAlign();
// void SetBorder()
// {
// Borders borders = m_excelRange.GetBorders();
// borders.SetLineStyle(COleVariant((short)1));
//
// Border border = borders.GetItem(7);
// border.SetWeight(COleVariant((short)4));
// border = borders.GetItem(8);
// border.SetWeight(COleVariant((short)4));
// border = borders.GetItem(10);
// border.SetWeight(COleVariant((short)4));
// border = borders.GetItem(9);
// border.SetWeight(COleVariant((short)4));
// }
};
};