R
Ramstar
I am working in VS2005 and am trying to figure out how to print the
speadsheet object data without much success. I can get paper to cycle though
the printer but no data printed on it. Same with the print preveiw, can view
but no data. What connection am I missing to the axspreadsheet object? Here
is code snippet: Thanks for any help.
private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
this.pagesPrinted = 0;
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
}
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
float yPos = 0;
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
string line = null;
//calculate number of lines per page
int linesPerPage = (int)(e.MarginBounds.Height /
mainFont.GetHeight(e.Graphics));
int lineNo = this.pagesPrinted * linesPerPage;
//print each line of the file.
int count = 0;
while (count < linesPerPage && lineNo < this.nLines)
{
line = ((TextLineInformation)this.documentLines[lineNo]).Text;
yPos = topMargin + (count * mainFont.GetHeight(e.Graphics));
e.Graphics.DrawString(line, mainFont, Brushes.Blue,
leftMargin, yPos, new StringFormat());
lineNo++;
count++;
}
// if more lines exist, print another page.
if (this.nLines > lineNo)
{
e.HasMorePages = true;
}
else
{
e.HasMorePages = false;
}
pagesPrinted++;
}
private void printPreviewToolStripMenuItem_Click(object sender,
EventArgs e)
{
this.pagesPrinted = 0;
PrintPreviewDialog ppd = new PrintPreviewDialog();
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
ppd.Document = pd;
ppd.ShowDialog();
}
speadsheet object data without much success. I can get paper to cycle though
the printer but no data printed on it. Same with the print preveiw, can view
but no data. What connection am I missing to the axspreadsheet object? Here
is code snippet: Thanks for any help.
private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
this.pagesPrinted = 0;
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
}
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
float yPos = 0;
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
string line = null;
//calculate number of lines per page
int linesPerPage = (int)(e.MarginBounds.Height /
mainFont.GetHeight(e.Graphics));
int lineNo = this.pagesPrinted * linesPerPage;
//print each line of the file.
int count = 0;
while (count < linesPerPage && lineNo < this.nLines)
{
line = ((TextLineInformation)this.documentLines[lineNo]).Text;
yPos = topMargin + (count * mainFont.GetHeight(e.Graphics));
e.Graphics.DrawString(line, mainFont, Brushes.Blue,
leftMargin, yPos, new StringFormat());
lineNo++;
count++;
}
// if more lines exist, print another page.
if (this.nLines > lineNo)
{
e.HasMorePages = true;
}
else
{
e.HasMorePages = false;
}
pagesPrinted++;
}
private void printPreviewToolStripMenuItem_Click(object sender,
EventArgs e)
{
this.pagesPrinted = 0;
PrintPreviewDialog ppd = new PrintPreviewDialog();
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
ppd.Document = pd;
ppd.ShowDialog();
}