Click here to Skip to main content
15,884,986 members
Articles / Desktop Programming / WTL

A fast and lightweight cell control

Rate me:
Please Sign up or sign in to vote.
4.42/5 (31 votes)
11 Mar 2008CPOL1 min read 90.9K   4.5K   81  
A fast and lightweight cell control for displaying tabular data. The cell is a custom control derived from ATL::CWindow.
/* -------------------------------------------------------------------------
//MyCell Library - MyCell version 1.0
//
// This file is a part of the MyCell Library.
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.txt at this distribution. By using
// this software in any fashion, you are agreeing to be bound by the terms
// of this license. You must not remove this notice, or any other, from
// this software.
//
// Creator: yanxueming
// Email: xueming.yan@gmail.com
// -----------------------------------------------------------------------*/
#pragma once
//#import <MSXML3.dll> named_guids raw_interfaces_only
#include "XmlExcelBase.h"
#include "Worksheet.h"
namespace mycell{
	//class Worksheet;
	class XmlExcel : public XmlExcelBase
	{
	public:
		XmlExcel()
		{
			//try{
			//	TESTHR(XmlExcelBase::FinalConstruct());
			//}catch(_com_error& e){
			//	_COM_ERROR_MSG_(e);
			//}
		}
		HRESULT load(Workbook* pWorkbook,LPCTSTR lpszFile/*,int nWorkSheet=0*/);
		HRESULT save(Workbook const* pWorkbook,LPCTSTR lpszFile);
	private:
		HRESULT init(MSXML2::IXMLDOMDocument* pXmlDoc);
		void StyleE2BorderStyle(MSXML2::IXMLDOMElement* pE,Border& bdr);
		void StyleE2StyleDesc(MSXML2::IXMLDOMNode* pStyleN,StyleDesc& sd);
		HRESULT LoadWorkSheet(Worksheet* pWorksheet,const map<CComBSTR,StyleDesc>& mapStyle,MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMNode* pSheetN);
		HRESULT LoadStyles(Workbook* pWorkbook,/*RowHeader& rh,ColHeader& ch,*/map<CComBSTR,StyleDesc>& mapStyle,MSXML2::IXMLDOMElement* pStylesE);
		//HRESULT LoadColumns(Worksheet* pSheet,RowHeader& rh,ColHeader& ch,const map<CComBSTR,StyleDesc>& mapStyle,MSXML2::IXMLDOMNode* pTableN);
		HRESULT LoadRows(Worksheet* pSheet,RowHeader& rh,ColHeader& ch,const map<CComBSTR,StyleDesc>& mapStyle,MSXML2::IXMLDOMNode* pTableN);
		HRESULT LoadCells(Worksheet* pSheet,RowHeader& rh,ColHeader& ch,int row,const map<CComBSTR,StyleDesc>& mapStyle,MSXML2::IXMLDOMElement* pRowE);
		HRESULT SaveStyles(Workbook const* pWorkbook,/*const RowHeader& rh,const ColHeader& ch,*/MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMNode* pNode);
		HRESULT _SaveStyles(const StyleDesc& sd,MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMElement* pE,const StyleDesc* pDefStyle=NULL);
		HRESULT SaveWorksheet(const Worksheet* pWorksheet,MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMElement* pSheetE);
		void CreateBorderNode(MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMElement* pBordersE,const Border* bdr,BSTR bstrPos);
		CComPtr<MSXML2::IXMLDOMElement> CreateStyleNode(MSXML2::IXMLDOMDocument* pXmlDoc,BSTR bstrStyleNodeName,MSXML2::IXMLDOMElement* pStylesE);
		HRESULT SaveRows(Worksheet const* pSheet,const RowHeader& rh,const ColHeader& ch,MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMElement* pTableE);
		HRESULT SaveWorksheetOptions(Worksheet const* pSheet,MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMElement* pWorksheetOptionsE);
		HRESULT LoadWorksheetOptions(Worksheet* pSheet,MSXML2::IXMLDOMNode* pOptions);
		void CreateRowNode(MSXML2::IXMLDOMDocument* pXmlDoc,int row,int nPreRow,bool& bRowCreated,MSXML2::IXMLDOMElement* pE,MSXML2::IXMLDOMElement** ppRowE);
		void CreateCellNode(MSXML2::IXMLDOMDocument* pXmlDoc,int row,int col,int nPreRow,int nPreCol,bool& bRowCreated,bool& bCellCreated,MSXML2::IXMLDOMElement* pE,CComPtr<MSXML2::IXMLDOMElement>& pRowE,CComPtr<MSXML2::IXMLDOMElement>& pCellE);
		HRESULT SaveColumns(Worksheet const* pSheet,const RowHeader& rh,const ColHeader& ch,MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMElement* pTableE);
		void CreateColumnNode(MSXML2::IXMLDOMDocument* pXmlDoc,bool& bCreated,int col,int nPreCol,MSXML2::IXMLDOMNode* pColumns,MSXML2::IXMLDOMElement** ppColE);
		HRESULT LoadColumns(Worksheet* pSheet,RowHeader& rh,ColHeader& ch,const map<CComBSTR,StyleDesc>& mapStyle,MSXML2::IXMLDOMNode* pTableN);
	};
}//namespace mycell

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
China China
My name is Yanxueming,i live in Chengdu China.Graduated from UESTC in 1999.

Comments and Discussions