°ÑaccessÊý¾Ý¿âµ¼Èëexcel±í¸ñ
public void ExportExcel(DataTable dtData, string filename)
{
System.Web.UI.WebControls.DataGrid dgExport = null;
// µ±Ç°¶Ô»°
System.Web.HttpContext curContext = System.Web.HttpContext.Current;
// IOÓÃÓÚµ¼³ö²¢·µ»ØexcelÎļþ
System.IO.StringWriter strWriter = null;
System.Web.UI.HtmlTextWriter htmlWriter = null;
if (dtData != null)
{
// ÉèÖñàÂëºÍ¸½¼þ¸ñʽ
curContext.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename) + ".xls");//¼ÓHttpUtility.UrlEncode()·½·¨´¦ÀíÎļþÃûÂÒÂë
curContext.Response.Charset = "gb2312";
curContext.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
//HttpContext.Current.Response.ContentType=".xls/.txt/.doc";image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
curContext.Response.ContentType = ".xls";
// µ¼³öexcelÎļþ
strWriter = new System.IO.StringWriter();
htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);
// ΪÁ˽â¾
Ïà¹ØÎĵµ£º
ʹÓÃÁËTCP/IP£¬ADO¼°XML£¨ÐèÒª°²×°Microsoft XML 4.0¡££©¡£·Ö·þÎñÆ÷ºÍ¿Í»§¶ËÁ½²¿·Ö£¬·þÎñÆ÷¿ÉÒÔ¶àÓû§Í¬Ê±Á¬½Ó¡£Ô¶³ÌÁ¬½ÓAccessÊý¾Ý¿âÓкܶ෽·¨£¬ÎÒÒÔÇ°ÒѾ±È½Ï¾ßÌåµÄ»Ø´ð¹ý£¨¼ûÏÂÃæËùÁеÄ5ÖÖ·½·¨£©£¬ÎÒÏÖÔÚÕâ¸öÀý×ÓÊôÓÚÆäÖеĵڣ³ÖÖ·½·¨£¨²»ÐèҪʹÓÃRDS»òWeb·þÎñÆ÷£©¡£
Ô¶³ÌÁ¬½ÓaccessÊý¾Ý¿âµÄ¼¸¸ö·½·¨£º
£±£®½¨Á¢VPN ......
Õ⼸Ìì°ïͬѧ×öÒ»¸öСµÄ¹ÜÀíϵͳ£¬B/S½á¹¹µÄ£¬ÓÉÓںܾÃûÓÐ×öB/S½á¹¹µÄ¶«Î÷ÁË£¬×öµÄʱºòºÜÉúÊè¡£Ò»¸öÏÂÎ磬Óöµ½ÁËÒ»¸öÎÊÌ⣺ÍùAccessÀï²åÈëÊý¾ÝµÄʱºò£¬ÀÏÊÇÌáʾÎÒsqlÓï¾ä´íÎ󣬵«ÊǾͺÜÄÉÃÆÁË£¬ÕâÖÖsqlÓï¾äдÁ˲»ÏÂ500±éÁË°É£¬¾ÍËãÊÇ×öÃÎÒ²²»»áд´íµÄ£¬Ôõô»ØÊ£¿sqlÓï¾ ......
Ê×Ò³£º
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head ......
¹ÊÕÏÏÖÏó:
Windows 2008 64λϵͳ,aspÍøÒ³·ÃÎÊaccessÊý¾Ý¿â±¨ÈçÏ´íÎó.
Ïà¹Ø´úÂë
set conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.mappath("db/db.mdb")
conn.open connstr
sql="select * fr ......