以Excel格式导出CR.net [英] Export CR.net in Excel Format

查看:76
本文介绍了以Excel格式导出CR.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用vb.net并希望将数据从CR导出到excel。这是我的代码。

I am using vb.net and want to export data from CR to excel. Here is my code.

Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
...(其他处理)
rpt.Load(Server.MapPath(" INWARD_RECEIPTtele.rpt"))点击...(其它处理)点击rpt.SetDataSource(数据集)点击rpt.SetDatabaseLogon(ConfigurationSettings.AppSettings(登录,密码)结果如果(format.Equals(QUOT ; EXCEL"))然后,点击昏暗strExportFile作为字符串=使用Server.Mappath(QUOT;")&安培;" /temp.xls"结果,rpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile结果,RPT。 ExportOptions.ExportFormatType = ExportFormatType.Excel
Dim objExcelOptions As ExcelFormatOptions = New ExcelFormatOptions
objExcelOptions.ExcelUseConstantColumnWidth = False
rpt.ExportOptions.FormatOptions = objExcelOptions
Dim objOptions As DiskFileDestinationOptions = New DiskFileDestinationOptions
objOptions。 DiskFileName = strExportFile


















objOptions = Nothing
rpt = Nothing
Response.Redirect(" temp.xls",False)
Endif

Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
...(other processing)
rpt.Load(Server.MapPath("INWARD_RECEIPTtele.rpt"))
...(other processing)
rpt.SetDataSource(DataSet)
rpt.SetDatabaseLogon(ConfigurationSettings.AppSettings(Login, Password)
If (format.Equals("EXCEL")) Then
Dim strExportFile As String = Server.MapPath(".") & "/temp.xls"
rpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
rpt.ExportOptions.ExportFormatType = ExportFormatType.Excel
Dim objExcelOptions As ExcelFormatOptions = New ExcelFormatOptions
objExcelOptions.ExcelUseConstantColumnWidth = False
rpt.ExportOptions.FormatOptions = objExcelOptions
Dim objOptions As DiskFileDestinationOptions = New DiskFileDestinationOptions
objOptions.DiskFileName = strExportFile
rpt.ExportOptions.DestinationOptions = objOptions
rpt.Export() <-----------HERE COMES THE ERROR objOptions = Nothing
rpt = Nothing
Response.Redirect("temp.xls", False)
Endif

错误是"inwardreceipttele.rpt:访问报告文件被拒绝。另一个程序可能正在使用它。"
它真的很紧急。如果有人帮助我,请提前感谢。

Error is "inwardreceipttele.rpt: Access to report file denied. Another program may be using it."
Its really urgent. If anybody from you could help me then thanks in advance.


推荐答案

我自己没有使用导出到excel格式功能,但导出到PDF格式是熟悉的。导出为PDF时遇到类似的(如果不是相同的)错误。

I haven't used the export to excel format functionality myself but the export to PDF format is familiar. I encountered a similiar (if not the same) error when exporting to PDF.

我的错误是ASP.NET用户帐户没有权限创建,修改并删除我尝试导出到的目录中的文件。为了让导出工作,我所要做的就是为ASP.NET用户提供导出目录的上述权限。

The error in my case was that the ASP.NET user account didn't have enought rights to create, modify and delete files in the directory that I tried to export to. All I had to do to get the export to work was to give the ASP.NET user the above mentioned rights for the export directory.


这篇关于以Excel格式导出CR.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆