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 ¶Ô Îļþ½øÐÐѹËõ or ½âѹ£¨zip£©
/// <summary>
/// ¶ÔÎļþ½øÐУ¨Ñ¹Ëõ£¬½âѹ£©
/// </summary>
public static class ZIP
{
/// <summary>ѹËõÎļþ</summary>
/// <param name="filename">filenameÉú³ÉµÄÎļþµÄÃû³Æ£¬È磺C\123\123.zip</param>
/// <param name="d ......
asp.net×°Ôؽø¶ÈÌõ¼°¹¤×÷Ò³Ãæ¿ò¼ÜÖ÷ÒªÓÉ4¸ö²¿·Ö×é³É,Õâ4¸ö²¿·ÖµÄÃû³Æ¼°ÔÚÕû¸ö¿ò¼ÜÖÐËùÆðµ½µÄ×÷ÓÃÈçÏÂ:
1.Èë¿ÚÁ´½ÓµØÖ·Ò³Ãæ(aspx):±ÈÈç,µÇ¼ҳÃæ.Ìṩµ½Ä¿±êµØÖ·µÄÒ»¸öÁ´½Ó,²¢Ïò¸ÃÄ¿±ê´«µÝһЩÆô¶¯±ØÐëµÄ»ù±¾Á´½Ó²ÎÊý.
2.Èë¿ÚÁ´½ÓÄ¿±êÒ³Ãæ(aspx):¸ÃÄ¿±ê¶ÔÏóÊÇÕû¸ö¿ò¼ÜµÄºËÐÄ,Ò³Ãæ×°ÔØʱͨ¹ýdocument.writeÊä³ö2¸öiframe,Æä ......
If Óï¾äÔÚASP.NETÖеÄÓ¦ÓÃ
ÔÚASP.NETÖÐÓÐÐí¶àµØ·½ÒªÓõ½“ifÓï¾ä”£¬ÆäʵifÓï¾äÊÇC# ·ÖÖ§½á¹¹ ÖеÄÒ»ÖÖ¡£
·ÖÖ§½á¹¹ÊÇÓÐÌõ¼þµÄÖ´ÐдúÂ룬¿ØÖÆÏÂÒ»²½ÒªÖ´ÐÐÄÄЩ´úÂëµÄ¹ý³Ì¡£
·ÖÖ§½á¹¹£º
1£®ifÓï¾ä
2£®SwitchÓï¾ä
½ñÌìËù½²µÄÄÚÈÝΪif Óï¾ä£º
Ê×ÏÈC#ÖÐif½á¹¹µÄÓï·¨ÈçÏ£º
If (±í´ïʽ)
{
´úÂë¿ ......