asp.net 导出Excel/Word
asp.net中导出有很多方法。其中比较推荐的兼容导出是导出为word/excel兼容的mhtml格式并设置流格式为word或excel。
这中方法的好处是可以建立一个通用的库。本文中提出了一个通用的导出类,实践中使用效果较好。(ps,html解析类写的比较仓促,各位如有兴趣可重写一下~)
///
///@Author Simsure
///@Version 1.0
///
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Net;
using System.IO;
/// <summary>
///MHtmlDocument 的摘要说明
/// </summary>
public class MHtmlDocument
{
protected const string _NEXT_PART = "------=_NextPart_WIND";
protected const string _4NEXT_PART = "----=_NextPart_WIND";
private const string WIND_SESSION_ID = "wind.sessionid";
protected string _encoding = "utf-8";
protected string _pageVirutalPath;
protected string _rootHttpVirtualPath;
protected bool _enableBase64 = false;
protected HtmlDocument _baseDocument;
protected HttpRequest _request;
protected HttpResponse _response;
protected static readonly log4net.ILog _log = log4net.LogManager.GetLogger("MHtmlDocument");
public string Encoding
{
get { return _encoding; }
}
public string RootHttpVirtualPath
{
get { return _rootHttpVirtualPath; }
}
public string PageVirtualPath
{
get { return _pageVirutalPath; }
}
public bool EnableBase64
{
get { return _enableBase64; }
set { _enableBase6
相关文档:
Asp.net连接SQL Server2000数据库例程详解:
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.SqlClient" %>
<script laguage="VB" runat="server">
sub page_load(sender as Object ......
URL 重写是截取传入 Web 请求并自动将请求重定向到其他 URL 的过程。
比如浏览器发来请求hostname/101.aspx ,服务器自动将这个请求中定向为http://hostname/list.aspx?id=101。
url重写的优点在于:
缩短url,隐藏实际路径提高安全性
易于用户记忆和键入。
&nbs ......
System.Drawing.Image watermark = System.Drawing.Image.fromFile(Server.MapPath("watermark.gif"));
Bitmap srcImg = new Bitmap(Server.MapPath("example.jpg"));
Graphics graphics = Graphics.fromImage(srcImg);
graphics.DrawImage(watermark,
srcImg.Width - watermark.Width,
srcImg.Height - w ......