91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 1.15MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2023-09-20
  • 語言: C#
  • 標(biāo)簽: C#??EXCEL導(dǎo)??mysql??

資源簡介

公司項(xiàng)目要求,做了一個(gè)C#程序,內(nèi)容是excel導(dǎo)入導(dǎo)出+mysql數(shù)據(jù)庫

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Windows.Forms;
using?System.Text;
using?System.Diagnostics;
using?System.IO;
using?Microsoft.Office.Interop.Excel;


namespace?UIForm4
{
????public?class?ExportDGVToExcel
????{
????????private?const?int?OLDOFFICEVESION?=?-4143;
????????private?const?int?NEWOFFICEVESION?=?56;
????????///?
????????///?DataGridView導(dǎo)出Excel
????????///?

????????///?Excel文件中的標(biāo)題
????????///?DataGridView?控件
????????///?0:成功;1:DataGridView中無記錄;2:Excel無法啟動;100:Cancel;9999:異常錯(cuò)誤
????????public?int?ExportExcel(string?strCaption?DataGridView?myDGV?SaveFileDialog?saveFileDialog)
????????{
????????????//saveFileDialog.Filter?=?“Execl?files?(*.xls)|*.xls“;
????????????saveFileDialog.Filter?=?“Excel?files?office2003(*.xls)|*.xls|Excel?office2016(*.xlsx)|*.xlsx|All?files?(*.*)|*.*“;
????????????saveFileDialog.FilterIndex?=?0;
????????????saveFileDialog.RestoreDirectory?=?true;
????????????//saveFileDialog.CreatePrompt?=?true;
????????????saveFileDialog.title?=?“Export?Excel?File“;
????????????if?(saveFileDialog.ShowDialog()?==?DialogResult.OK)
????????????{
????????????????if?(saveFileDialog.FileName?==?““)
????????????????{
????????????????????MessageBox.Show(“請輸入保存文件名!“);
????????????????????saveFileDialog.ShowDialog();
????????????????}
????????????????//?列索引,行索引,總列數(shù),總行數(shù)
????????????????int?ColIndex?=?0?RowIndex?=?0;
????????????????int?ColCount?=?myDGV.ColumnCount?RowCount?=?myDGV.RowCount;
?
????????????????if?(myDGV.RowCount?==?0)
????????????????{
????????????????????return?1;
????????????????}
?
????????????????//?創(chuàng)建Excel對象
????????????????Microsoft.Office.Interop.Excel.Application?xlApp?=?new?ApplicationClass();
????????????????if?(xlApp?==?null)
????????????????{
????????????????????return?2;
????????????????}
????????????????try
????????????????{
????????????????????//?創(chuàng)建Excel工作薄
????????????????????Workbook?xlBook?=?xlApp.Workbooks.Add(true);
????????????????????Worksheet?xlSheet?=?(Worksheet)xlBook.Worksheets[1];
????????????????????////Get?excel?Version
????????????????????string?Version?=?xlApp.Version;
????????????????????//保存excel文件的格式
????????????????????int?FormatNum;
????????????????????if?(Convert.ToDouble(Version)?????????????????????{
????????????????????????//使用Excel?97-2003
????????????????????????FormatNum?=?OLDOFFICEVESION;
????????????????????}
????????????????????else
????????????????????{
????????????????????????//使用?excel?2007或更新
????????????????????????FormatNum?=?NEWOFFICEVESION;
????????????????????}
????????????????????//?設(shè)置標(biāo)題
????????????????????//標(biāo)題所占的單元格數(shù)與DataGridView中的列數(shù)相同
????????????????????Range?range?=?xlSheet.get_Range(xlApp.Cells[1?1]?xlApp.Cells[1?ColCount]);?
????????????????????range.MergeCells?=?true;
????????????????????xlApp.ActiveCell.FormulaR1C1?=?strCaption;
????????????????????xlApp.ActiveCell.Font.Size?=?20;
????????????????????xlApp.ActiveCell.Font.B

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-03-20?17:32??UIForm4-備份\
?????目錄???????????0??2019-03-20?17:32??UIForm4-備份\UIForm4\
?????文件?????????187??2019-03-20?08:00??UIForm4-備份\UIForm4\App.config
?????文件????????5612??2019-03-20?11:37??UIForm4-備份\UIForm4\ExportDGVToExcel.cs
?????文件????????6665??2019-03-20?11:21??UIForm4-備份\UIForm4\ExportToExcel.cs
?????文件????????6599??2019-03-20?11:34??UIForm4-備份\UIForm4\Form1.Designer.cs
?????文件???????11904??2019-03-20?15:56??UIForm4-備份\UIForm4\Form1.cs
?????文件????????5817??2019-03-20?11:34??UIForm4-備份\UIForm4\Form1.resx
?????文件????????1250??2019-03-20?10:16??UIForm4-備份\UIForm4\MySQLConn.cs
?????文件?????????519??2019-03-20?08:00??UIForm4-備份\UIForm4\Program.cs
?????目錄???????????0??2019-03-20?17:32??UIForm4-備份\UIForm4\Properties\
?????文件????????1352??2019-03-20?08:00??UIForm4-備份\UIForm4\Properties\AssemblyInfo.cs
?????文件????????2866??2019-03-20?08:00??UIForm4-備份\UIForm4\Properties\Resources.Designer.cs
?????文件????????5612??2019-03-20?08:00??UIForm4-備份\UIForm4\Properties\Resources.resx
?????文件????????1094??2019-03-20?08:00??UIForm4-備份\UIForm4\Properties\Settings.Designer.cs
?????文件?????????249??2019-03-20?08:00??UIForm4-備份\UIForm4\Properties\Settings.settings
?????文件????????5346??2019-03-20?11:32??UIForm4-備份\UIForm4\UIForm4.csproj
?????目錄???????????0??2019-03-20?17:32??UIForm4-備份\UIForm4\bin\
?????目錄???????????0??2019-03-20?17:32??UIForm4-備份\UIForm4\bin\Debug\
?????文件?????1550200??2011-12-12?06:54??UIForm4-備份\UIForm4\bin\Debug\Microsoft.Office.Interop.Excel.dll
?????文件?????3378414??2011-12-12?11:53??UIForm4-備份\UIForm4\bin\Debug\Microsoft.Office.Interop.Excel.xml
?????文件???????63336??2011-12-12?06:54??UIForm4-備份\UIForm4\bin\Debug\Microsoft.Vbe.Interop.dll
?????文件??????294912??2013-05-22?17:21??UIForm4-備份\UIForm4\bin\Debug\MySql.Data.dll
?????文件???????17920??2019-03-20?11:37??UIForm4-備份\UIForm4\bin\Debug\UIForm4.exe
?????文件?????????187??2019-03-20?08:00??UIForm4-備份\UIForm4\bin\Debug\UIForm4.exe.config
?????文件???????36352??2019-03-20?11:37??UIForm4-備份\UIForm4\bin\Debug\UIForm4.pdb
?????文件???????22984??2019-03-20?11:40??UIForm4-備份\UIForm4\bin\Debug\UIForm4.vshost.exe
?????文件?????????187??2019-03-20?08:00??UIForm4-備份\UIForm4\bin\Debug\UIForm4.vshost.exe.config
?????文件?????????490??2015-06-04?12:48??UIForm4-備份\UIForm4\bin\Debug\UIForm4.vshost.exe.manifest
?????文件??????448360??2011-12-12?06:54??UIForm4-備份\UIForm4\bin\Debug\office.dll
?????文件?????1101614??2011-12-12?11:53??UIForm4-備份\UIForm4\bin\Debug\office.xml
............此處省略17個(gè)文件信息

評論

共有 條評論