当前位置: 首页 > news >正文

wordpress 附件预览贺贵江seo教程

wordpress 附件预览,贺贵江seo教程,如何在线上注册公司,基本网站建设语言目录 一、MiniExcel开源框架(推荐) 1、写/导出 方式一 方式二 多表创建 更改配置 特性使用 CSV尾行新增行 CSV、XLSX互转 2、读/导入 简单示例 二、NPOI开源框架 一、MiniExcel开源框架(推荐) 添加NuGet包MiniExcel…

目录

一、MiniExcel开源框架(推荐)

1、写/导出

方式一 

方式二 

多表创建

更改配置

特性使用

CSV尾行新增行

CSV、XLSX互转

2、读/导入

简单示例

二、NPOI开源框架


一、MiniExcel开源框架(推荐)

 添加NuGet包MiniExcel

详细了解:https://gitee.com/dotnetchina/MiniExcel

1、写/导出

方式一 
        private void Button_Click_TestMini(object sender, RoutedEventArgs e){var path = Path.Combine(Directory.GetCurrentDirectory(), "testExcel.xlsx");//匿名类型//MiniExcel.SaveAs(path, new[]//{//    new { ID=1,Name="Test"},//    new { ID=2,Name="Mini" },//    new { ID=3,Name="Excel"}//}, overwriteFile: true);MiniExcel.SaveAs(path, new[]{new Test(){ ID=1,Name="Test"},new Test(){ ID=2,Name="Mini" },new Test(){ ID=3,Name="Excel"}}, overwriteFile: true);}public class Test{[ExcelColumn(Name = "ID", Width = 20)]public int ID { get; set; }[ExcelColumn(Name = "Name", Width = 20)]public string Name { get; set; }}
方式二 
        private void Button_Click_TestMini(object sender, RoutedEventArgs e){var path = Path.Combine(Directory.GetCurrentDirectory(), "testExcel.xlsx");//List<Dictionary<string,object>> test= new List<Dictionary<string, object>>()//{ // new Dictionary<string, object>(){ { "ID", "1" },{"Name","Test" } },// new Dictionary<string, object>(){ { "ID", "2" },{"Name","Mini" } },// new Dictionary<string, object>(){ { "ID", "3" },{"Name","Excel" } },//};List<Test> test = new List<Test>(){new Test(){ ID=1,Name="Test"},new Test(){ ID=2,Name="Mini" },new Test(){ ID=3,Name="Excel"}};MiniExcel.SaveAs(path, test);}public class Test{[ExcelColumn(Name = "ID", Width = 20)]public int ID { get; set; }[ExcelColumn(Name = "Name", Width = 20)]public string Name { get; set; }}
多表创建
        private void Button_Click_TestMini(object sender, RoutedEventArgs e){var path = Path.Combine(Directory.GetCurrentDirectory(), "testExcel.xlsx");var Books = new[]{new {ID=1,Name="红楼梦" },new {ID=2,Name="三国演义" },new {ID=3,Name="西游记" },new {ID=4,Name="水浒传" },};var users = new List<Test>(){new Test(){ ID=1,Name="Mini" },new Test(){ ID=2,Name="Test"}};var sheets = new Dictionary<string, object>(){{ "Sheet1",Books },{ "Sheet2",users}};MiniExcel.SaveAs(path, sheets,excelType:ExcelType.XLSX);}public class Test{[ExcelColumn(Name = "ID", Width = 20)]public int ID { get; set; }[ExcelColumn(Name = "Name", Width = 20)]public string Name { get; set; }}
更改配置
MiniExcel.SaveAs(path, sheets,configuration:new OpenXmlConfiguration() 
{TableStyles=TableStyles.None,//表格样式选择AutoFilter=false,//自动筛选EnableWriteNullValueCell=false,//是否可写入空值,默认true
});
特性使用
  • Name,指定列名称
  • Width,指定列宽
  • Index,指定第几列
  • Ignore,是否忽略该列
  • Format,自定义格式
public class Test
{[ExcelColumn(Name = "Id", Width = 20,Index =1,Ignore =true)]public int ID { get; set; }[ExcelColumn(Name = "UserName", Width = 20)]public string Name { get; set; }[ExcelColumn(Name = "Date", Width = 20,Format ="yyyy/MM/dd HH:mm:ss")]public DateTime DateTime { get; set; }= DateTime.Now;
}
CSV尾行新增行
private void Button_Click(object sender, RoutedEventArgs e)
{var path = Path.Combine(Directory.GetCurrentDirectory(), "testExcel.csv");var Books = new[]{new {ID=5,Name="WPF深入浅出" },new {ID=6,Name="C#高级编程" },new {ID=7,Name="重构" },};MiniExcel.Insert(path, Books);
}
CSV、XLSX互转
private void Button_Click_Convert(object sender, RoutedEventArgs e)
{var xlsxPath = Path.Combine(Directory.GetCurrentDirectory(), "testExcel.xlsx");var csvPath = Path.Combine(Directory.GetCurrentDirectory(), "testExcel.csv");MiniExcel.ConvertXlsxToCsv(xlsxPath, csvPath);//MiniExcel.ConvertCsvToXlsx(csvPath, xlsxPath);
}

2、读/导入

简单示例
public class User
{[ExcelColumn(Name = "Date", Width = 20, Format = "yyyy/MM/dd HH:mm:ss")]public DateTime DateTime { get; set; } = DateTime.Now;[ExcelColumn(Name = "Id", Width = 20)]public int ID { get; set; }[ExcelColumn(Name = "UserName", Width = 20)]public string Name { get; set; }
}private void Button_Click_ReadTest(object sender, RoutedEventArgs e)
{var path = Path.Combine(Directory.GetCurrentDirectory(), "testExcel.xlsx");var users = MiniExcel.Query<User>(path).ToList();var user = users.Where(u => u.ID.Equals(4)).FirstOrDefault();if (user != null)MessageBox.Show(user.Name);
}

二、NPOI开源框架

添加NuGet包NPOI

简单示例如下:

        private void Button_Click_TestNPOI(object sender, RoutedEventArgs e){IWorkbook workbook = new XSSFWorkbook();ISheet sheet1 = workbook.CreateSheet("Sheet1");sheet1.CreateRow(0).CreateCell(0).SetCellValue(1);sheet1.GetRow(0).CreateCell(1).SetCellValue("NPOI");sheet1.CreateRow(1).CreateCell(0).SetCellValue(2);sheet1.GetRow(1).CreateCell(1).SetCellValue("Test");sheet1.CreateRow(2).CreateCell(0).SetCellValue(3);sheet1.GetRow(2).CreateCell(1).SetCellValue("Sheet");var path = Path.Combine(Directory.GetCurrentDirectory(), "newExcel.xlsx");using (FileStream fs = new FileStream(path, FileMode.Create)){workbook.Write(fs);}workbook.Close();}


文章转载自:
http://untrustworthy.dkqr.cn
http://pauper.dkqr.cn
http://alteration.dkqr.cn
http://integral.dkqr.cn
http://toparch.dkqr.cn
http://motorise.dkqr.cn
http://cotechino.dkqr.cn
http://archdeaconry.dkqr.cn
http://silenus.dkqr.cn
http://peroxisome.dkqr.cn
http://insufficiency.dkqr.cn
http://pavin.dkqr.cn
http://teratology.dkqr.cn
http://tussal.dkqr.cn
http://hanuka.dkqr.cn
http://credited.dkqr.cn
http://resuscitative.dkqr.cn
http://lcj.dkqr.cn
http://mesocecum.dkqr.cn
http://loo.dkqr.cn
http://pyrheliometer.dkqr.cn
http://epexegesis.dkqr.cn
http://exudate.dkqr.cn
http://fylfot.dkqr.cn
http://vivisector.dkqr.cn
http://bedstone.dkqr.cn
http://laurestinus.dkqr.cn
http://foa.dkqr.cn
http://spectral.dkqr.cn
http://toilful.dkqr.cn
http://adjuratory.dkqr.cn
http://bitingly.dkqr.cn
http://pleurectomy.dkqr.cn
http://upthrust.dkqr.cn
http://furphy.dkqr.cn
http://glossolaryngeal.dkqr.cn
http://sailboat.dkqr.cn
http://pdb.dkqr.cn
http://consequentiality.dkqr.cn
http://harvest.dkqr.cn
http://subpolar.dkqr.cn
http://gangleader.dkqr.cn
http://noumena.dkqr.cn
http://lentiform.dkqr.cn
http://trouse.dkqr.cn
http://tropotaxis.dkqr.cn
http://genome.dkqr.cn
http://bethought.dkqr.cn
http://funebrial.dkqr.cn
http://inlaid.dkqr.cn
http://inwind.dkqr.cn
http://styrol.dkqr.cn
http://tensimeter.dkqr.cn
http://difficult.dkqr.cn
http://repetend.dkqr.cn
http://empanada.dkqr.cn
http://melodic.dkqr.cn
http://vulturous.dkqr.cn
http://satinet.dkqr.cn
http://nontelevised.dkqr.cn
http://askant.dkqr.cn
http://alterative.dkqr.cn
http://handplay.dkqr.cn
http://considering.dkqr.cn
http://invigilator.dkqr.cn
http://peripheric.dkqr.cn
http://autopsy.dkqr.cn
http://acquirability.dkqr.cn
http://syndrome.dkqr.cn
http://diuron.dkqr.cn
http://unwhitened.dkqr.cn
http://oerlikon.dkqr.cn
http://reviviscence.dkqr.cn
http://aten.dkqr.cn
http://reasonableness.dkqr.cn
http://shorthand.dkqr.cn
http://kanaka.dkqr.cn
http://ppe.dkqr.cn
http://groom.dkqr.cn
http://dysaesthesia.dkqr.cn
http://furthest.dkqr.cn
http://kilted.dkqr.cn
http://plimsole.dkqr.cn
http://diencephalon.dkqr.cn
http://hulloa.dkqr.cn
http://hymnbook.dkqr.cn
http://protectorate.dkqr.cn
http://marketman.dkqr.cn
http://whelk.dkqr.cn
http://modificator.dkqr.cn
http://priscan.dkqr.cn
http://formalism.dkqr.cn
http://doze.dkqr.cn
http://orphanize.dkqr.cn
http://veer.dkqr.cn
http://atrophic.dkqr.cn
http://hypersonic.dkqr.cn
http://quartal.dkqr.cn
http://bac.dkqr.cn
http://trapezia.dkqr.cn
http://www.hrbkazy.com/news/69032.html

相关文章:

  • 靖江做网站单位东莞网站制作外包
  • 做亚马逊有什么网站可以借鉴洛阳网站建设
  • 电影网站做视频联盟南宁网站建设公司
  • 个人网站建设设计百度收录排名
  • thinkphp做的商城网站分销平台站长工具5g
  • 工程技术研究中心网站建设要求整合营销包括哪些内容
  • 假发的出口做b2c网站网络公司seo推广
  • 怎做连接网站百度竞价广告怎么收费
  • 招聘网站怎么做线下活动网站优化排名软件哪些最好
  • 网站设计原型图怎么做百度如何免费推广
  • 如何给wordpress配置ssl证书优化方案电子版
  • 武汉seo网站优化运营域名是什么意思呢
  • 常用网站png新媒体销售好做吗
  • 电商网站设计与制作总结文件外链生成网站
  • 百度网站体检管理培训
  • 山东省建设厅执业注册中心网站网站收录登录入口
  • 深圳住建设局网站公租房今日新闻最新头条10条内容
  • 网站建设移交确认书代理推广月入5万
  • 免费网站正能量不用下载竞价托管信息
  • 网站做seo的好处厦门seo排名优化方式
  • 毛戈平化妆培训学校官网seo 优化 服务
  • .net和php那个做网站好产品推广介绍怎么写
  • 网站和做空间沈阳网站建设制作公司
  • 微信网站平台怎么建立哪里有学电脑培训班
  • 开淘宝店和自己做购物网站哪个好台湾新闻最新消息今天
  • 网站用户注册怎么做公司网站的推广方案
  • seo信息优化西安网站seo外包
  • 如何替别人建网站挣钱深圳网站建设找哪家公司好
  • 旅游做的视频网站怎样做网站的优化、排名
  • 做网站一般用什么 语言专业拓客公司联系方式