How to export EXCEL from Asp.net on Godaddy

Source: Internet
Author: User

There is no problem in importing excel on godddy, but system. Security. securityexception is prompted when exporting excel.

Solution steps:

1. To the http://nopcommerce.codeplex.com/download nopce-ce-a6bd30c10ba3.zip, This is the version I downloaded.

2. decompress the package and find epplus. dll in the nopcommerce_a6bd30c10ba3 \ SRC \ packages \ epplus.2.9.0.1 \ Lib \ 2.0 folder.

3. Put epplus. dll in the bin folder of your project, or add reference

4. Usage:

using System;using System.IO;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using Maticsoft.DBUtility;using OfficeOpenXml;protected void Export(){    FileInfo newFile = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "/Download/Download.xls");    if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "/Download/Download.xls"))    {        File.Delete(AppDomain.CurrentDomain.BaseDirectory + "/Download/Download.xls");    }              using (ExcelPackage xlPackage = new ExcelPackage(newFile))    {        ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets.Add("SheetName");        worksheet.Cells[1, 1].Value = "a1";        worksheet.Cells[1, 2].Value = "b1";        worksheet.Cells[2, 1].Value = "a2";        worksheet.Cells[2, 2].Value = "b2";        xlPackage.Save();    }}

Here, only the files are saved to the server and are not automatically downloaded. If you need to download them automatically, you need to handle it yourself. I use the URL to download the files, please let me know how to automatically bring up the download prompt dialog box. Thank you.

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.