?? excelsheetview.cpp
字號:
// excelsheetView.cpp : implementation of the CExcelsheetView class
//
#include "stdafx.h"
#include "excelsheet.h"
#include "excelsheetDoc.h"
#include "excelsheetView.h"
#include "abaoExcel.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExcelsheetView
IMPLEMENT_DYNCREATE(CExcelsheetView, CFormView)
BEGIN_MESSAGE_MAP(CExcelsheetView, CFormView)
//{{AFX_MSG_MAP(CExcelsheetView)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExcelsheetView construction/destruction
CExcelsheetView::CExcelsheetView()
: CFormView(CExcelsheetView::IDD)
{
//{{AFX_DATA_INIT(CExcelsheetView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// TODO: add construction code here
n=1;
}
CExcelsheetView::~CExcelsheetView()
{
}
void CExcelsheetView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExcelsheetView)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BOOL CExcelsheetView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CExcelsheetView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
if (CoInitialize(NULL)!=0)
{
AfxMessageBox("初始化COM支持庫失敗!");
exit(1);
}
}
/////////////////////////////////////////////////////////////////////////////
// CExcelsheetView printing
BOOL CExcelsheetView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CExcelsheetView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CExcelsheetView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CExcelsheetView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CExcelsheetView diagnostics
#ifdef _DEBUG
void CExcelsheetView::AssertValid() const
{
CFormView::AssertValid();
}
void CExcelsheetView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CExcelsheetDoc* CExcelsheetView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExcelsheetDoc)));
return (CExcelsheetDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CExcelsheetView message handlers
void CExcelsheetView::OnButton1()
{
// TODO: Add your control notification handler code here
AbaoExcel a;
// CFileFind finder;
CString str;
CTime currenttime=CTime::GetCurrentTime();
str=currenttime.Format("e:\\sheet\\%Y%m%d_%H%M%S");
// str1=currenttime.Format("%H%M%S");
// if (finder.FindFile(str)) //判斷文件是否存在,若存在則打開,若不存在則創建新文件
// {
// a.Add(str);
// }
// else
// {
// a.Add(CString(""));
// }
a.Add(CString(""));
// a.SetVisible(true);
// a.Copy(a.SelectSheet(n));
// n++;
// a.ActiveSheet().SetName(str1);
// a.SelectSheet("sheet1");
a.SelectSheet("sheet1").SetName("123");
a.SetCell(1,1,3.14159267,6);
long t=1000;
a.SetCell(1,1,t);
a.SetCell(1,3,CString("CString"));
a.SetCell(1,4,"C Style string");
AbaoRange b(a.GetRange("A1:B1"));
b.Merge();
b.Border();
b.SetHAlign(HAlignCenter);
b.SetVAlign(VAlignTop);
b=a.GetRange("B2");
b.Border();
b="123456";
b=a.GetRange("C2");
b=CString("CString");
b=a.GetRange("D2");
b="C Style string";
b=a.GetRange("C1:D2");
b.SetHAlign(HAlignCenter);
// a.SelectSheet(1);
// a.SetCell(1,1,"內容都在sheet1里面呢");
a.SaveAs(str);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -