on 12-18-2008 11:14 PM
Hi, I am trying to clean up the excel export of a crystal report and am using visual studio 2005 and the CR.net that comes with it, I think version 10.
I have the following code that it runs if the export type is excel and I was just trying to make sure it is working. It does not seem to be making any difference in the exported excel file.
I am using office 2007.
private ReportDocument document;
ExcelFormatOptions excelformat = new ExcelFormatOptions();
excelformat.ExcelUseConstantColumnWidth = true ;
excelformat.ExcelConstantColumnWidth = 20;
excelformat.ExcelTabHasColumnHeadings = false;
excelformat.LastPageNumber = 2;
excelformat.FirstPageNumber = 3;
excelformat.UsePageRange = true;
document.ExportOptions.ExportFormatOptions = excelformat;
Hi, Paul;
Try changing your code a bit.
Change the line:
document.ExportOptions.ExportFormatOptions = excelformat
to:
ExportOptions.ExportFormatOptions = excelformat
document.Export (ExportOptions)
Then try different options for the formatting to see if they are really changes.
Regards,
Jonathan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the information, just wondering is that ment to be one line. I commented out the line
document.ExportOptions.ExportFormatOptions-excelformat;
and replaced it with two lines
ExportOptions.ExportFormatOptions = excelformat;
document.Export(ExportOptions);
on the first new line I get the following error
Error 1 An object reference is required for the nonstatic field, method, or property 'CrystalDecisions.Shared.ExportOptions.ExportFormatOptions.get'
on the second new line I get the error
Error 2 'CrystalDecisions.Shared.ExportOptions' is a 'type' but is used like a 'variable'
Hi, Paul;
Here is the complete block of sample code:
Dim rep As New CrystalReport1
Dim expOptions As New ExportOptions
Dim expdest As New DiskFileDestinationOptions
Dim expformat As New ExcelDataOnlyFormatOptions
'----
expdest.DiskFileName = "c:\ExportedExcel.xls"
'----
expformat.ExcelUseConstantColumnWidth = True
expformat.ExcelAreaType = AreaSectionKind.WholeReport
expformat.ExcelConstantColumnWidth = 60
expformat.ExcelUseConstantColumnWidth = True
expformat.ExportPageHeaderAndPageFooter = True
'----
expOptions.ExportDestinationType =
ExportDestinationType.DiskFile
expOptions.ExportDestinationOptions = expdest
expOptions.ExportFormatOptions = expformat
expOptions.ExportFormatType = ExportFormatType.ExcelRecord
'----
rep.Export(expOptions)
Regards,
Jonathan
Hi I tried the settings in the example but still did not see any changes. I noticed that in my code the export type is Excel where in the example it is ExcelRecord, although do not think this would make a difference. Will take another look at my code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks for the quick response, I am using C#, I think your example is in VB. I think my code is the equivalent in C# but I will take a closer look at the code you provided. Assuming the code is correct wondering if there is anything else that could cause it from not working?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.