-
大小: 95KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-05-09
- 語言: 其他
- 標(biāo)簽: .net??導(dǎo)出Excel??
資源簡(jiǎn)介
采用第三方dll,不安裝office導(dǎo)出excel,現(xiàn)成demo,功能實(shí)用。demo是用vs2012開發(fā)。

代碼片段和文件信息
using?org.in2bits.MyXls;
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
namespace?第三方導(dǎo)出excel插件
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????DataTable?dt?=?new?DataTable();
????????????DataColumn?col1?=?new?DataColumn(“col1“);
????????????DataColumn?col2?=?new?DataColumn(“col2“);
????????????DataColumn?col3?=?new?DataColumn(“col3“);
????????????DataColumn?col4?=?new?DataColumn(“col4“);
????????????DataColumn?col5?=?new?DataColumn(“col5“);
????????????DataColumn?col6?=?new?DataColumn(“col6“);
????????????dt.Columns.Add(col1);
????????????dt.Columns.Add(col2);
????????????dt.Columns.Add(col3);
????????????dt.Columns.Add(col4);
????????????dt.Columns.Add(col5);
????????????dt.Columns.Add(col6);
????????????for?(int?i?=?0;?i?<=?200;?i++)
????????????{
????????????????DataRow?dr?=?dt.NewRow();
????????????????dr[0]?=?“楚哥“;
????????????????dr[1]?=?“中華糧網(wǎng)“;
????????????????dr[2]?=?“員工“;
????????????????dr[3]?=?“2014-08-08“;
????????????????dr[4]?=?“上班“;
????????????????dr[5]?=?“已收回“;
????????????????dt.Rows.Add(dr);
????????????}
????????????string[][]?titleName?=?new?string[2][]?{?null?null?};
????????????string[]?tempName?=?new?string[]?{?“姓名“?“單位“?“出入門類型“?“時(shí)間“?“到訪目的“?“卡片是否收回“?};
????????????titleName[0]?=?tempName;
????????????string?date?=?DateTime.Now.ToString(“yyyyMMddHHmmss“);
????????????CreateExcel(“外來人員記錄“?+?date?new?string[]?{?“考勤詳情“?}?titleName?dt);
????????}
????????public?void?CreateExcel(string?FileName?string[]?SheetName?string[][]?titleName?DataTable?DataSource)
????????{
????????????XlsDocument?xls?=?new?XlsDocument();
????????????Worksheet?sheet1?=?xls.Workbook.Worksheets.Add(SheetName[0]);
????????????XF?xf?=?xls.NewXF();
????????????xf.Font.Bold?=?true;
????????????xf.HorizontalAlignment?=?HorizontalAlignments.Centered;
????????????xf.Font.Height?=?16?*?16;
????????????ColumnInfo?columnInfo?=?new?ColumnInfo(xls?sheet1);
????????????columnInfo.ColumnIndexStart?=?0;
????????????columnInfo.ColumnIndexEnd?=?(ushort)(DataSource.Columns.Count?-?2);
????????????columnInfo.Width?=?15?*?300;
????????????sheet1.AddColumnInfo(columnInfo);
????????????Cells?cells1?=?sheet1.Cells;
????????????//合并單元格cells.Merge(1?1?1?7);
????????????
????????????if?(titleName?==?null?||?titleName[0].Length?==?0)
????????????{
????????????????for?(int?j?=?0;?j?????????????????{
????????????????????cells1.Add(1?j?+?1?DataSource.Columns[j].ColumnName?xf);
????????????????}
????????????}
????????????else
????????????{
????????????????for?(int?k?=?0;?k?????????????????{
????????????????????cells1.Add(
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????125952??2013-10-14?09:39??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\bin\Debug\org.in2bits.MyXls.dll
?????文件??????11264??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\bin\Debug\第三方導(dǎo)出excel插件.exe
?????文件??????24064??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\bin\Debug\第三方導(dǎo)出excel插件.pdb
?????文件??????22472??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\bin\Debug\第三方導(dǎo)出excel插件.vshost.exe
?????文件????????490??2013-06-18?20:28??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\bin\Debug\第三方導(dǎo)出excel插件.vshost.exe.manifest
?????文件???????4449??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\Form1.cs
?????文件???????2039??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\Form1.Designer.cs
?????文件???????5817??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\Form1.resx
?????文件???????1451??2014-08-29?15:46??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????7023??2014-08-29?14:36??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????884??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj\Debug\第三方導(dǎo)出excel插件.csproj.FileListAbsolute.txt
?????文件????????975??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj\Debug\第三方導(dǎo)出excel插件.csproj.GenerateResource.Cache
?????文件??????11264??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj\Debug\第三方導(dǎo)出excel插件.exe
?????文件????????180??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj\Debug\第三方導(dǎo)出excel插件.Form1.resources
?????文件??????24064??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj\Debug\第三方導(dǎo)出excel插件.pdb
?????文件????????180??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj\Debug\第三方導(dǎo)出excel插件.Properties.Resources.resources
?????文件????????507??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\Program.cs
?????文件???????1372??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\Properties\AssemblyInfo.cs
?????文件???????2904??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\Properties\Resources.Designer.cs
?????文件???????5612??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\Properties\Resources.resx
?????文件???????1113??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\Properties\Settings.Designer.cs
?????文件????????249??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\Properties\Settings.settings
?????文件???????3998??2014-08-29?15:04??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件.csproj
?????文件????????968??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件.sln
????..A..H.?????30720??2014-08-29?15:44??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件.v11.suo
?????目錄??????????0??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj\Debug\TempPE
?????目錄??????????0??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\bin\Debug
?????目錄??????????0??2014-08-29?15:47??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj\Debug
?????目錄??????????0??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\bin
?????目錄??????????0??2014-08-29?14:34??第三方導(dǎo)出excel插件\第三方導(dǎo)出excel插件\obj
............此處省略6個(gè)文件信息
評(píng)論
共有 條評(píng)論