asp.net²Ù×÷word
http://www.cnblogs.com/jinglelin/archive/2005/09/02/228486.html
Éæ¼°µ½asp.net²Ù×÷wordµÄÎÊÌâ
½ñÄêÂ½ÐøÓÖÅöµ½²Ù×÷excel¡¢wordµÈofficeÎĵµ
ʹÓõͼÊÇInteropÏà¹Ødll£¬´ò¿ªofficeÏà¹Ø½ø³Ì½øÐвÙ×÷
ΪÃâÍü¼Ç£¬½«Ïà¹ØtipÕûÀíÈçÏ£º
1. ÒýÓÃÎļþ,¼¸¸ödll´ò°üÁË
2. ²Ù×÷word´úÂëʾÀý:
using ImportExportToOffice;
using Microsoft.ApplicationBlocks.Data;
protected void btnJianJie_Click(object sender, EventArgs e)
{
string sYear = DropDownList2.SelectedValue;
string sMonth = DropDownList1.SelectedValue;
string sDate1 = String.Format("{0}-{1}-{2}", sYear, sMonth, "1");
string sDate2 = String.Format("{0}-{1}-{2}", sYear, sMonth, System.DateTime.DaysInMonth(int.Parse(sYear), int.Parse(sMonth)).ToString());
word = new ImportExportToWord();
string sTmpUrl = "../Report/" + Guid.NewGuid().ToString() + ".Doc";
string sTmpFile = Server.MapPath(sTmpUrl);
string sModelDoc = Server.MapPath("../Report/¹ú¼ÊÂþÓμò±¨Ä£°å.doc");
System.IO.File.Copy(sModelDoc, sTmpFile, true);
try
{
word.Open(sTmpFile);
object sBookMark = "";
//GSM À´·Ãǰʮ ·Ö¹«Ë¾
sBookMark = "GSM_1";
if (word.Document.Bookmarks.Exists(sBookMark.ToString()))
{
word.Document.Bookmarks.get_Item(ref sBookMark).Select();
string sSql = "SELECT TOP 10 t1.ToCarrier, COUNT(t1.ToCarrier) AS Num, t2.ShortName AS Name" +
" from BiteGSM t1 INNER JOIN" +
" BranchInfo t2 ON t1.ToCarrier = t2.ID" +
" INNER JOIN DispatchInfo t3 ON t1.DispatchID = t3.ID" +
" Where t3.SendTime >='" + sDate1 + "'" +
" And t3.SendTime <='" + sDate2 + "'" +
" And t1.SimType=1" +
" GROUP BY t1.ToCarrier, t2.ShortName" +
" ORDER BY COUNT(t1.ToCarrier) DESC";
SqlDa
Ïà¹ØÎĵµ£º
Ôõôдһ¶Îasp.net´úÂ룬°ÑÒ»¸ö×Ö·û´®ÖÐËùÓеÄHTML±ê¼Ç¶¼È¥µô£¬Ö»Ê£ÏÂÎÄ×ÖÄÚÈÝÄØ£¿
±ÈÈ磺<td width=\"427\" align=\"left\" class=\"cn\">½Ï¸ßµÄζȣ¬¿ÉÄÜÔö¼ÓÆ¡¾Æ¶ÔÄúµÄÓÕ»ó£¬ÊÊÁ¿ÒûÓÃÆ¡¾Æ»á¸øÄú´øÀ´ÇåÁ¹µÄ¸Ð¾õ£¬µ«Ç§Íò×¢Òâ²»Òª¹ýÁ¿ßÏ£¡</td>
......
char[] constant = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', ......
×î½ü×öµÄϵͳÖÐÀϳöÏÖµÄһЩÎÊÌⲻ̫Ã÷°×£¬ÔÚʹÓà Response.End¡¢Response.Redirect »ò Server.Transfer ʱ³öÏÖ ThreadAbortException £¬±¾À´ÏµÍ³ÊÇûÓÐÎÊÌâµÄ£¬ÔÚ±£´æÊý¾ÝʱҲ¿ÉÒÔÕý³££¬±¾À´Ê¹ÓÃtry-catch Óï¾äÊÇÓÃÀ´²¶»ñÒ»Òì³£Çé¿öµÄ£¬µ«ÏµÍ³Õý³££¬Àϲ¶»ñµ½ÏÂÃæµÄ¶«Î÷
##[²Ù×÷¼Ç¼]£º2010-02-23 9:25:12 Sys ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Sha ......
1.¾¡Á¿Ê¹ÓÃHtml¾²Ì¬Ò³Ãæ¡£aspxÔÚÊý¾Ý½»»¥·½ÃæÓкܺõĵĽ»»¥ÄÜÁ¦£¬µ«ÊÇÒ²»áÏûºÄÒ»¶¨µÄ·þÎñÆ÷×ÊÔ´£¬ËùÒÔÎÒÃǾ¡Á¿Óô¿htmlµÄҳȥʵÏÖ¡£×îÖØÒªµÄCMSµÄÓ¦ÓÃ
2.±ÜÃâ²»±ØÒªµÄ»ØËͲÙ×÷£¬Ã¿´Îµ¥»÷Ò³Ãæ°´Å¥¶¼Òª¼ÓÔØPage_Loadʼþ£¬ÓÃPage.IsPostBack±ÜÃâ²»±ØÒªµÄ¼ÓÔØ
3.¾¡Á¿ÔÚ¿Í»§¶Ë½øÐÐÑéÖ¤²Ù×÷£¬Í¨¹ýjs½øÐÐʵÏÖ
4.ÓÅÏÈʹÓÃHtml¿ ......