欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

.net core項(xiàng)目中常用的幾款類庫詳解(值得收藏)

 更新時(shí)間:2018年04月12日 09:33:06   作者:易兒善  
這篇文章主要給大家介紹了關(guān)于.net core項(xiàng)目中常用的幾款類庫的相關(guān)資料,文章通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用.net core具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。

前言

至2002微軟公司推出.NET平臺(tái)已近15年,在互聯(lián)網(wǎng)快速迭代的浪潮中,許多語言已被淘汰,同時(shí)也有更多新的語言涌現(xiàn),但 .Net 依然堅(jiān)挺的站在系統(tǒng)開發(fā)平臺(tái)的一線陣營(yíng)中,并且隨著.NET Core正式版的到來,迎來新一輪春天。

本文主要給大家介紹了關(guān)于.net core項(xiàng)目中常用的幾款類庫的相關(guān)內(nèi)容,分享出來供大家參考學(xué)習(xí),下面話不多說了,來一起看看詳細(xì)的介紹吧。

漢字轉(zhuǎn)拼音

1、 HxfPinYin

這是我自己根據(jù)網(wǎng)上大神提供的源碼,再。net core 框架下編譯出的類庫

主要提供漢字轉(zhuǎn)拼音的功能。

使用

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 = { "貨品編號(hào)",
  "貨品名稱",
  "條碼",
  "規(guī)格",
  "基本單位",
  "當(dāng)前庫存",
  "庫存下限",
  "庫存上限"
  };
  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 = { "貨品編號(hào)",
  "貨品名稱",
  "條碼",
  "規(guī)格",
  "基本單位",
  "當(dāng)前庫存",
  "庫存下限",
  "庫存上限"
  };
  using (FileStream wfs = new FileStream(tempFilePath, FileMode.OpenOrCreate)) {
  //PageSize.A4.Rotate();當(dāng)需要把PDF紙張?jiān)O(shè)置為橫向時(shí)
  Document docPDF = new Document(PageSize.A4,10, 10, 20,20);
  PdfWriter write = PdfWriter.GetInstance(docPDF, wfs);
  docPDF.Open();
  //在這里需要注意的是,itextsharp不支持中文字符,想要顯示中文字符的話需要自己設(shè)置字體 
  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();//關(guān)閉
  write.Close();
  wfs.Close();
  }

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問大家可以留言交流,謝謝大家對(duì)腳本之家的支持。

相關(guān)文章

最新評(píng)論