ASP.NET EXCEL資料的匯出和匯入
資料的匯入和匯出在實際的專案中,用的非常普遍。我在自己的專案中實現了從excel檔案中匯入和到處資料,現分析如下:
一、資料的匯出,其基本思想是首先將要匯出的內容放在Table中並拼成字串,然後以EXCEL檔案的形式匯出。在我的專案中,使用者可以自己選擇要匯出的資料欄位。因為實際的欄位較多,故只列出部分欄位。
頁面的html如下:
Code
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> <div id="DivProjectProperty" style="text-align: center; color: White">
<fieldset>
<legend>專案匯出欄位legend>
<div id="DivProjectBasic" style="margin-top: 5px">
<fieldset style="text-align: left;">
<legend>專案基本欄位legend>
<table id="tableProjectBasic" cellpadding="0" cellspacing="0" width="99%" style="margin-left: 10px">
<tr>
<td>
<input type="checkbox" id="CheckboxProjectBasicSelectAll" name="ProjectBasic" class="ProjectBasic"
onclick="selectProjectPropertyAll(this)" />選擇全部
td>
<td>
<input type="checkbox" id="CheckboxProjectName" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />名稱
td>
<td>
<input type="checkbox" id="CheckboxProjectSerialNumber" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />流水號
td>
<td>
<input type="checkbox" id="CheckboxProjectNumber" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />編號
td>
<td>
<input type="checkbox" id="CheckboxProjectPrincipalNumber" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />負責人工作證號
td>
<td>
<input type="checkbox" id="CheckboxProjectPrincipalName" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />負責人姓名
td>
tr>
<tr>
<td>
<input type="checkbox" id="CheckboxProjectState" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />狀態
td>
<td>
<input type="checkbox" id="CheckboxProjectStartDate" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />開始日期
td>
<td>
<input type="checkbox" id="CheckboxProjectEndDate" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />結束日期
td>
<td>
<input type="checkbox" id="CheckboxProjectCreator" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />創立人
td>
<td>
<input type="checkbox" id="CheckboxProjectCreateDate" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />創立日期
td>
<td>
<input type="checkbox" id="CheckboxprojectUpdateDate" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />更新日期
td>
tr>
<tr>
<td>
<input type="checkbox" id="CheckboxProjectSubjectCode" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />學科程式碼
td>
<td>
<input type="checkbox" id="CheckboxProjectResearchType" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />研究型別
td>
<td>
<input type="checkbox" id="CheckboxProjectIsSerect" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />是否保密
td>
<td>
<input type="checkbox" id="CheckboxProjectBaseName" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />基地名稱
td>
<td>
<input type="checkbox" id="CheckboxProjectCooperationType" class="ProjectBasic" checked="checked"
runat="server" onclick="changeSelectAllState(this)" />合作型別
td>
<td>
<input type="checkbox" id="CheckboxProjectUnit" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />合作單位
td>
tr>
<tr>
<td>
<input type="checkbox" id="CheckboxPorjectTaskFrom" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />任務來源
td>
<td>
<input type="checkbox" id="CheckboxProjectCorporationPlace" class="ProjectBasic"
checked="checked" runat="server" onclick="changeSelectAllState(this)" />公司地址
td>
<td>
<input type="checkbox" id="CheckboxProjectRemark" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />備註
td>
tr>
table>
fieldset>
div>
fieldset>
div>
<div id="DivOperator" style="text-align: center; margin-
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> <div id="DivProjectProperty" style="text-align: center; color: White">
<fieldset>
<legend>專案匯出欄位legend>
<div id="DivProjectBasic" style="margin-top: 5px">
<fieldset style="text-align: left;">
<legend>專案基本欄位legend>
<table id="tableProjectBasic" cellpadding="0" cellspacing="0" width="99%" style="margin-left: 10px">
<tr>
<td>
<input type="checkbox" id="CheckboxProjectBasicSelectAll" name="ProjectBasic" class="ProjectBasic"
onclick="selectProjectPropertyAll(this)" />選擇全部
td>
<td>
<input type="checkbox" id="CheckboxProjectName" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />名稱
td>
<td>
<input type="checkbox" id="CheckboxProjectSerialNumber" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />流水號
td>
<td>
<input type="checkbox" id="CheckboxProjectNumber" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />編號
td>
<td>
<input type="checkbox" id="CheckboxProjectPrincipalNumber" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />負責人工作證號
td>
<td>
<input type="checkbox" id="CheckboxProjectPrincipalName" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />負責人姓名
td>
tr>
<tr>
<td>
<input type="checkbox" id="CheckboxProjectState" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />狀態
td>
<td>
<input type="checkbox" id="CheckboxProjectStartDate" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />開始日期
td>
<td>
<input type="checkbox" id="CheckboxProjectEndDate" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />結束日期
td>
<td>
<input type="checkbox" id="CheckboxProjectCreator" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />創立人
td>
<td>
<input type="checkbox" id="CheckboxProjectCreateDate" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />創立日期
td>
<td>
<input type="checkbox" id="CheckboxprojectUpdateDate" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />更新日期
td>
tr>
<tr>
<td>
<input type="checkbox" id="CheckboxProjectSubjectCode" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />學科程式碼
td>
<td>
<input type="checkbox" id="CheckboxProjectResearchType" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />研究型別
td>
<td>
<input type="checkbox" id="CheckboxProjectIsSerect" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />是否保密
td>
<td>
<input type="checkbox" id="CheckboxProjectBaseName" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />基地名稱
td>
<td>
<input type="checkbox" id="CheckboxProjectCooperationType" class="ProjectBasic" checked="checked"
runat="server" onclick="changeSelectAllState(this)" />合作型別
td>
<td>
<input type="checkbox" id="CheckboxProjectUnit" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />合作單位
td>
tr>
<tr>
<td>
<input type="checkbox" id="CheckboxPorjectTaskFrom" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />任務來源
td>
<td>
<input type="checkbox" id="CheckboxProjectCorporationPlace" class="ProjectBasic"
checked="checked" runat="server" onclick="changeSelectAllState(this)" />公司地址
td>
<td>
<input type="checkbox" id="CheckboxProjectRemark" class="ProjectBasic" runat="server"
checked="checked" onclick="changeSelectAllState(this)" />備註
td>
tr>
table>
fieldset>
div>
fieldset>
div>
<div id="DivOperator" style="text-align: center; margin-
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12639172/viewspace-464292/,如需轉載,請註明出處,否則將追究法律責任。
上一篇:
Excel物件模型的一些使用心得(C#)
下一篇:
c# oop思想
請登入後發表評論
登入
全部評論
相關文章
- ASP.NET Excel匯入和匯出ASP.NETExcel
- SQL SERVER 和EXCEL的資料匯入匯出SQLServerExcel
- EasyPoi, Excel資料的匯入匯出Excel
- php讀取excel檔案資料的匯入和匯出PHPExcel
- kxcel, 方便匯入和匯出 ExcelExcel
- 匯入和匯出AWR的資料
- BCP 資料的匯入和匯出
- NDS的資料匯入和匯出
- (轉)excel和sql server的匯入匯出ExcelSQLServer
- postgresql 資料匯入和匯出SQL
- NPOI匯出和匯入Excel,Word和PDFExcel
- 如何使用 JavaScript 匯入和匯出 ExcelJavaScriptExcel
- vue excel匯入匯出VueExcel
- SQL資料庫的匯入和匯出SQL資料庫
- Oracle資料泵的匯入和匯出Oracle
- MySQL入門--匯出和匯入資料MySql
- 【mysql】資料庫匯出和匯入MySql資料庫
- Oracle資料庫匯入匯出。imp匯入命令和exp匯出命令Oracle資料庫
- Asp.net 匯出ExcelASP.NETExcel
- 前端實現Excel匯入和匯出功能前端Excel
- Angular Excel 匯入與匯出AngularExcel
- Oracle資料庫的匯入和匯出命令Oracle資料庫
- 資料庫的匯入匯出資料庫
- 資料泵的匯入匯出
- ClickHouse 資料表匯出和匯入(qbit)
- 資料泵取匯出和匯入(一)
- php匯出資料excelPHPExcel
- 如何使用JavaScript匯入和匯出Excel檔案JavaScriptExcel
- Excel 表匯入資料Excel
- Oracle 資料匯入ExcelOracleExcel
- 資料泵匯出匯入
- Oracle 資料匯入匯出Oracle
- mysql資料匯入匯出MySql
- mysql資料匯出匯入MySql
- Oracle資料匯入匯出Oracle
- ASP.NET利用NPOI元件快速匯入匯出Execl資料ASP.NET元件
- asp.net Excel匯出方法ASP.NETExcel
- 使用Dbeaver 進行資料的匯入和匯出