Calling Crystal Report, another try

A

Alex

Hello, everybody

I'm sorry, but maybe first time I'd asked this question it didn't
catch the eye of the proper person. So here I go again. There is a
Crystal Report file, let's say SomeReport.rpt. When the report is
designed it could've used hard coded ODBC data source name to connect
to the required database. So when I call this report it looking for
this ODBC data source and use it figure out the connection parameters -
database, user, password. On some reason this is not good for me, so
would like to be able to call report dynamically, i.e. pass all
required info to the report (database, user, password) using
"connection string".

Any help will be greatly appreciated.

Thanks,
Alex
 
J

jehugaleahsa

Hello, everybody

I'm sorry, but maybe first time I'd asked this question it didn't
catch the eye of the  proper person.  So here I go again.  There is a
Crystal Report file, let's say SomeReport.rpt.  When the report is
designed it could've used hard coded  ODBC data source name to connect
to the required database.  So when I call this report it looking for
this ODBC data source and use it figure out the connection parameters -
database, user, password.  On some reason this is not good for me, so
would like to be able to call report dynamically, i.e. pass all
required info to the report (database, user, password) using
"connection string".

Any help will be greatly appreciated.

Thanks,
Alex

Crystal Reports do not use a connection string, but instead you create
a ConnectionInfo class and populate the database, user name and
password. Here is a simple example of how to do it:

public void LogOnToDatabase(string userName, string password,
string database)
{
foreach (Table table in report.Database.Tables)
{
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo.ConnectionInfo = new ConnectionInfo();
logOnInfo.ConnectionInfo.Password = password;
logOnInfo.ConnectionInfo.ServerName = database;
logOnInfo.ConnectionInfo.UserID = userName;
table.ApplyLogOnInfo(logOnInfo);
}
}

In most reports there is just one "table" to log into. You *may* need
to recursively log in for subdocuments. I not sure what Business
Objects thinks a table is, but the name of the class confuses things.
I have written a fairly stable and useful library that simplifies the
ReportDocument class. It should be fairly straight forward. I will
paste it below; let me know if I am missing a file.

// CrystalReport.cs
using System.IO;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalReportsAccess;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.Enterprise;

namespace CrystalReportsAccess
{
public class CrystalReport : IDisposable
{
private readonly ReportDocument report;
private readonly CrystalParameters parametersProxy;
private bool disposed = false;
private string reportName;

public CrystalReport(string filePath)
{
if (!System.IO.File.Exists(filePath))
{
throw new IOException("File does not exist");
}
report = new ReportDocument();
report.Load(filePath);
parametersProxy = new CrystalParameters(report);
reportName = report.Name;
}

internal CrystalReport(ReportDocument document)
{
report = document;
parametersProxy = new CrystalParameters(report);
}

public string Name
{
get { return reportName; }
set { reportName = value; }
}

public CrystalReport GetSubDocument(string subDocumentName)
{
ReportDocument document =
report.OpenSubreport(subDocumentName);
return document == null ? null : new
CrystalReport(document);
}

public IEnumerable<CrystalReport> GetSubDocuments()
{
List<CrystalReport> reports = new List<CrystalReport>();
foreach (ReportDocument subDocument in report.Subreports)
{
reports.Add(new CrystalReport(subDocument));
}
return reports;
}

public void LogOnToDatabase(string userName, string password)
{
LogOnToDatabase(userName, password, String.Empty);
}

public void LogOnToDatabase(string userName, string password,
string database)
{
foreach (Table table in report.Database.Tables)
{
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo.ConnectionInfo = new ConnectionInfo();
logOnInfo.ConnectionInfo.Password = password;
logOnInfo.ConnectionInfo.ServerName = database;
logOnInfo.ConnectionInfo.UserID = userName;
table.ApplyLogOnInfo(logOnInfo);
}
}

public CrystalParameters Parameters
{
get { return parametersProxy; }
}

public void Export(string filePath, ExportFormatType format)
{
report.ExportToDisk(format, filePath);
}

public void Print(PrinterOptions options)
{
report.PrintOptions.PrinterName = options.PrinterName;
report.PrintOptions.PaperOrientation =
options.Orientation;
report.PrintOptions.PaperSize = options.PaperSize;
report.PrintOptions.PaperSource = options.PaperSource;
report.PrintOptions.PrinterDuplex = options.Duplexing;
PageMargins margins = new PageMargins(options.LeftMargin,
options.TopMargin,
options.RightMargin,
options.BottomMargin);
report.PrintOptions.ApplyPageMargins(margins);
report.PrintToPrinter(options.NumberOfCopies,
options.Collate,
options.FirstPage, options.LastPage);
}

public void Refresh()
{
report.Refresh();
}

~CrystalReport()
{
Dispose();
}

public void Dispose()
{
if (!disposed)
{
try
{
report.Dispose();
}
catch
{
}
disposed = true;
}
}

public object GetReportSource()
{
return report;
}
}
}

// CrystalParameters
using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.CrystalReports.Engine;
using System.Collections;
using CrystalDecisions.Shared;

namespace CrystalReportsAccess
{
public class CrystalParameters : IEnumerable<CrystalParameter>
{
private readonly ReportDocument report;

internal CrystalParameters(ReportDocument document)
{
report = document;
}

public CrystalParameter this[int index]
{
get { return new
CrystalParameter(report.ParameterFields[index]); }
}

public CrystalParameter this[string name]
{
get { return new
CrystalParameter(report.ParameterFields[name]); }
}

public CrystalParameter this[string name, string subReport]
{
get { return new
CrystalParameter(report.ParameterFields[name, subReport]); }
}

public IEnumerator<CrystalParameter> GetEnumerator()
{
foreach (ParameterField parameter in
report.ParameterFields)
{
yield return new CrystalParameter(parameter);
}
}

IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}

// CrystalParameter.cs
using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.Shared;

namespace CrystalReportsAccess
{
public class CrystalParameter
{
private readonly ParameterField parameter;

internal CrystalParameter(ParameterField field)
{
parameter = field;
}

public string Name
{
get { return parameter.Name; }
}

public void AddValues(params object[] values)
{
ParameterValues currentValues = parameter.CurrentValues;
if (currentValues == null)
{
currentValues = parameter.CurrentValues = new
ParameterValues();
}
foreach (object o in values)
{
ParameterDiscreteValue value = new
ParameterDiscreteValue();
value.Value = o;
currentValues.Add(value);
}
}

public void ClearValues()
{
ParameterValues currentValues = parameter.CurrentValues;
if (currentValues != null)
{
currentValues.Clear();
}
}

public object[] Values
{
get
{
List<object> values = new List<object>();
foreach (ParameterDiscreteValue value in
parameter.CurrentValues)
{
values.Add(value.Value);
}
return values.ToArray();
}
}
}
}

// PrinterOptions.cs
using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.Shared;

namespace CrystalReportsAccess
{
public class PrinterOptions
{
public PrinterOptions()
{
}

public PrinterOptions(string printerName)
{
PrinterName = printerName;
}

public string PrinterName = String.Empty;
public int NumberOfCopies = 1;
public bool Collate = false;
public int FirstPage = 0;
public int LastPage = 0;
public PaperOrientation Orientation =
PaperOrientation.DefaultPaperOrientation;
public PaperSize PaperSize = PaperSize.DefaultPaperSize;
public PaperSource PaperSource = PaperSource.Auto;
public PrinterDuplex Duplexing = PrinterDuplex.Default;
public int TopMargin = 360;
public int BottomMargin = 360;
public int LeftMargin = 360;
public int RightMargin = 360;
}
}
 
A

Alex

Wow!!
Thank you jehugaleahsa very much, as I understand you are very
knowledgeable person in this area and I hope you gave me all I need
(and I believe not just me, but many people struggling with this
"beast" as I read in one post :) ), but, indeed, this term "table"
sounds very confusing. I don't know about connection parameters to
the "table"... my crystal reports are based on one stored procedure,
but this stored procedure addresses to many tables....
I'll try to implement the code you gave,
Thanks a log again,
Alex


Hello, everybody
I'm sorry, but maybe first time I'd asked this question it didn't
catch the eye of the proper person. So here I go again. There is a
Crystal Report file, let's say SomeReport.rpt. When the report is
designed it could've used hard coded ODBC data source name to connect
to the required database. So when I call this report it looking for
this ODBC data source and use it figure out the connection parameters -
database, user, password. On some reason this is not good for me, so
would like to be able to call report dynamically, i.e. pass all
required info to the report (database, user, password) using
"connection string".
Any help will be greatly appreciated.
Thanks,
Alex

Crystal Reports do not use a connection string, but instead you create
a ConnectionInfo class and populate the database, user name and
password. Here is a simple example of how to do it:

public void LogOnToDatabase(string userName, string password,
string database)
{
foreach (Table table in report.Database.Tables)
{
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo.ConnectionInfo = new ConnectionInfo();
logOnInfo.ConnectionInfo.Password = password;
logOnInfo.ConnectionInfo.ServerName = database;
logOnInfo.ConnectionInfo.UserID = userName;
table.ApplyLogOnInfo(logOnInfo);
}
}

In most reports there is just one "table" to log into. You *may* need
to recursively log in for subdocuments. I not sure what Business
Objects thinks a table is, but the name of the class confuses things.
I have written a fairly stable and useful library that simplifies the
ReportDocument class. It should be fairly straight forward. I will
paste it below; let me know if I am missing a file.

// CrystalReport.cs
using System.IO;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalReportsAccess;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.Enterprise;

namespace CrystalReportsAccess
{
public class CrystalReport : IDisposable
{
private readonly ReportDocument report;
private readonly CrystalParameters parametersProxy;
private bool disposed = false;
private string reportName;

public CrystalReport(string filePath)
{
if (!System.IO.File.Exists(filePath))
{
throw new IOException("File does not exist");
}
report = new ReportDocument();
report.Load(filePath);
parametersProxy = new CrystalParameters(report);
reportName = report.Name;
}

internal CrystalReport(ReportDocument document)
{
report = document;
parametersProxy = new CrystalParameters(report);
}

public string Name
{
get { return reportName; }
set { reportName = value; }
}

public CrystalReport GetSubDocument(string subDocumentName)
{
ReportDocument document =
report.OpenSubreport(subDocumentName);
return document == null ? null : new
CrystalReport(document);
}

public IEnumerable<CrystalReport> GetSubDocuments()
{
List<CrystalReport> reports = new List<CrystalReport>();
foreach (ReportDocument subDocument in report.Subreports)
{
reports.Add(new CrystalReport(subDocument));
}
return reports;
}

public void LogOnToDatabase(string userName, string password)
{
LogOnToDatabase(userName, password, String.Empty);
}

public void LogOnToDatabase(string userName, string password,
string database)
{
foreach (Table table in report.Database.Tables)
{
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo.ConnectionInfo = new ConnectionInfo();
logOnInfo.ConnectionInfo.Password = password;
logOnInfo.ConnectionInfo.ServerName = database;
logOnInfo.ConnectionInfo.UserID = userName;
table.ApplyLogOnInfo(logOnInfo);
}
}

public CrystalParameters Parameters
{
get { return parametersProxy; }
}

public void Export(string filePath, ExportFormatType format)
{
report.ExportToDisk(format, filePath);
}

public void Print(PrinterOptions options)
{
report.PrintOptions.PrinterName = options.PrinterName;
report.PrintOptions.PaperOrientation =
options.Orientation;
report.PrintOptions.PaperSize = options.PaperSize;
report.PrintOptions.PaperSource = options.PaperSource;
report.PrintOptions.PrinterDuplex = options.Duplexing;
PageMargins margins = new PageMargins(options.LeftMargin,
options.TopMargin,
options.RightMargin,
options.BottomMargin);
report.PrintOptions.ApplyPageMargins(margins);
report.PrintToPrinter(options.NumberOfCopies,
options.Collate,
options.FirstPage, options.LastPage);
}

public void Refresh()
{
report.Refresh();
}

~CrystalReport()
{
Dispose();
}

public void Dispose()
{
if (!disposed)
{
try
{
report.Dispose();
}
catch
{
}
disposed = true;
}
}

public object GetReportSource()
{
return report;
}
}

}

// CrystalParameters
using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.CrystalReports.Engine;
using System.Collections;
using CrystalDecisions.Shared;

namespace CrystalReportsAccess
{
public class CrystalParameters : IEnumerable<CrystalParameter>
{
private readonly ReportDocument report;

internal CrystalParameters(ReportDocument document)
{
report = document;
}

public CrystalParameter this[int index]
{
get { return new
CrystalParameter(report.ParameterFields[index]); }
}

public CrystalParameter this[string name]
{
get { return new
CrystalParameter(report.ParameterFields[name]); }
}

public CrystalParameter this[string name, string subReport]
{
get { return new
CrystalParameter(report.ParameterFields[name, subReport]); }
}

public IEnumerator<CrystalParameter> GetEnumerator()
{
foreach (ParameterField parameter in
report.ParameterFields)
{
yield return new CrystalParameter(parameter);
}
}

IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}

}

// CrystalParameter.cs
using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.Shared;

namespace CrystalReportsAccess
{
public class CrystalParameter
{
private readonly ParameterField parameter;

internal CrystalParameter(ParameterField field)
{
parameter = field;
}

public string Name
{
get { return parameter.Name; }
}

public void AddValues(params object[] values)
{
ParameterValues currentValues = parameter.CurrentValues;
if (currentValues == null)
{
currentValues = parameter.CurrentValues = new
ParameterValues();
}
foreach (object o in values)
{
ParameterDiscreteValue value = new
ParameterDiscreteValue();
value.Value = o;
currentValues.Add(value);
}
}

public void ClearValues()
{
ParameterValues currentValues = parameter.CurrentValues;
if (currentValues != null)
{
currentValues.Clear();
}
}

public object[] Values
{
get
{
List<object> values = new List<object>();
foreach (ParameterDiscreteValue value in
parameter.CurrentValues)
{
values.Add(value.Value);
}
return values.ToArray();
}
}
}

}

// PrinterOptions.cs
using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.Shared;

namespace CrystalReportsAccess
{
public class PrinterOptions
{
public PrinterOptions()
{
}

public PrinterOptions(string printerName)
{
PrinterName = printerName;
}

public string PrinterName = String.Empty;
public int NumberOfCopies = 1;
public bool Collate = false;
public int FirstPage = 0;
public int LastPage = 0;
public PaperOrientation Orientation =
PaperOrientation.DefaultPaperOrientation;
public PaperSize PaperSize = PaperSize.DefaultPaperSize;
public PaperSource PaperSource = PaperSource.Auto;
public PrinterDuplex Duplexing = PrinterDuplex.Default;
public int TopMargin = 360;
public int BottomMargin = 360;
public int LeftMargin = 360;
public int RightMargin = 360;
}



}- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
 
A

Alex

Hello, jehugaleahsa
Sorry for bothering you again, one more question. In your function
Print I could not find "preview" option before printing.
Thanks,
Alex


Hello, everybody
I'm sorry, but maybe first time I'd asked this question it didn't
catch the eye of the proper person. So here I go again. There is a
Crystal Report file, let's say SomeReport.rpt. When the report is
designed it could've used hard coded ODBC data source name to connect
to the required database. So when I call this report it looking for
this ODBC data source and use it figure out the connection parameters -
database, user, password. On some reason this is not good for me, so
would like to be able to call report dynamically, i.e. pass all
required info to the report (database, user, password) using
"connection string".
Any help will be greatly appreciated.
Thanks,
Alex

Crystal Reports do not use a connection string, but instead you create
a ConnectionInfo class and populate the database, user name and
password. Here is a simple example of how to do it:

public void LogOnToDatabase(string userName, string password,
string database)
{
foreach (Table table in report.Database.Tables)
{
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo.ConnectionInfo = new ConnectionInfo();
logOnInfo.ConnectionInfo.Password = password;
logOnInfo.ConnectionInfo.ServerName = database;
logOnInfo.ConnectionInfo.UserID = userName;
table.ApplyLogOnInfo(logOnInfo);
}
}

In most reports there is just one "table" to log into. You *may* need
to recursively log in for subdocuments. I not sure what Business
Objects thinks a table is, but the name of the class confuses things.
I have written a fairly stable and useful library that simplifies the
ReportDocument class. It should be fairly straight forward. I will
paste it below; let me know if I am missing a file.

// CrystalReport.cs
using System.IO;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalReportsAccess;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.Enterprise;

namespace CrystalReportsAccess
{
public class CrystalReport : IDisposable
{
private readonly ReportDocument report;
private readonly CrystalParameters parametersProxy;
private bool disposed = false;
private string reportName;

public CrystalReport(string filePath)
{
if (!System.IO.File.Exists(filePath))
{
throw new IOException("File does not exist");
}
report = new ReportDocument();
report.Load(filePath);
parametersProxy = new CrystalParameters(report);
reportName = report.Name;
}

internal CrystalReport(ReportDocument document)
{
report = document;
parametersProxy = new CrystalParameters(report);
}

public string Name
{
get { return reportName; }
set { reportName = value; }
}

public CrystalReport GetSubDocument(string subDocumentName)
{
ReportDocument document =
report.OpenSubreport(subDocumentName);
return document == null ? null : new
CrystalReport(document);
}

public IEnumerable<CrystalReport> GetSubDocuments()
{
List<CrystalReport> reports = new List<CrystalReport>();
foreach (ReportDocument subDocument in report.Subreports)
{
reports.Add(new CrystalReport(subDocument));
}
return reports;
}

public void LogOnToDatabase(string userName, string password)
{
LogOnToDatabase(userName, password, String.Empty);
}

public void LogOnToDatabase(string userName, string password,
string database)
{
foreach (Table table in report.Database.Tables)
{
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo.ConnectionInfo = new ConnectionInfo();
logOnInfo.ConnectionInfo.Password = password;
logOnInfo.ConnectionInfo.ServerName = database;
logOnInfo.ConnectionInfo.UserID = userName;
table.ApplyLogOnInfo(logOnInfo);
}
}

public CrystalParameters Parameters
{
get { return parametersProxy; }
}

public void Export(string filePath, ExportFormatType format)
{
report.ExportToDisk(format, filePath);
}

public void Print(PrinterOptions options)
{
report.PrintOptions.PrinterName = options.PrinterName;
report.PrintOptions.PaperOrientation =
options.Orientation;
report.PrintOptions.PaperSize = options.PaperSize;
report.PrintOptions.PaperSource = options.PaperSource;
report.PrintOptions.PrinterDuplex = options.Duplexing;
PageMargins margins = new PageMargins(options.LeftMargin,
options.TopMargin,
options.RightMargin,
options.BottomMargin);
report.PrintOptions.ApplyPageMargins(margins);
report.PrintToPrinter(options.NumberOfCopies,
options.Collate,
options.FirstPage, options.LastPage);
}

public void Refresh()
{
report.Refresh();
}

~CrystalReport()
{
Dispose();
}

public void Dispose()
{
if (!disposed)
{
try
{
report.Dispose();
}
catch
{
}
disposed = true;
}
}

public object GetReportSource()
{
return report;
}
}

}

// CrystalParameters
using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.CrystalReports.Engine;
using System.Collections;
using CrystalDecisions.Shared;

namespace CrystalReportsAccess
{
public class CrystalParameters : IEnumerable<CrystalParameter>
{
private readonly ReportDocument report;

internal CrystalParameters(ReportDocument document)
{
report = document;
}

public CrystalParameter this[int index]
{
get { return new
CrystalParameter(report.ParameterFields[index]); }
}

public CrystalParameter this[string name]
{
get { return new
CrystalParameter(report.ParameterFields[name]); }
}

public CrystalParameter this[string name, string subReport]
{
get { return new
CrystalParameter(report.ParameterFields[name, subReport]); }
}

public IEnumerator<CrystalParameter> GetEnumerator()
{
foreach (ParameterField parameter in
report.ParameterFields)
{
yield return new CrystalParameter(parameter);
}
}

IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}

}

// CrystalParameter.cs
using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.Shared;

namespace CrystalReportsAccess
{
public class CrystalParameter
{
private readonly ParameterField parameter;

internal CrystalParameter(ParameterField field)
{
parameter = field;
}

public string Name
{
get { return parameter.Name; }
}

public void AddValues(params object[] values)
{
ParameterValues currentValues = parameter.CurrentValues;
if (currentValues == null)
{
currentValues = parameter.CurrentValues = new
ParameterValues();
}
foreach (object o in values)
{
ParameterDiscreteValue value = new
ParameterDiscreteValue();
value.Value = o;
currentValues.Add(value);
}
}

public void ClearValues()
{
ParameterValues currentValues = parameter.CurrentValues;
if (currentValues != null)
{
currentValues.Clear();
}
}

public object[] Values
{
get
{
List<object> values = new List<object>();
foreach (ParameterDiscreteValue value in
parameter.CurrentValues)
{
values.Add(value.Value);
}
return values.ToArray();
}
}
}

}

// PrinterOptions.cs
using System;
using System.Collections.Generic;
using System.Text;
using CrystalDecisions.Shared;

namespace CrystalReportsAccess
{
public class PrinterOptions
{
public PrinterOptions()
{
}

public PrinterOptions(string printerName)
{
PrinterName = printerName;
}

public string PrinterName = String.Empty;
public int NumberOfCopies = 1;
public bool Collate = false;
public int FirstPage = 0;
public int LastPage = 0;
public PaperOrientation Orientation =
PaperOrientation.DefaultPaperOrientation;
public PaperSize PaperSize = PaperSize.DefaultPaperSize;
public PaperSource PaperSource = PaperSource.Auto;
public PrinterDuplex Duplexing = PrinterDuplex.Default;
public int TopMargin = 360;
public int BottomMargin = 360;
public int LeftMargin = 360;
public int RightMargin = 360;
}



}- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
 
J

jehugaleahsa

Hello, jehugaleahsa
Sorry for bothering you again, one more question.  In your function
Print I could not find "preview" option before printing.
Thanks,
Alex

Do Crystal Reports support print preview? I mean what is a "print
preview"? A better question would be, do the Crystal Reports
themselves support print preview, or does the CrystalReportViewer
handle it?

We have found an alternate solution that includes printing or
exporting to a PDF and then showing the PDF in a viewer, or we just
use the CrystalReportViewer and attach the
CrystalReportViewer.ReportSource = CrystalReport.GetReportSource().
The purpose of the CrystalReport class isn't to replace
ReportDocument, it is to simplify its interface. You can easily
discard it and rip out the code you need. I provide the
GetReportSource() method as a way of getting the underlying object
when needed by the Business Objects library.

The reason the method returns Object is because that is all the more
the CrystalReportViewer requires to work. I try not to put classes
that are DLL-dependent in my interfaces since it saves clients from
needing addition "using" statements and references. Plus, it gives me
the option of loading a DLL dynamically, if desired.

Don't worry about asking questions; half the responsibility of a
library is making sure it is easy to understand.
 
A

Alex

Currently I'm using functionality from some dll which is Crystal
Report SDK wrapper It uses ODBC data source to connect to database.
That's is why I have to re-write it. Unfortunately it's not my dll
and I don't know how it's been done, but I think it does something
like you described above, because I'm doing it in several steps:
................
int nX = ::GetSystemMetrics( SM_CXFULLSCREEN );
int nY = ::GetSystemMetrics( SM_CYFULLSCREEN );
dl::.EnablePreviewPrint( TRUE );
dll::EnablePreviewExport(TRUE );
dll::UseCustomPreviewPrint( TRUE );
dll::preview( strReportTitle, nX, nY ) );
................

Thanks for suggesting me keep asking questions

A
 
A

Alex

Jehugaleahsa, here I come again:

How can add the following namespaces in my project:

using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.Enterprise;

My VS 7 doesn't see these references. Should I look for some Crystal
Decisions dll?

Thanks,
Alex
 
A

Alex

Jehugaleahsa and others, please, disregard this question, I've found
these references. Sorry.

Alex
 
A

Alex

Jehugaleahsa, I have a problem compiling the code you provided.
The following lines cause the error:

public IEnumerable<CrystalReport> GetSubDocuments()
{
List<CrystalReport> reports = new List<CrystalReport>();
..............

The error is:
"The non-generic type "System.Collections.IEnumerable cannot be used
with type arguments"

What should I add to my (your actually :) ) code to get it working,
thanks,
Alex
 
J

jehugaleahsa

Jehugaleahsa, I have a problem compiling the code you provided.
The following lines cause the error:

       public IEnumerable<CrystalReport> GetSubDocuments()
        {
            List<CrystalReport> reports = new List<CrystalReport>();
..............

The error is:
"The non-generic type "System.Collections.IEnumerable cannot be used
with type arguments"

What should I add to my (your actually :) ) code to get it working,
thanks,
Alex




- Show quoted text -

You need to include using System.Collections.Generics;

It must have gotten chopped off.
 
A

Alex

Hello, Jehugaleahsa, sorry for using this nickname, but I couldn't
find anything else instead. Now all of your code has been compiled OK
in my project. Thanks a lot for you great response. But I havn't had
an opportunity to use it though. Hopefully everything will be fine,
otherwise you'll see some more questions from me :)

Best regards,
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top