您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關.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(); }
關于“.net core項目中常用的類庫有哪些”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。