Use aspose. cells for simple excle Export

Source: Internet
Author: User
// Create a new excelsheet workbook buildreport_workbook = new Workbook (); worksheet buildreport_worksheet = tables [0]; cells buildreportcells = buildreport_worksheet.cells; buildreportcells [0, 0]. putvalue ("User Type"); buildreportcells [0, 1]. putvalue ("User Name"); buildreportcells [0, 2]. putvalue ("phone number"); buildreportcells [0, 3]. putvalue ("Unit Address"); // read data and import it to cells for (INT I = 0; I <listsystemus Erinfo. count; I ++) {buildreportcells [1 + I, 0]. putvalue (usertype. find (Int. parse (listsystemuserinfo [I]. usertype. tostring ())). dispstring. tostring (); buildreportcells [1 + I, 1]. putvalue (listsystemuserinfo [I]. username. tostring (); buildreportcells [1 + I, 2]. putvalue (listsystemuserinfo [I]. phone. tostring (); buildreportcells [1 + I, 3]. putvalue (listsystemuserinfo [I]. address. tostring ();} buildreport_w Orksheet. Name = "Address Book"; buildreport_worksheet.autofitcolumns (); string savefilename = server. mappath ("~ /Attachinfo/"+ buildreport_worksheet.name + ". xls "); // save Excel buildreport_workbook.save (savefilename, fileformattype. excel2003); // output fileinfo file = new fileinfo (savefilename); filestream = file. openread (); byte [] buffer = new byte [(INT) filestream. length]; filestream. read (buffer, 0, (INT) filestream. length); filestream. close (); response. clear (); response. appendheader ("content-disposition", "attachment; filename =" + server. urlencode (datetime. now. tostring ("yyyymmdd") + ". xls "); response. contenttype = "application/octet-stream"; response. contentencoding = system. text. encoding. utf8; response. binarywrite (buffer); response. flush (); file. delete (); response. clear (); response. end ();

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.