zoukankan      html  css  js  c++  java
  • 有关ASP.net里操作EXCEL的注意点

    这几天郁闷死了。只给一天的时间。要完成一个EXCEL任意形式报表在asp.net环境下的
    下发。上传。统计。
    以前从来没有写过office程序。MSDN又还是4月份的。没办法。只好看
     X:\Program Files\Microsoft Visual Studio .NET
    2003\SDK\v1.1\Samples\Technologies\Interop\Applications\Office\Excel里的
    DEMO。
    我用的是OFFICE2003
    按SDK里说的
    set ExcelTlb=D:\Program Files\Microsoft Office\Office11\excel.exe
    然后是
    nmake D:\Program Files\Microsoft Visual Studio .NET
    2003\SDK\v1.1\Samples\Technologies\Interop\Applications\Office\Excel\makefil
    e
    OK
    winform下跑的很正常。代码见。AutoExcel.cs
    但是同样的代码扔到asp.net里
    第一句
    Application app = new Application();
    竟报错。:(
    按照给的第一个提示:在web.config里加上了AutoExcel.cs
    <identity impersonate="true"/>
    然后F5 :)。OK。第一句可以。但是后面又出
    System.Runtime.InteropServices.COMException: 服务器出现意外情况
    这个太要命了。
    试了半天。没结果。没办法。
    找了另一位枪手写了个COM来做。结果winform好用。但是webform还是一样的错。郁闷
    到家了。

    把GOOGLE翻了个遍,最后查到了终极的解决方案。

    “配置Dcom。运行Dcomcnfg.exe,找到Excel应用程序,配置其属性,身份验证级别选"
    无",身份标识选"交互式用户",安全性页面,启动和访问均给
    everyone。”

    这段话真是太太太太太太管用了。配完一跑。哈哈。可以了。
    不然就是有源码都跑不起来  :(
  • 相关阅读:
    237. Delete Node in a Linked List
    430. Flatten a Multilevel Doubly Linked List
    707. Design Linked List
    83. Remove Duplicates from Sorted List
    160. Intersection of Two Linked Lists
    426. Convert Binary Search Tree to Sorted Doubly Linked List
    142. Linked List Cycle II
    类之间的关系
    初始化块
    明确类和对象
  • 原文地址:https://www.cnblogs.com/tongzhenhua/p/13023.html
Copyright © 2011-2022 走看看