资源简介
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NPOI.HSSF.UserModel;
using System.IO;
using NPOI.HSSF.Record.Formula.Functions;
namespace MysqlWinform
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void skinButton2_Click(object sender, EventArgs e)
{
using (FileStream fs = new FileStream(@"c:\users\administrator\desktop\excel\goods_classone.xls", FileMode.Open, FileAccess.Read))
{
HSSFWorkbook work = new HSSFWorkbook(fs);
HSSFSheet sheet = work.GetSheetAt(0);
zlyfmallEntities2 db = new zlyfmallEntities2();
HSSFRow row = null;
goodsclasstwo gco = null;
for (int i = 1; i <= 95; i )
{
row = sheet.GetRow(i);
gco = new goodsclasstwo();
gco.tname = row.GetCell(0).ToString();
gco.father = int.Parse(row.GetCell(1).ToString());
gco.status = 1;
db.goodsclasstwo.Add(gco);
}
db.SaveChanges();
MessageBox.Show("插入成功");
}
}
private void skinButton1_Click_1(object sender, EventArgs e)
{
}
private void skinButton1_Click_2(object sender, EventArgs e)
{
int m = 0;
using (FileStream fsread = new FileStream(@"C:\Users\Administrator\Desktop\Excel\zong.xls", FileMode.Open, FileAccess.Read))
{
using (FileStream fswrite = new FileStream(@"C:\Users\Administrator\Desktop\Excel\goodsClassThree.xls", FileMode.OpenOrCreate, FileAccess.Write))
{
HSSFWorkbook workread = new HSSFWorkbook(fsread);
HSSFSheet sheetread = workread.GetSheetAt(0);
HSSFWorkbook workwrite = new HSSFWorkbook();
HSSFSheet sheetwrite = workwrite.CreateSheet("goodsClassOne");
for (int i = 0; i <= sheetread.LastRowNum; i )
{
HSSFRow row = sheetread.GetRow(i);
for (int j = 0; j <= row.LastCellNum; j )
{
HSSFCell cell = row.GetCell(j);
if (cell != null)
{
if (cell.ToString() != "")
{
HSSFRow newrow = sheetwrite.CreateRow(m);
newrow.CreateCell(0, HSSFCellType.STRING).SetCellValue(cell.ToString());
newrow.CreateCell(1, HSSFCellType.NUMERIC).SetCellValue(i 1);
m ;
}
}
}
}
workwrite.Write(fswrite);
}
MessageBox.Show("写入成功共" m);
}
}
private void skinButton3_Click(object sender, EventArgs e)
{
using (FileStream fs = new FileStream(@"C:\Users\Administrator\Desktop\Excel\goodsClassThree.xls", FileMode.Open, FileAccess.Read))
{
HSSFWorkbook wk = new HSSFWorkbook(fs);
HSSFSheet sheet = wk.GetSheetAt(0);
HSSFRow row = null;
goodsclassthree gc = null;
zlyfmallEntities2 db = new zlyfmallEntities2();
for (int i = 0; i <= sheet.LastRowNum; i )
{
row = sheet.GetRow(i);
gc = new goodsclassthree();
gc.tname = row.GetCell(0).ToString();
gc.father = int.Parse(row.GetCell(1).ToString());
gc.status = 1;
db.goodsclassthree.Add(gc);
}
db.SaveChanges();
MessageBox.Show("插入成功");
}
}
private void button1_Click(object sender, EventArgs e)
{
using (FileStream fs = new FileStream(@"C:\Users\Administrator\Desktop\Excel\goodstype1.xls", FileMode.Open, FileAccess.Read))
{
HSSFWorkbook work = new HSSFWorkbook(fs);
HSSFSheet sheet = work.GetSheetAt(0);
HSSFRow row = null;
goodsclassone gt = null;
zlyfmallEntities2 db = new zlyfmallEntities2();
for (int i = 1; i <= sheet.LastRowNum; i )
{
row = sheet.GetRow(i);
gt = new goodsclassone();
gt.tname = row.GetCell(0).ToString().Replace(" ", ",");
gt.status = int.Parse(row.GetCell(1).ToString());
db.goodsclassone.Add(gt);
}
db.SaveChanges();
}
}
}
}
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NPOI.HSSF.UserModel;
using System.IO;
using NPOI.HSSF.Record.Formula.Functions;
namespace MysqlWinform
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void skinButton1_Click(object sender EventArgs e)
{
//using (FileStream fs = new FileStream(@“C:\Users\Administrator\Desktop\Excel\goodstype1.xls“ FileMode.Open FileAccess.Read))
//{
// HSSFWorkbook work = new HSSFWorkbook(fs);
// HSSFSheet sh 属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 52224 2017-07-29 18:15 MysqlWinform\.vs\MysqlWinform\v14\.suo
文件 1998 2017-07-29 14:11 MysqlWinform\MysqlWinform\App.config
文件 2738176 2016-05-18 18:13 MysqlWinform\MysqlWinform\bin\Debug\CSkin.dll
文件 263246 2016-05-18 18:11 MysqlWinform\MysqlWinform\bin\Debug\CSkin.xm
文件 1116760 2015-11-03 17:43 MysqlWinform\MysqlWinform\bin\Debug\Entityfr
文件 1138045 2015-11-03 17:43 MysqlWinform\MysqlWinform\bin\Debug\Entityfr
文件 196608 2010-05-25 12:55 MysqlWinform\MysqlWinform\bin\Debug\ICSharpCode.SharpZipLib.dll
文件 18944 2017-07-29 18:12 MysqlWinform\MysqlWinform\bin\Debug\MysqlWinform.exe
文件 1998 2017-07-29 14:11 MysqlWinform\MysqlWinform\bin\Debug\MysqlWinform.exe.config
文件 36352 2017-07-29 18:12 MysqlWinform\MysqlWinform\bin\Debug\MysqlWinform.pdb
文件 22696 2017-07-31 09:36 MysqlWinform\MysqlWinform\bin\Debug\MysqlWinform.vshost.exe
文件 1998 2017-07-29 14:11 MysqlWinform\MysqlWinform\bin\Debug\MysqlWinform.vshost.exe.config
文件 490 2014-09-19 01:53 MysqlWinform\MysqlWinform\bin\Debug\MysqlWinform.vshost.exe.manifest
文件 92160 2009-12-20 12:57 MysqlWinform\MysqlWinform\bin\Debug\NPOI.DDF.dll
文件 9728 2009-12-20 13:16 MysqlWinform\MysqlWinform\bin\Debug\NPOI.dll
文件 53248 2009-12-20 13:16 MysqlWinform\MysqlWinform\bin\Debug\NPOI.HPSF.dll
文件 964608 2009-12-20 13:33 MysqlWinform\MysqlWinform\bin\Debug\NPOI.HSSF.dll
文件 49664 2009-12-20 13:16 MysqlWinform\MysqlWinform\bin\Debug\NPOI.POIFS.dll
文件 39424 2009-12-20 12:57 MysqlWinform\MysqlWinform\bin\Debug\NPOI.Util.dll
文件 71256 2015-11-03 17:43 MysqlWinform\MysqlWinform\bin\Debug\zh-Hans\Entityfr
文件 6358 2017-07-29 18:12 MysqlWinform\MysqlWinform\Form1.cs
文件 2033 2017-07-29 18:12 MysqlWinform\MysqlWinform\Form1.Designer.cs
文件 5817 2017-07-29 18:12 MysqlWinform\MysqlWinform\Form1.resx
文件 683 2017-07-29 14:12 MysqlWinform\MysqlWinform\goodsclassone.cs
文件 736 2017-07-29 14:12 MysqlWinform\MysqlWinform\goodsclassthree.cs
文件 734 2017-07-29 14:12 MysqlWinform\MysqlWinform\goodsclasstwo.cs
文件 1092 2017-07-29 14:11 MysqlWinform\MysqlWinform\Model1.Context.cs
文件 26161 2017-07-29 14:11 MysqlWinform\MysqlWinform\Model1.Context.tt
文件 417 2017-07-29 14:12 MysqlWinform\MysqlWinform\Model1.cs
文件 750 2017-07-29 14:12 MysqlWinform\MysqlWinform\Model1.Designer.cs
............此处省略93个文件信息
相关资源
- C# KTV 点歌系统,C#项目源码带数据库
- asp.net完整项目带数据库
- 北大青鸟accp7.0 使用C#开发数据库应用
- ASP.NET C#在线音乐网站带数据库2017更新
- 通用ASP.NET Core NPOI导出复杂Word、Exce
- 旅游管理系统C#版数据库sql server
- C# 一元幸运购项目源码+数据库 大学项
- ASP.NET MVC Json表格数据 为Excel
- C# EF6连接、操作Mysql教程和增删改查
- C#超市管理系统
- ASP.NET旅游网源码商业-全套代码含数据
- C# 进销存管理系统,自己根据需求写
- C# excel处理源码
- asp.net(c#) 与 highcharts 数据库交互
- c#简单的选课系统用 数据库的造作完
- 数据库课设:KTV点歌系统C# WinForm+Sq
- C#学生选课系统包括源程序及数据库文
- 精通C#与.NET4.0数据库开发.pdf
- C#数据库课程设计说明书报告
- C#使用Microsoft.Office.Interop.Excel操作EX
- 基于C#WinForm数据库在线考试系统项目
-
C#将数据库数据生成xm
l文件 - C#游戏后台数据库管理系统
- ASP.NET+SQL Server 数据库开发与 光盘
- ASP.NET购物网站全部资源.zip
- C# 五子棋 大学项目源码+数据库
- C# Winform数据库应用设计(附开发案例
- 2017年全国五级行政区划_省市县乡村
- C#+SQL2005图书管理系统
- C#语言实现操作SQLite数据库完成基本的
川公网安备 51152502000135号
评论
共有 条评论