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 ' >
<TD height=25 class=xl8919632 style= ' height:18.75pt ' > Material Coding </td>
<TD class=xl8919632> Material Name </td>
<TD class=xl8919632> Specification Model </td>
<TD class=xl8919632> Unit of measurement </td>
<TD class=xl8919632> Material Type </td>
<TD class=xl8919632> Annual </td>
<TD class=xl8919632> Time </td>
<TD class=xl9019632> Quantity </td>
<TD class=xl9119632> Amount </td>
<TD class=xl9019632> Quantity </td>
<TD class=xl9119632> Amount </td>
<TD class=xl9019632> Quantity </td>
<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 ' >
<TD height=17 class=xl7119632 style= ' height:12.75pt ' ><%=i%></td>
<TD class=xl7219632 width=129 style= ' width:97pt ' ><%=mat. Mat_code%></td>
<TD Class=xl7319632><%=mat. Mat_name%></td>
<TD Class=xl7319632><%=mat. Mat_model%></td>
<TD Class=xl7319632><%=mat. Units_name%></td>
<TD Class=xl7319632><%=mat. Materielcls_name%></td>
<TD Class=xl7319632><%=mat. Stockledger_year%></td>
<TD Class=xl7319632><%=mat. Stockledger_period%></td>
<TD Class=xl7419632><%=mat. Stockledger_bamount%></td>
<TD Class=xl7519632><%=mat. Stockledger_bmoney%></td>
<TD Class=xl7619632><%=mat. Stockledger_iamount%></td>
<TD Class=xl7519632><%=mat. Stockledger_imoney%></td>
<TD Class=xl7619632><%=mat. Stockledger_oamount%></td>
<TD Class=xl7519632><%=mat. Stockledger_omoney%></td>
</tr>
<%
}%>
<tr class=xl7719632 height=24 style= ' mso-height-source:userset;height:18.0pt ' >
<TD height=24 class=xl7819632 style= ' height:18.0pt ' > Total:</td>
<TD class=xl7919632 width=129 style= ' width:97pt ' > </td>
<TD class=xl8019632> </td>
<TD class=xl8019632> </td>
<TD class=xl8019632> </td>
<TD class=xl8019632> </td>
<TD class=xl8019632> </td>
<TD class=xl8019632> </td>
<TD class=xl8119632><%=stockledger_bamount%></td>
<TD class=xl8219632><%=stockledger_bmoney%></td>
<TD class=xl8319632><%=stockledger_iamount%></td>
<TD class=xl8219632><%=stockledger_imoney%></td>
<TD class=xl8319632><%=stockledger_oamount%></td>
<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