Asp.NetÖÐWord,ExcelµÈoffice com×é¼þ²Ù×÷ȨÏÞµÄÎÊÌâ
½üÈÕÔÚ´ò¿ªÔÀ´Ð´µÄÒ»¸öÍøÒ³³ÌÐòÔËÐÐʱ£¬³öÏÖÁËExcel²Ù×÷ȨÏÞµÄÎÊÌ⣬¾ßÌåµÄ˵¾ÍÊÇÔÚ´úÂëÖе÷ÓÃÏÂÃæÕâ¶ÎÓëExcel²Ù×÷ÓйصÄÓï¾äʱ£¬
¡¡¡¡Application curExcelApp = new ApplicationClass();
¡¡¡¡ÌáʾȨÏÞ²»×㣬¾ßÌåµÄÌáʾÄÚÈÝÈçÏ£º
¡¡¡¡¼ìË÷ COM À๤³§ÖÐ CLSID Ϊ {00024500-0000-0000-C000-000000000046} µÄ×é¼þʱʧ°Ü£¬ÔÒòÊdzöÏÖÒÔÏ´íÎó: 80070005¡£
¡¡¡¡¡¡¡¡ËµÃ÷: Ö´Ðе±Ç° Web ÇëÇóÆڼ䣬³öÏÖδ´¦ÀíµÄÒì³£¡£Çë¼ì²é¶ÑÕ»¸ú×ÙÐÅÏ¢£¬ÒÔÁ˽âÓйظôíÎóÒÔ¼°´úÂëÖе¼Ö´íÎóµÄ³ö´¦µÄÏêϸÐÅÏ¢¡£ Òì³£ÏêϸÐÅÏ¢: system.UnauthorizedAccessException: ¼ìË÷ COM À๤³§ÖÐ CLSID Ϊ {00024500-0000-0000-C000-000000000046} µÄ×é¼þʱʧ°Ü£¬ÔÒòÊdzöÏÖÒÔÏ´íÎó: 80070005¡£ ASP.NET δ±»ÊÚȨ·ÃÎÊËùÇëÇóµÄ×ÊÔ´¡£Ç뿼ÂÇÊÚÓè ASP.NET ÇëÇó±êʶ·ÃÎÊ´Ë×ÊÔ´µÄȨÏÞ¡£ASP.NET ÓÐÒ»¸öÔÚÓ¦ÓóÌÐòûÓÐÄ£ÄâʱʹÓõĻù½ø³Ì±êʶ(ͨ³££¬ÔÚ IIS 5 ÉÏΪ {MACHINE}ASPNET£¬ÔÚ IIS 6 ÉÏΪÍøÂç·þÎñ)¡£Èç¹ûÓ¦ÓóÌÐòÕýÔÚͨ¹ý <identity impersonate="true"/> Ä£Ä⣬Ôò±êʶ½«ÎªÄäÃûÓû§(ͨ³£Îª IUSR_MACHINENAME)»ò¾¹ýÉí·ÝÑéÖ¤µÄÇëÇóÓû§¡£ Òª½« ASP.NET ·ÃÎÊȨÏÞÊÚÓèij¸öÎļþ£¬ÇëÔÚ×ÊÔ´¹ÜÀíÆ÷ÖÐÓÒ»÷¸ÃÎļþ£¬Ñ¡Ôñ“ÊôÐÔ”£¬È»ºóÑ¡Ôñ“°²È«”Ñ¡Ï¡£µ¥»÷“Ìí¼Ó”Ìí¼ÓÊʵ±µÄÓû§»ò×顣ͻ³öÏÔʾ ASP.NET ÕÊ»§£¬Ñ¡ÖÐËùÐè·ÃÎÊȨÏÞ¶ÔÓ¦µÄ¿ò¡£ Ô´´íÎó: ¡¡¡¡¡¡¡¡ ÐÐ 533:¡¡¡¡¡¡¡¡//´´½¨ExcelÐÅÏ¢¡¡¡¡¡¡¡¡
ÐÐ 534:¡¡¡¡¡¡¡¡object missing = system.Reflection.Missing.Value;¡¡¡¡¡¡¡¡
ÐÐ 535:¡¡¡¡¡¡¡¡Application curExcelApp = new ApplicationClass();¡¡¡¡¡¡¡¡
ÐÐ 536:¡¡¡¡¡¡¡¡curExcelApp.Application.DisplayAlerts = false;¡¡¡¡¡¡¡¡
ÐÐ 537:¡¡¡¡¡¡¡¡Workbook curWorkBook = curExcelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
¡¡¡¡ÔÀ´Åöµ½¹ýÕâÖÖÇé¿ö£¬ÖªµÀÊÇÓÉÓÚExcelµÄDCom×é¼þȨÏÞ²»×ãËùÒýÆðµÄ£¬ËùÒÔ°´ÕÕÔÀ´µÄ²½Öè½øÐÐÉèÖã¬ÈçÏÂËùʾ£º
¡¡¡¡1:ÔÚ·þÎñÆ÷ÉÏ°²×°officeµÄExcelÈí¼þ;
¡¡¡¡2:ÔÚ"¿ªÊ¼"->"ÔËÐÐ"ÖÐÊäÈëdcomcnfg.exeÆô¶¯"×é¼þ·þÎñ";
¡¡¡¡3:ÒÀ´ÎË«»÷"×é¼þ·þÎñ"->"¼ÆËã»ú"->"ÎҵĵçÄÔ"->"DCOMÅäÖÃ";
¡¡¡¡4:ÔÚ"DCOMÅäÖÃ"ÖÐÕÒµ½"Microsoft Excel Ó¦ÓóÌÐò",ÔÚËüÉÏÃæµã»÷ÓÒ¼ü,È»ºóµã»÷"ÊôÐÔ",µ¯³ö"Microsoft Excel Ó¦ÓóÌÐòÊôÐÔ"¶Ô»°¿ò;
¡¡¡¡5:µã»÷"±êʶ"±êÇ©,Ñ¡Ôñ"½»»¥Ê½Óû§";
¡¡¡¡6:µ
Ïà¹ØÎĵµ£º
1£ºÔÚ.aspxÒ³Ã棬<% %>±êÇ©Ï൱ÓÚÔÚ.csÒ³ÃæµÄ´úÂ룬Ҳ¾ÍÊÇ˵ÄãÔÚ.csÎļþÀïÃæÔõÑùд£¬¾Í¿ÉÒÔÔÚ.aspxÎļþÀïÃæµÄ<% %>±êÇ©ÀïÃæÔõÑùд¡£
2£ºÔÚ.aspxÒ³Ã棬<%= %>±êÇ©¿ÉÒÔµ÷ÓÃÄãµÄºǫ́µÄ±äÁ¿»òÕß·½·¨µÈ£¬²»¹ý±»µ÷Óõķ½·¨±ØÐëÊÇpublicµÄ¡£
Èç¹ûÄãµÄDefault.csÎļþÀïÃæÓУº
public string str = "µ÷Óúǫ́·½ ......
ASP.NET 2009-08-15 13:45 ÔĶÁ459 ÆÀÂÛ3 ×ֺţº ´ó´ó ÖÐÖРСС 1.Asp.NetÖм¸ÖÖÏàËƵıê¼Ç·ûºÅ:
< %=...%>< %#... %>< % %>< %@ %>½âÊͼ°Ó÷¨
´ð: < %#... %>: ÊÇÔڰ󶨿ؼþDataBind()·½·¨Ö´ÐÐʱ±»Ö´ÐУ¬ÓÃÓÚÊý¾Ý°ó¶¨
Èç: < %# Co ......
ÍøÂç´òÓ¡¸ÅÊö
¡¡¡¡• B/S½á¹¹µ¼ÖÂÁËWebÓ¦ÓóÌÐòÖдòÓ¡µÄÌØÊâÐÔ¡£
¡¡¡¡• ³ÌÐòÔËÐÐÔÚä¯ÀÀÆ÷ÖУ¬´òÓ¡»úÔÚ±¾µØ£¬¶øÎļþÈ·¿ÉÄÜÔÚ·þÎñÆ÷ÉÏ£¬µ¼ÖÂÁË´òÓ¡¿ØÖƲ»ÊǺÜÁé»î¡£
¡¡¡¡• ¸ñʽÈçºÎ¿ØÖƺͶ¨ÖƵȣ¬ÊÇÎÒÃÇ¿ª·¢ÖпÉÄÜ»áÃæ¶ÔµÄÎÊÌâ¡£
¡¡¡¡´òÓ¡ÎĵµµÄÉú³É
¡¡¡¡• 1¡¢¿Í»§¶Ë½Å±¾·½Ê½
¡¡¡¡Ò»°ãÇé¿öÏ£¬Ö÷ÒªÊ ......
1. ×¢²ájsº¯Êý
String scriptString = "<script language=JavaScript>function doClick(){";
scriptString += "for(var index=0;index<myArray.length;index++)";
scriptString += "alert(myArray[index]);}<";
scriptString += "/" + "script>";
ClientScript.RegisterStartupScript(typeof(WebForm2) ......
If Óï¾äÔÚASP.NETÖеÄÓ¦ÓÃ
ÔÚASP.NETÖÐÓÐÐí¶àµØ·½ÒªÓõ½“ifÓï¾ä”£¬ÆäʵifÓï¾äÊÇC# ·ÖÖ§½á¹¹ ÖеÄÒ»ÖÖ¡£
·ÖÖ§½á¹¹ÊÇÓÐÌõ¼þµÄÖ´ÐдúÂ룬¿ØÖÆÏÂÒ»²½ÒªÖ´ÐÐÄÄЩ´úÂëµÄ¹ý³Ì¡£
·ÖÖ§½á¹¹£º
1£®ifÓï¾ä
2£®SwitchÓï¾ä
½ñÌìËù½²µÄÄÚÈÝΪif Óï¾ä£º
Ê×ÏÈC#ÖÐif½á¹¹µÄÓï·¨ÈçÏ£º
If (±í´ïʽ)
{
´úÂë¿ ......