报表自定义工具栏
来源:互联网 发布:免费ddos攻击软件 编辑:程序博客网 时间:2024/05/16 05:00
VS提供了功能强大的报表工具栏,但有时候需要重新自定义工具栏,可以重新封转一个报表的操作类,重新定义报表的操作函数。
(1)报表导出
public static bool ReportExportTo(ReportViewer reportView, HttpResponse Response, stringfileType)
{
Microsoft.Reporting.WebForms.Warning[] Warnings;
string[] strStreamIds;
stringstrMimeType;
stringstrEncoding;
stringstrFileNameExtension;
stringfileSuffix = ".doc";
if(fileType.ToLower().Equals("word"))
{
fileSuffix = ".doc";
}
elseif(fileType.ToLower().Equals("pdf"))
{
fileSuffix = ".pdf";
}
elseif(fileType.ToLower().Equals("excel"))
{
fileSuffix = ".xls";
}
byte[] bytes = reportView.LocalReport.Render(fileType,null,outstrMimeType,
{
Microsoft.Reporting.WebForms.Warning[] Warnings;
string[] strStreamIds;
stringstrMimeType;
stringstrEncoding;
stringstrFileNameExtension;
stringfileSuffix = ".doc";
if(fileType.ToLower().Equals("word"))
{
fileSuffix = ".doc";
}
elseif(fileType.ToLower().Equals("pdf"))
{
fileSuffix = ".pdf";
}
elseif(fileType.ToLower().Equals("excel"))
{
fileSuffix = ".xls";
}
byte[] bytes = reportView.LocalReport.Render(fileType,null,outstrMimeType,
outstrEncoding,outstrFileNameExtension,outstrStreamIds,outWarnings);
try
{
Response.Buffer = true;
Response.AddHeader("Connection","Keep-Alive"); //添加文件标头
Response.ContentType = "application/ms-excel";
Response.AddHeader("Content-Disposition","attachment;filename="+ Utilities.GetTimeStamp() + fileSuffix);//下载时要保存的默认文件名
Response.BinaryWrite(bytes);
returntrue;
}
catch
{
returnfalse;
}
finally
{
Response.End();
Response.Close();
}
}
try
{
Response.Buffer = true;
Response.AddHeader("Connection","Keep-Alive"); //添加文件标头
Response.ContentType = "application/ms-excel";
Response.AddHeader("Content-Disposition","attachment;filename="+ Utilities.GetTimeStamp() + fileSuffix);//下载时要保存的默认文件名
Response.BinaryWrite(bytes);
returntrue;
}
catch
{
returnfalse;
}
finally
{
Response.End();
Response.Close();
}
}
(2)报表导出,报表直接打印功能涉及到DeviceInfo类参数的设置,在尝试失败后,采用的是先将报表导出到word文档,然后打印word文档,有一些影响性能,如果遇到更好的方法,以后再补充。
public static bool ReportExportTo(ReportViewer reportView, HttpResponse Response, string fileType)
{
Microsoft.Reporting.WebForms.Warning[] Warnings;
string[] strStreamIds;
string strMimeType;
string strEncoding;
string strFileNameExtension;
string fileSuffix = ".doc";
if (fileType.ToLower().Equals("word"))
{
fileSuffix = ".doc";
}
else if (fileType.ToLower().Equals("pdf"))
{
fileSuffix = ".pdf";
}
else if (fileType.ToLower().Equals("excel"))
{
fileSuffix = ".xls";
}
byte[] bytes = reportView.LocalReport.Render(fileType, null, out strMimeType, out strEncoding, out strFileNameExtension, out strStreamIds, out Warnings);
try
{
Response.Buffer = true;
Response.AddHeader("Connection", "Keep-Alive"); //添加文件标头
Response.ContentType = "application/ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=" + Utilities.GetTimeStamp() + fileSuffix);//下载时要保存的默认文件名
Response.BinaryWrite(bytes);
return true;
}
catch
{
return false;
}
finally
{
Response.End();
Response.Close();
}
}
{
Microsoft.Reporting.WebForms.Warning[] Warnings;
string[] strStreamIds;
string strMimeType;
string strEncoding;
string strFileNameExtension;
string fileSuffix = ".doc";
if (fileType.ToLower().Equals("word"))
{
fileSuffix = ".doc";
}
else if (fileType.ToLower().Equals("pdf"))
{
fileSuffix = ".pdf";
}
else if (fileType.ToLower().Equals("excel"))
{
fileSuffix = ".xls";
}
byte[] bytes = reportView.LocalReport.Render(fileType, null, out strMimeType, out strEncoding, out strFileNameExtension, out strStreamIds, out Warnings);
try
{
Response.Buffer = true;
Response.AddHeader("Connection", "Keep-Alive"); //添加文件标头
Response.ContentType = "application/ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=" + Utilities.GetTimeStamp() + fileSuffix);//下载时要保存的默认文件名
Response.BinaryWrite(bytes);
return true;
}
catch
{
return false;
}
finally
{
Response.End();
Response.Close();
}
}
- 报表自定义工具栏
- 自定义工具栏
- 自定义工具栏
- 【分享】自定义水晶报表工具栏导出按钮事件WinForm & WebForm版
- 帆软报表自定义在原工具栏上增加按钮导出其他模板
- 自定义水晶报表外观、工具栏、样式设置、除水晶报表的的公司LOGO 、替换图标等,非常实用!
- ALV自定义工具栏按钮
- 添加自定义工具栏图标
- 自定义工具栏图标
- 自定义myeclipse的工具栏
- FCKeditor(2.6)自定义工具栏
- 创建自定义的工具栏
- VC自定义工具栏
- ReportViewer : RDLC自定义工具栏
- 单文档自定义工具栏
- fckeditor自定义工具栏控件
- MFC创建自定义工具栏
- IE浏览器自定义工具栏
- 【原创】说说JSON和JSONP,也许你会豁然开朗,含jQuery用例
- 怎样为Linux内核打补丁,及特定版本内核下载
- 解决ffmpeg编译后ffplay没有生成的问题
- 《Windows程序设计》之鼠标2
- C语言中的多维数组(2)
- 报表自定义工具栏
- Exchange 2003 升级到Exchange 2010 之设置Internet Facing FQDN 名称!
- 教你禁用XP四大自动播放功能
- a walk throught the forest(HDU1142)
- c++ string类实现
- 用 IIS 7、ARR 與 Velocity 建设高性能的大型网站
- 【C++】setw函数的用法和作用【原创技术】
- 推荐:增强视觉站
- 上传文件测试