Click here to Skip to main content
15,896,118 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 91K   4.5K   81  
A fast and lightweight cell control for displaying tabular data. The cell is a custom control derived from ATL::CWindow.
// MyCell - version 1.1
// Written by Yanxueming <yanxm2003@hotmail.com>
// Copyright (C) 2006-2007
// All rights reserved.
//
// The code and information is provided "as-is" without
// warranty of any kind, either expressed or implied.
//Yanxm 2007��12��6�� 11:16:58
#pragma once
//#import <MSXML3.dll> named_guids raw_interfaces_only
#include "XmlExcelBase.h"
#include "Worksheet.h"
namespace mycell{
	//class Worksheet;
	//class Border;
	//class StyleDesc;
	class XmlMyCell : public XmlExcelBase
	{
	public:
		HRESULT load(Worksheet* pSheet,LPCTSTR lpszFile);
		HRESULT save(Worksheet const* pSheet,LPCTSTR lpszFile);
	private:
		HRESULT init(MSXML2::IXMLDOMDocument* pXmlDoc);
		void StyleE2BorderStyle(MSXML2::IXMLDOMElement* pE,Border& bdr);
		void StyleE2StyleDesc(MSXML2::IXMLDOMNode* pStyleN,StyleDesc& sd);
		HRESULT LoadStyles(Worksheet* pSheet,RowHeader& rh,ColHeader& ch,map<StyleID_t,StyleDesc>& mapStyle,MSXML2::IXMLDOMElement* pStylesE);
		void CreateBorderNode(MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMElement* pBordersE,const Border* bdr,BSTR bstrPos);
		void CreateColumnNode(MSXML2::IXMLDOMDocument* pXmlDoc,bool& bCreated,int col,int nPreCol,MSXML2::IXMLDOMNode* pColumns,MSXML2::IXMLDOMElement** ppColE);
		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);
		CComPtr<MSXML2::IXMLDOMElement> CreateStyleNode(MSXML2::IXMLDOMDocument* pXmlDoc,BSTR bstrStyleNodeName,MSXML2::IXMLDOMElement* pStylesE);
		HRESULT _SaveStyles(const StyleDesc& sd,MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMElement* pE,const StyleDesc* pDefStyle=NULL);
		HRESULT SaveStyles(Worksheet const* pSheet,map<StyleID_t,size_t>& mapStyleID,const RowHeader& rh,const ColHeader& ch,MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMNode* pNode);
		HRESULT LoadColumns(Worksheet* pSheet,RowHeader& rh,ColHeader& ch,const map<StyleID_t,StyleDesc>& mapStyle,MSXML2::IXMLDOMElement* pColumnsE);
		HRESULT SaveColumns(Worksheet const* pSheet,const RowHeader& rh,const ColHeader& ch,MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMNode* pNode);
		HRESULT LoadRows(Worksheet* pSheet,RowHeader& rh,ColHeader& ch,const map<StyleID_t,StyleDesc>& mapStyle,MSXML2::IXMLDOMElement* pRowsE);
		HRESULT SaveRows(Worksheet const* pSheet,const map<StyleID_t,size_t>& mapStyleID,const RowHeader& rh,const ColHeader& ch,MSXML2::IXMLDOMDocument* pXmlDoc,MSXML2::IXMLDOMNode* pNode);
	};
}//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