Silverlight Program: A simple Excel Report export method

Source: Internet
Author: User
Tags silverlight

Silverlight Program: A simple Excel Report export method

Overview

Introduces a simple method of Excel report export.

Page effects

Export effects:

First we create an Excel table and set up our basic information format as shown in:

Save the Excel table you created as a Web page.

Open vs Drag the Created Report template Web page file to the Web project new Reports folder

Modify the suffix named aspx

Open File

Add header Code

<%@ page language= "C #" contenttype= "application/vnd.ms-excel"%>
<%@ Import namespace= "Mmisui. Dao.report "%>
<%@ Import namespace= "Mmisui. Models.report "%>

Find the head with Chinese characters <tr>

Modify and Add code

Inside you can get the data set and loop through the cells. Form a form.

<tr class=xl9719632 height=25 style= ' mso-height-source:userset;height:18.75pt ' >
&LT;TD height=25 class=xl8919632 style= ' height:18.75pt ' > Material Coding </td>
&LT;TD class=xl8919632> Material Name </td>
&LT;TD class=xl8919632> Specification Model </td>
&LT;TD class=xl8919632> Unit of measurement </td>
&LT;TD class=xl8919632> Material Type </td>
&LT;TD class=xl8919632> Annual </td>
&LT;TD class=xl8919632> Time </td>
&LT;TD class=xl9019632> Quantity </td>
&LT;TD class=xl9119632> Amount </td>
&LT;TD class=xl9019632> Quantity </td>
&LT;TD class=xl9119632> Amount </td>
&LT;TD class=xl9019632> Quantity </td>
&LT;TD class=xl9119632> Amount </td>
</tr>
<%

string s = request.querystring["username"];
string S1 = request.querystring["email"];
Decimal Stockledger_bamount = 0,
Stockledger_bmoney = 0,
Stockledger_iamount = 0,
Stockledger_imoney = 0,
Stockledger_oamount = 0,
Stockledger_omoney = 0;
var dao = "Supplydetailreportdao". Instance<isupplydetailreportdao> ();
var list= dao. Getmaterialdispatchlist ();
for (int i = 0; i < list. Count; i++)
{
var mat = list[i] as Materialdispatchreport;
if (mat==null) continue;
Stockledger_bamount + = Mat. Stockledger_bamount;
Stockledger_bmoney + = Mat. Stockledger_bmoney;
Stockledger_iamount + = Mat. Stockledger_iamount;
Stockledger_imoney + = Mat. Stockledger_imoney;
Stockledger_oamount + = Mat. Stockledger_oamount;
Stockledger_omoney + = Mat. Stockledger_omoney;
%>

<tr class=xl7019632 height=17 style= ' mso-height-source:userset;height:12.75pt ' >
&LT;TD height=17 class=xl7119632 style= ' height:12.75pt ' ><%=i%></td>
&LT;TD class=xl7219632 width=129 style= ' width:97pt ' ><%=mat. Mat_code%></td>
&LT;TD Class=xl7319632><%=mat. Mat_name%></td>
&LT;TD Class=xl7319632><%=mat. Mat_model%></td>
&LT;TD Class=xl7319632><%=mat. Units_name%></td>
&LT;TD Class=xl7319632><%=mat. Materielcls_name%></td>
&LT;TD Class=xl7319632><%=mat. Stockledger_year%></td>
&LT;TD Class=xl7319632><%=mat. Stockledger_period%></td>
&LT;TD Class=xl7419632><%=mat. Stockledger_bamount%></td>
&LT;TD Class=xl7519632><%=mat. Stockledger_bmoney%></td>
&LT;TD Class=xl7619632><%=mat. Stockledger_iamount%></td>
&LT;TD Class=xl7519632><%=mat. Stockledger_imoney%></td>
&LT;TD Class=xl7619632><%=mat. Stockledger_oamount%></td>
&LT;TD Class=xl7519632><%=mat. Stockledger_omoney%></td>
</tr>

<%
}%>

<tr class=xl7719632 height=24 style= ' mso-height-source:userset;height:18.0pt ' >
&LT;TD height=24 class=xl7819632 style= ' height:18.0pt ' > Total:</td>
&LT;TD class=xl7919632 width=129 style= ' width:97pt ' > </td>
&LT;TD class=xl8019632> </td>
&LT;TD class=xl8019632> </td>
&LT;TD class=xl8019632> </td>
&LT;TD class=xl8019632> </td>
&LT;TD class=xl8019632> </td>
&LT;TD class=xl8019632> </td>
&LT;TD class=xl8119632><%=stockledger_bamount%></td>
&LT;TD class=xl8219632><%=stockledger_bmoney%></td>
&LT;TD class=xl8319632><%=stockledger_iamount%></td>
&LT;TD class=xl8219632><%=stockledger_imoney%></td>
&LT;TD class=xl8319632><%=stockledger_oamount%></td>
&LT;TD class=xl8219632><%=stockledger_omoney%></td>
</tr>

Delete the extra table ...

Called Inside the Silverlight program

var uri = new Uri (App.Current.Host.Source, "... /report/material receiving and depositing report. Aspx?username={0}&email={1} ");
Htmlpage.popupwindow (URI, "_blank", New htmlpopupwindowoptions ());

Run the program and click the Export button to prompt you to open save Cancel.

Done!!!


Memories of the Lost youth
Source: http://www.cnblogs.com/lukun/
This article copyright belongs to the author and the blog Park, welcome reprint, but without the consent of the author must retain this paragraph statement, and in the article page obvious location to the original link, if there is a problem, can contact me through http://www.cnblogs.com/lukun/ , thank you very much.

Silverlight Program: A simple Excel Report export method

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.