Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Printing to Excel

, 20 Apr 2002
This article shows how to send data to Excel instead of a printer.
testexcel.zip
testexcel
res
TestExcel.ico
TestExcelDoc.ico
Toolbar.bmp
TestExcel.dsp
TestExcel.dsw
TestExcel.plg
//	PrintExcel.h - Definition of the PrintExcel class
//


#ifndef __PRINTEXCEL_H
#define __PRINTEXCEL_H


#define	ID_EXCEL_INIT				50
#define	ID_EXCEL_CLOSE				51



#define ID_FORMAT_LEFT				0
#define ID_FORMAT_RIGHT				1
#define ID_FORMAT_CENTER			2

#define ID_FORMAT_NUMBER0			10
#define ID_FORMAT_NUMBER1			11
#define ID_FORMAT_NUMBER2			12
#define ID_FORMAT_NUMBER3			13
#define ID_FORMAT_NUMBER4			14
#define ID_FORMAT_NUMBER5			15
#define ID_FORMAT_NUMBER6			16

#define	ID_EXCEL_TYPBACKGROUND			0
#define ID_EXCEL_TYPTEXTFONT			1
#define ID_EXCEL_TYPTEXT				2

#define ID_EXCEL_TYPLINESINGLETOP		3
#define ID_EXCEL_TYPLINESINGLEBOTTOM	4
#define ID_EXCEL_TYPLINESINGLELEFT		5
#define ID_EXCEL_TYPLINESINGLERIGHT		6
#define ID_EXCEL_TYPLINEDOUBLETOP		7
#define ID_EXCEL_TYPLINEDOUBLEBOTTOM	8
#define ID_EXCEL_TYPLINEDOUBLELEFT		9
#define ID_EXCEL_TYPLINEDOUBLERIGHT		10

#define ID_FORMAT_PORTRAIT			20
#define ID_FORMAT_LANDSCAPE			21


class CPrintExcel {

// Construction
public:
	CPrintExcel ();
	~CPrintExcel ();

	
private:
	int		ExcelGetRowCol (CRect &rect, int *pnCol, int *pnRow, 
								 int *pnSorted, float *pfWidth, char *cCell,
								 int nArray, int nUseTop=FALSE);


// Operations
public:

	// transform CRect to cols
	int		CalcExcelCols (CRect &rect);	
	// send different data to excel
	int		PrintExcel (int	nFunction, CRect *pRect=NULL, const char *cText=NULL, 
						COLORREF nColor=0, LOGFONT *pLogFont=NULL, 
						int nFormat=0);


// Attributes
private:
	CObArray	m_ExcelCols;
	CObArray	m_ExcelRows;
	int			m_nExcelRowHeight;

	int	m_nCurrentRow;
	int	m_nCurrentCol;
	int	m_nSorted;
	int	m_nTop;
	int	m_nBottom;

	int	m_nError;

	int	m_nGerman;	// decimalsign and thousand sign are in german different
	
	
};

#endif	// __SERIAL_H

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141216.1 | Last Updated 21 Apr 2002
Article Copyright 2002 by Franz Maerzinger
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid