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
// TestExcelDoc.cpp : Implementierung der Klasse CTestExcelDoc
//

#include "stdafx.h"
#include "TestExcel.h"

#include "TestExcelDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTestExcelDoc

IMPLEMENT_DYNCREATE(CTestExcelDoc, CDocument)

BEGIN_MESSAGE_MAP(CTestExcelDoc, CDocument)
	//{{AFX_MSG_MAP(CTestExcelDoc)
		// HINWEIS - Hier werden Mapping-Makros vom Klassen-Assistenten eingef�gt und entfernt.
		//    Innerhalb dieser generierten Quelltextabschnitte NICHTS VER�NDERN!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestExcelDoc Konstruktion/Destruktion

CTestExcelDoc::CTestExcelDoc()
{
	// ZU ERLEDIGEN: Hier Code f�r One-Time-Konstruktion einf�gen



	m_fontNormal.CreateFont(-11,0,0,0,400,FALSE,FALSE,
                       0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
                       CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
                       DEFAULT_PITCH | FF_SWISS,"Arial");

	m_fontBold.CreateFont(-11,0,0,0,800,FALSE,FALSE,
                       0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
                       CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
                       DEFAULT_PITCH | FF_SWISS,"Arial");

	m_rectHeader[1].top=10; m_rectHeader[1].bottom=30;
	m_rectHeader[1].left=10; m_rectHeader[1].right=100;
	m_strHeader[1] = "Client report";

	m_rectHeader[2].top=10; m_rectHeader[2].bottom=30;
	m_rectHeader[2].left=150; m_rectHeader[2].right=250;
	m_strHeader[2] = "Date: 2002-04-12";

	m_rectHeader[3].top=10; m_rectHeader[3].bottom=30;
	m_rectHeader[3].left=300; m_rectHeader[3].right=380;
	m_strHeader[3] = "Page 1";

	m_nFieldsHeader = 3;


	// Position line 1
	m_rectPosition[1].top=60; m_rectPosition[1].bottom=80;
	m_rectPosition[1].left=10; m_rectPosition[1].right=50;
	m_strPosition[1] = "Col 11";
	m_rectPosition[2].top=60; m_rectPosition[2].bottom=80;
	m_rectPosition[2].left=50; m_rectPosition[2].right=100;
	m_strPosition[2] = "Col 12";
	m_rectPosition[3].top=60; m_rectPosition[3].bottom=80;
	m_rectPosition[3].left=100; m_rectPosition[3].right=150;
	m_strPosition[3] = "Col 13";
	m_rectPosition[4].top=60; m_rectPosition[4].bottom=80;
	m_rectPosition[4].left=150; m_rectPosition[4].right=200;
	m_strPosition[4] = "Col 14";
	m_rectPosition[5].top=60; m_rectPosition[5].bottom=80;
	m_rectPosition[5].left=200; m_rectPosition[5].right=250;
	m_strPosition[5] = "Col 15";
	m_rectPosition[6].top=60; m_rectPosition[6].bottom=80;
	m_rectPosition[6].left=250; m_rectPosition[6].right=300;
	m_strPosition[6] = "Col 16";
	m_rectPosition[7].top=60; m_rectPosition[7].bottom=80;
	m_rectPosition[7].left=300; m_rectPosition[7].right=350;
	m_strPosition[7] = "Col 17";
	m_rectPosition[8].top=60; m_rectPosition[8].bottom=80;
	m_rectPosition[8].left=350; m_rectPosition[8].right=400;
	m_strPosition[8] = "Col 18";

	// Position line 2
	m_rectPosition[9].top=85; m_rectPosition[9].bottom=105;
	m_rectPosition[9].left=10; m_rectPosition[9].right=50;
	m_strPosition[9] = "Col 21";
	m_rectPosition[10].top=85; m_rectPosition[10].bottom=105;
	m_rectPosition[10].left=50; m_rectPosition[10].right=100;
	m_strPosition[10] = "Col 22";
	m_rectPosition[11].top=85; m_rectPosition[11].bottom=105;
	m_rectPosition[11].left=100; m_rectPosition[11].right=150;
	m_strPosition[11] = "Col 23";
	m_rectPosition[12].top=85; m_rectPosition[12].bottom=105;
	m_rectPosition[12].left=150; m_rectPosition[12].right=200;
	m_strPosition[12] = "Col 24";
	m_rectPosition[13].top=85; m_rectPosition[13].bottom=105;
	m_rectPosition[13].left=200; m_rectPosition[13].right=250;
	m_strPosition[13] = "Col 25";
	m_rectPosition[14].top=85; m_rectPosition[14].bottom=105;
	m_rectPosition[14].left=250; m_rectPosition[14].right=300;
	m_strPosition[14] = "Col 26";
	m_rectPosition[15].top=85; m_rectPosition[15].bottom=105;
	m_rectPosition[15].left=300; m_rectPosition[15].right=350;
	m_strPosition[15] = "Col 27";
	m_rectPosition[16].top=85; m_rectPosition[16].bottom=105;
	m_rectPosition[16].left=350; m_rectPosition[16].right=400;
	m_strPosition[16] = "Col 28";

	// Position line 3
	m_rectPosition[17].top=110; m_rectPosition[17].bottom=130;
	m_rectPosition[17].left=10; m_rectPosition[17].right=50;
	m_strPosition[17] = "Col 31";
	m_rectPosition[18].top=110; m_rectPosition[18].bottom=130;
	m_rectPosition[18].left=50; m_rectPosition[18].right=100;
	m_strPosition[18] = "Col 32";
	m_rectPosition[19].top=110; m_rectPosition[19].bottom=130;
	m_rectPosition[19].left=100; m_rectPosition[19].right=150;
	m_strPosition[19] = "Col 33";
	m_rectPosition[20].top=110; m_rectPosition[20].bottom=130;
	m_rectPosition[20].left=150; m_rectPosition[20].right=200;
	m_strPosition[20] = "Col 34";
	m_rectPosition[21].top=110; m_rectPosition[21].bottom=130;
	m_rectPosition[21].left=200; m_rectPosition[21].right=250;
	m_strPosition[21] = "Col 35";
	m_rectPosition[22].top=110; m_rectPosition[22].bottom=130;
	m_rectPosition[22].left=250; m_rectPosition[22].right=300;
	m_strPosition[22] = "Col 36";
	m_rectPosition[23].top=110; m_rectPosition[23].bottom=130;
	m_rectPosition[23].left=300; m_rectPosition[23].right=350;
	m_strPosition[23] = "Col 37";
	m_rectPosition[24].top=110; m_rectPosition[24].bottom=130;
	m_rectPosition[24].left=350; m_rectPosition[24].right=400;
	m_strPosition[24] = "Col 38";

	// Position line 4
	m_rectPosition[25].top=135; m_rectPosition[25].bottom=155;
	m_rectPosition[25].left=10; m_rectPosition[25].right=50;
	m_strPosition[25] = "Col 41";
	m_rectPosition[26].top=135; m_rectPosition[26].bottom=155;
	m_rectPosition[26].left=50; m_rectPosition[26].right=100;
	m_strPosition[26] = "Col 42";
	m_rectPosition[27].top=135; m_rectPosition[27].bottom=155;
	m_rectPosition[27].left=100; m_rectPosition[27].right=150;
	m_strPosition[27] = "Col 43";
	m_rectPosition[28].top=135; m_rectPosition[28].bottom=155;
	m_rectPosition[28].left=150; m_rectPosition[28].right=200;
	m_strPosition[28] = "Col 44";
	m_rectPosition[29].top=135; m_rectPosition[29].bottom=155;
	m_rectPosition[29].left=200; m_rectPosition[29].right=250;
	m_strPosition[29] = "Col 45";
	m_rectPosition[30].top=135; m_rectPosition[30].bottom=155;
	m_rectPosition[30].left=250; m_rectPosition[30].right=300;
	m_strPosition[30] = "Col 46";
	m_rectPosition[31].top=135; m_rectPosition[31].bottom=155;
	m_rectPosition[31].left=300; m_rectPosition[31].right=350;
	m_strPosition[31] = "Col 47";
	m_rectPosition[32].top=135; m_rectPosition[32].bottom=155;
	m_rectPosition[32].left=350; m_rectPosition[32].right=400;
	m_strPosition[32] = "Col 48";

	m_nFieldsPosition = 32;

	// CRect	m_rectPosition[10];
	// CString	m_strPosition[10]

}

CTestExcelDoc::~CTestExcelDoc()
{
}

BOOL CTestExcelDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// ZU ERLEDIGEN: Hier Code zur Reinitialisierung einf�gen
	// (SDI-Dokumente verwenden dieses Dokument)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CTestExcelDoc Serialisierung

void CTestExcelDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// ZU ERLEDIGEN: Hier Code zum Speichern einf�gen
	}
	else
	{
		// ZU ERLEDIGEN: Hier Code zum Laden einf�gen
	}
}

/////////////////////////////////////////////////////////////////////////////
// CTestExcelDoc Diagnose

#ifdef _DEBUG
void CTestExcelDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CTestExcelDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTestExcelDoc Befehle

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 | Mobile
Web04 | 2.8.141022.2 | Last Updated 21 Apr 2002
Article Copyright 2002 by Franz Maerzinger
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid