前言
至2002微软公司推出.NET平台已近15年,在互联网快速迭代的浪潮中,许多语言已被淘汰,同时也有更多新的语言涌现,但 .Net 依然坚挺的站在系统开发平台的一线阵营中,并且随着.NET Core正式版的到来,迎来新一轮春天。
本文主要给大家介绍了关于.net core项目中常用的几款类库的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。
汉字转拼音
1、 HxfPinYin
这是我自己根据网上大神提供的源码,再。net core 框架下编译出的类库
主要提供汉字转拼音的功能。
使用
public static class Pinyin { public static string ConvertEncoding(string text, Encoding srcEncoding, Encoding dstEncoding); public static string GetChineseText(string pinyin); public static string GetChineseText(string pinyin, Encoding encoding); public static string GetInitials(string text); public static string GetInitials(string text, Encoding encoding); public static string GetPinyin(string text); public static string GetPinyin(string text, Encoding encoding); public static string GetPinyin(char ch); public static string GetPinyin(char ch, Encoding encoding); }
excel操作
1、EPPlus.Core
生成excel表格
string sFileName = $"{Guid.NewGuid()}.xlsx"; FileInfo file = new FileInfo(sFileName); string[] title = { "货品编号", "货品名称", "条码", "规格", "基本单位", "当前库存", "库存下限", "库存上限" }; using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("库存信息"); int index = 1; foreach (string t in title) { worksheet.Cells[1, index++].Value = t; } index = 2; foreach (var d in list) { worksheet.Cells[index,1].Value = d.ProductCode; worksheet.Cells[index, 2].Value = d.ProductName; worksheet.Cells[index, 3].Value = d.BarCode; worksheet.Cells[index, 4].Value = d.SpecValues; worksheet.Cells[index, 5].Value = d.BaseUnit; worksheet.Cells[index, 6].Value = d.Quantity; worksheet.Cells[index, 7].Value = d.DownLimitQuantity; worksheet.Cells[index, 8].Value = d.UpLimitQuantity; index++; } package.Save(); }
pdf操作
1、iTextSharp.LGPLv2.Core
生成pdf
string tempFilePath = $"{Guid.NewGuid()}.pdf"; string[] title = { "货品编号", "货品名称", "条码", "规格", "基本单位", "当前库存", "库存下限", "库存上限" }; using (FileStream wfs = new FileStream(tempFilePath, FileMode.OpenOrCreate)) { //PageSize.A4.Rotate();当需要把PDF纸张设置为横向时 Document docPDF = new Document(PageSize.A4,10, 10, 20,20); PdfWriter write = PdfWriter.GetInstance(docPDF, wfs); docPDF.Open(); //在这里需要注意的是,itextsharp不支持中文字符,想要显示中文字符的话需要自己设置字体 BaseFont bsFont = BaseFont.CreateFont(@"C:\Windows\Fonts\simsun.ttc,0", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font font = new Font(bsFont); float[] clos = new float[] { 40,40,40,20,20,30,30,30};// 宽度 PdfPTable tablerow1 = new PdfPTable(clos); foreach (string t in title) { PdfPCell cell = new PdfPCell(new Paragraph(t, font)); cell.MinimumHeight = 4f; tablerow1.AddCell(cell); } foreach (var d in list) { tablerow1.AddCell(new PdfPCell(new Paragraph(d.ProductCode, font))); tablerow1.AddCell(new PdfPCell(new Paragraph(d.ProductName, font))); tablerow1.AddCell(new PdfPCell(new Paragraph(d.BarCode, font))); tablerow1.AddCell(new PdfPCell(new Paragraph(d.SpecValues, font))); tablerow1.AddCell(new PdfPCell(new Paragraph(d.BaseUnit, font))); tablerow1.AddCell(new PdfPCell(new Paragraph(d.Quantity.ToString(), font))); tablerow1.AddCell(new PdfPCell(new Paragraph(d.DownLimitQuantity.ToString(), font))); tablerow1.AddCell(new PdfPCell(new Paragraph(d.UpLimitQuantity.ToString(), font))); } docPDF.Add(tablerow1);//将表格添加到pdf文档中 docPDF.Close();//关闭 write.Close(); wfs.Close(); }
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对的支持。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年09月21日
2024年09月21日
- 归龙潮中浦城区福鼠位置在哪 中浦城区福鼠收集位置大全
- MatteoPasqualini-JohannSebastianBachItalienischesKonzertFranzsischeOuvertureVierDue
- 【雨果唱片】陈百强《梦里人LPCD45》2012[WAV+CUE]
- 王菲.1994-《迷路》美卡引进版[WAV+CUE]
- 老外遇到八戒裸体Bug 网友:我需要用它对付蜘蛛精
- 《黑神话》超强越化补丁:游戏里有文字的地都改了
- 玩家吐槽《黑神话:悟空》唐僧相貌:一脸衰样 没半点气质
- 群星.1994-烧得厉害VOL.2我不是一个人拙滚石】【WAV+CUE】
- 群星.1994-烧得厉害VOL.3风笑痴【滚石】【WAV+CUE】
- 群星.1995-烧得厉害VOL.4两个世界【滚石】【WAV+CUE】
- 归龙潮中浦城区宝箱位置收集大全 中浦区宝箱解密攻略
- 黑神话悟空上品幽灯鬼精魄获取方法一览|上品幽灯鬼精魄收集攻略
- 《电锯糖心:RePOP》发售首日表现亮眼,玩家峰值超越《星鸣特攻》
- NewViennaOctet,ViennaWindSoloists-TheDeccaRecordings(2024)18CD[FLAC]-8
- 金梅子-《靓声妹3又见炊烟》[WAV+CUE]