我的目的就是点击一个Button,弹出一个类似FileBrowserDialog的对话框,选中文件夹就可以把路径显示在一个TextBox里边,请教!
解决方案 »
- 奇怪的问题,Convert.ToInt32(Item.Cells[8].Text),总是出现错误Input string was not in a correc
- 导出Excel,在框架里面无效
- 求助asp.net读取二进制数据后下载的问题
- 环境配置简单问题--知道的请进
- 如果在我的机器上建立WEB站点和FTP站点是不是不能用同一个端口啊?
- post之前如何获得viewstate
- 有防止刷新的好办法吗?
- 我是新手,连接数据库有问题?
- 这是出什么问题吖?
- 求助 网页怎么通过香港服务器将谷歌搜索到的内容显现到自己的页面??急
- ASP.NET在后台如何获取页面HTML标签动态改变的内容?
- 在js中如何比较两个textbox里面的数字的大小?
<input id="Text1" type="text" />
<input id="File1" type="file" onchange="Text1.value=File1.value"/>
Server.MapPath()
你那先要给个string,然后获得的是该文件对应的物理地址。我想要的效果是类似FileUpLoad控件一样弹出一个窗体,然后选择文件夹。
TableLogOnInfo myLogInfo = new TableLogOnInfo();
string strPath = Server.MapPath("CrystalReport.rpt");
ReportDocument myReport = new ReportDocument(); myReport.Load(strPath);
this.CrystalReportViewer1.ReportSource = myReport; myLogInfo.ConnectionInfo.ServerName = "(local)";
myLogInfo.ConnectionInfo.DatabaseName = "Persons";
myLogInfo.ConnectionInfo.UserID = "sa";
myLogInfo.ConnectionInfo.Password = "123456";
myReport.Database.Tables[0].ApplyLogOnInfo(myLogInfo); ExportOptions exportOpts = new ExportOptions();
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
exportOpts = myReport.ExportOptions;
exportOpts.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
string foderPath = "C:\\Temp\\CrystalReport";
if(!System.IO.Directory.Exists(foderPath))
{
System.IO.Directory.CreateDirectory(foderPath);
} Response.Clear();
// 设置导出格式。
switch (DropDownList1.SelectedItem.Text)
{
case "PDF": exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
diskOpts.DiskFileName = foderPath+"\\CrystalReport.pdf";
Response.AppendHeader("Content-Disposition", "attachment;filename=CrystalReport.pdf");
Response.ContentType = "application/ms-pdf";
break;
case "WORD":
exportOpts.ExportFormatType = ExportFormatType.WordForWindows;
diskOpts.DiskFileName = foderPath+"\\CrystalReport.doc";
Response.AppendHeader("Content-Disposition", "attachment;filename=CrystalReport.doc");
Response.ContentType = "application/ms-word";
break;
case "EXCEL":
exportOpts.ExportFormatType = ExportFormatType.Excel;
diskOpts.DiskFileName = foderPath+"\\CrystalReport.xls";
Response.AppendHeader("Content-Disposition", "attachment;filename=CrystalReport.xls");
Response.ContentType = "application/ms-excel";
break;
default:
break; } exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
exportOpts.DestinationOptions = diskOpts;
myReport.Export();
myReport = null;
myLogInfo = null; /******************************************************************************/
//获取的是网站根目录对应的物理地址
//string path = Server.MapPath("~");
Response.Buffer = true;
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
this.EnableViewState = false;
Response.WriteFile(diskOpts.DiskFileName);
代码是把一个水晶报表导出,可以导出为PDF,EXCEL,DOC三种格式,想要多的格式,自己可以再加。