ASP. NET office Pia programming experience

Source: Internet
Author: User
Recently, the project needs to operate Excel in ASP. NET. There is no problem with encoding, and some problems have been encountered in environment settings. After several days of study, I finally got it done.
Summary:
Environment Settings:
1. Excel must be installed on the server.
I started to dream about using DLL for release. Some forums said yes. After several days of hard work, I confirmed that all these are yy.
2. DCOM permission settings.
There are a lot of detailed information on the Internet and screenshots are also provided.
3. The Sky knows what it is.
In an environment, it is clear that the setting is successful. if the machine is switched, the setting fails, and the excel.exe fails.
Programming considerations;
1. It is necessary to release the COM object. Because the COM object is not hosted Code .

Try
{
If(O! = Null)
Marshal. releasecomobject (O );
}

Finally
{
O= Null;
}

2. Save and close the Excel file. If (WB ! =   Null )
{
WB. Saved= True;
WB. Close (False, Type. Missing, type. Missing );
}

TIPS:
It is best not to use com Excel operations, MS is not recommended, and easy to error. If you only want to read and write Excel files, use oledb directly.
Fatal problem:
When an interactive query occurs in Excel, ASP. NET will wait for the request to die.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.