資源簡介
通過示例源碼你可以更加靈活的控制Excel表格文件,其中包括創建新Excel文件、寫入表格數據、讀取表格數據(包括對原建Excel文件自已手工添加的行、列數據的準確讀取),刪除已有Excel表格,對表格中指定行、列、單元格進行查詢、插入、替換等操作,同時還可以將生成的Excel文件轉換為按指定分隔符分隔的其它文本格式的文件。

代碼片段和文件信息
#include?“stdafx.h“
#include?“CeXDib.h“
#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif
CCeXDib::CCeXDib()
{
m_hDib?=?NULL;
m_dwLineWidth?=?0;
m_wColors?=?0;
m_hMemDC?=?NULL;
m_hBitmap?=?NULL;
m_lpBits?=?NULL;
FreeResources();
}
CCeXDib::~CCeXDib()
{
FreeResources();
}
void?CCeXDib::FreeResources()
{
if?(m_hMemDC) ::DeleteDC(m_hMemDC);
if?(m_hBitmap) ::Deleteobject(m_hBitmap);
if?(m_hDib) delete?m_hDib;
m_hDib?=?NULL;
m_hMemDC?=?NULL;
m_hBitmap?=?NULL;
m_lpBits?=?NULL;
memset(&m_bi?0?sizeof(m_bi));
}?//?End?of?FreeResources
HDIB?CCeXDib::Create(DWORD?dwWidth?DWORD?dwHeight?WORD?wBitCount)
{
????LPBITMAPINFOHEADER??lpbi?=?NULL; //?Pointer?to?BITMAPINFOHEADER
????DWORD???????????????dwLen?=?0; //?Size?of?memory?block
FreeResources();
//?Following??is?taken?from
//?CDIBSectionLite?class?by?Chris?Maunder
????switch?(wBitCount)?
????{
????case?1:??m_wColors?=?2;???break;
#ifdef?_WIN32_WCE
????????case?2:??m_wColors?=?4;???break;???//?winCE?only???????
#endif
????????case?4:??m_wColors?=?16;??break;
????????case?8:??m_wColors?=?256;?break;
????????case?16:
????????case?24:
????????case?32:?m_wColors?=?0;???break;???//?1624?or?32?bpp?have?no?color?table
????????default:
???????????m_wColors?=?0;
????}?//?switch
/*
????//?Make?sure?bits?per?pixel?is?valid
????if?(wBitCount?<=?1) wBitCount?=?1;
????else?if?(wBitCount?<=?4) wBitCount?=?4;
????else?if?(wBitCount?<=?8) wBitCount?=?8;
????else ????????wBitCount?=?24;
????switch?(wBitCount)
{
????????case?1:
????????????m_wColors?=?2;
break;
????????case?4:
????????????m_wColors?=?16;
break;
????????case?8:
????????????m_wColors?=?256;
break;
????????default:
????????????m_wColors?=?0;
break;
????}?//?switch
*/
????m_dwLineWidth?=?WIDTHBYTES(wBitCount?*?dwWidth);
????//?Initialize?BITMAPINFOHEADER
????m_bi.biSize?=?sizeof(BITMAPINFOHEADER);
????m_bi.biWidth?=?dwWidth;?????????//?fill?in?width?from?parameter
????m_bi.biHeight?=?dwHeight;???????//?fill?in?height?from?parameter
????m_bi.biPlanes?=?1;??????????????//?must?be?1
????m_bi.biBitCount?=?wBitCount;????//?from?parameter
????m_bi.biCompression?=?BI_RGB;????
????m_bi.biSizeImage?=?m_dwLineWidth?*?dwHeight;
????m_bi.biXPelsPerMeter?=?0;
????m_bi.biYPelsPerMeter?=?0;
????m_bi.biClrUsed?=?0;
????m_bi.biClrImportant?=?0;
????//?Calculate?size?of?memory?block?required?to?store?the?DIB.??This
????//?block?should?be?big?enough?to?hold?the?BITMAPINFOHEADER?the?color
????//?table?and?the?bits.
????dwLen?=?GetSize();
m_hDib?=?new?HDIB[dwLen];?//?Allocate?memory?block?to?store?our?bitmap
????if?(m_hDib?==?NULL)?return?NULL;
????//?Use?our?bitmap?info?structure?to?fill?in?first?part?of
????//?our?DIB?with?the?BITMAPINFOHEADER
lpbi?=?(LPBITMAPINFOHEADER)(m_hDib);
????*lpbi?=?m_bi;
????return?m_hDib;?//?Return?handle?to?the?DIB
}?//?End?o
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????8684??2001-12-03?17:54??ExcelAccessSrc\CeXDib.cpp
?????文件????????2328??2001-12-04?11:23??ExcelAccessSrc\CeXDib.h
?????文件???????34182??1997-01-01?03:42??ExcelAccessSrc\CSpreadSheet.h
?????文件????????1649??2003-05-01?00:28??ExcelAccessSrc\ExcelAccess.clw
?????文件????????2855??2003-05-01?04:02??ExcelAccessSrc\ExcelAccess.cpp
?????文件????????4957??2003-05-01?00:46??ExcelAccessSrc\ExcelAccess.dsp
?????文件?????????545??1997-01-01?00:39??ExcelAccessSrc\ExcelAccess.dsw
?????文件???????90112??2003-05-01?00:53??ExcelAccessSrc\ExcelAccess.exe
?????文件????????1604??2003-05-01?03:55??ExcelAccessSrc\ExcelAccess.h
?????文件????????1543??2003-05-01?00:53??ExcelAccessSrc\ExcelAccess.plg
?????文件????????6410??2003-05-01?00:44??ExcelAccessSrc\ExcelAccess.rc
?????文件???????14281??2003-05-01?00:53??ExcelAccessSrc\ExcelAccessDlg.cpp
?????文件????????2403??2003-05-01?00:30??ExcelAccessSrc\ExcelAccessDlg.h
?????文件????????1069??2003-01-04?18:47??ExcelAccessSrc\HoverEdit.cpp
?????文件????????1269??2003-01-04?18:46??ExcelAccessSrc\HoverEdit.h
?????文件??????100590??2003-04-13?13:22??ExcelAccessSrc\PPTooltip.cpp
?????文件???????16510??2003-04-13?10:54??ExcelAccessSrc\PPTooltip.h
?????目錄???????????0??2003-05-27?19:59??ExcelAccessSrc\res\
?????文件????????1078??2003-05-01?04:23??ExcelAccessSrc\res\ExcelAccess.ico
?????文件?????????403??1997-01-01?00:39??ExcelAccessSrc\res\ExcelAccess.rc2
?????文件???????14333??2002-09-27?00:06??ExcelAccessSrc\res\Flag.gif
?????文件????????2238??2003-05-01?00:43??ExcelAccessSrc\res\Info.ico
?????文件????????1001??2003-05-01?00:44??ExcelAccessSrc\resource.h
?????文件?????????213??1997-01-01?00:39??ExcelAccessSrc\StdAfx.cpp
?????文件????????1134??2003-05-01?00:41??ExcelAccessSrc\StdAfx.h
?????文件????????1799??2003-01-04?18:47??ExcelAccessSrc\TrackControl.h
?????文件????????6320??2002-12-25?10:38??ExcelAccessSrc\XPButton.cpp
?????文件????????1885??2002-12-25?10:38??ExcelAccessSrc\XPButton.h
?????目錄???????????0??2003-05-27?19:59??ExcelAccessSrc\
?????文件????????3575??2003-05-26?16:21??ShadowButton.zip
- 上一篇:經典差分進化算法的C++語言實現
- 下一篇:vc++6.0開發的音頻采集程序
評論
共有 條評論