C# 繪製Word形狀——基本形狀、組合形狀

来源:https://www.cnblogs.com/Yesi/archive/2018/06/06/9143978.html
-Advertisement-
Play Games

一、序言 在Office Word中,支持在Word文檔中插入類型非常豐富的形狀,包括線條、矩形、基本形狀(諸如圓形、多邊形、星形、括弧、笑臉等等圖形)、箭頭形狀、公式形狀、流程圖、旗幟圖形、標註圖形等等,我們在編程過程中,想要在Word中繪製不同類型的圖形,可以通過類庫來操作。控制項Spire.Do ...


一、序言

在Office Word中,支持在Word文檔中插入類型非常豐富的形狀,包括線條、矩形、基本形狀(諸如圓形、多邊形、星形、括弧、笑臉等等圖形)、箭頭形狀、公式形狀、流程圖、旗幟圖形、標註圖形等等,我們在編程過程中,想要在Word中繪製不同類型的圖形,可以通過類庫來操作。控制項Spire.Doc for .NET 6.0及以上版本開始支持Office Word中的所有圖形,可以通過代碼操作某個單一的形狀,也可以通過將單一形狀進行組合來獲得想要的圖形或形狀效果,當然,也支持自己自定義圖形,通過編程繪製也是可以的。下麵將介紹向Word繪製形狀和組合形狀的方法,方法中的代碼供參考。

PS:

  • Spire.Doc for .NET獲取地址
  • 安裝後,dll文件可在安裝路徑下的Bin文件夾中獲取

Dll引用

二、代碼示例

(一)繪製單一形狀

步驟1:添加如下using指定

using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
using System.Drawing;

 

步驟2:創建示例,添加section、paragraph

//創建一個Document實例
Document doc = new Document();
//添加一個section paragraph
 Section sec = doc.AddSection();
 Paragraph para1 = sec.AddParagraph();

 

步驟3:在文檔指定位置插入形狀,並設置形狀類型、大小、填充顏色、線條樣式等

(這裡簡單列舉幾個形狀的添加方法,方法比較簡單,不做贅述,效果圖中列舉了部分形狀樣式,需要其他樣式的形狀可自行設置添加)

           //插入一個矩形
            ShapeObject shape1 = para1.AppendShape(50, 50, ShapeType.Rectangle);
            shape1.FillColor = Color.Blue;
            shape1.StrokeColor = Color.LightSkyBlue;
            shape1.HorizontalPosition = 20;
            shape1.VerticalPosition = 20;

            //插入一個圓形
            ShapeObject shape2 = para1.AppendShape(50, 50, ShapeType.Ellipse);
            shape2.FillColor = Color.Purple;
            shape2.StrokeColor = Color.LightPink;
            shape2.LineStyle = ShapeLineStyle.Single;
            shape2.StrokeWeight = 1;
            shape2.HorizontalPosition = 80;
            shape2.VerticalPosition = 20;

            //插入一個公式符號 +
            ShapeObject shape3 = para1.AppendShape(50, 50, ShapeType.Plus);
            shape3.FillColor = Color.DarkCyan;
            shape3.StrokeColor = Color.LightGreen;
            shape3.LineStyle = ShapeLineStyle.Single;
            shape3.StrokeWeight = 1;
            shape3.HorizontalPosition = 140;
            shape3.VerticalPosition = 20;

            //插入一顆星形
            ShapeObject shape4 = para1.AppendShape(50, 50, ShapeType.Star);
            shape4.FillColor = Color.Red;
            shape4.StrokeColor = Color.Gold;
            shape4.LineStyle = ShapeLineStyle.Single;
            shape4.HorizontalPosition = 200;
            shape4.VerticalPosition = 20;

 

步驟4:保存文檔

//保存並打開文檔
doc.SaveToFile("InsertShapes.docx", FileFormat.Docx2010);
System.Diagnostics.Process.Start("InsertShapes.docx");

 

形狀添加效果:

全部代碼:

  1 using Spire.Doc;
  2 using Spire.Doc.Documents;
  3 using Spire.Doc.Fields;
  4 using System.Drawing;
  5 
  6 namespace AddShapes_Doc
  7 {
  8     class Program
  9     {
 10         static void Main(string[] args)
 11         {
 12             //創建一個Document實例
 13             Document doc = new Document();
 14 
 15             //添加一個section paragraph
 16             Section sec = doc.AddSection();
 17             Paragraph para1 = sec.AddParagraph();
 18 
 19             //插入一個矩形
 20             ShapeObject shape1 = para1.AppendShape(50, 50, ShapeType.Rectangle);
 21             shape1.FillColor = Color.Blue;
 22             shape1.StrokeColor = Color.LightSkyBlue;
 23             shape1.HorizontalPosition = 20;
 24             shape1.VerticalPosition = 20;
 25 
 26             //插入一個圓形
 27             ShapeObject shape2 = para1.AppendShape(50, 50, ShapeType.Ellipse);
 28             shape2.FillColor = Color.Purple;
 29             shape2.StrokeColor = Color.LightPink;
 30             shape2.LineStyle = ShapeLineStyle.Single;
 31             shape2.StrokeWeight = 1;
 32             shape2.HorizontalPosition = 80;
 33             shape2.VerticalPosition = 20;
 34 
 35             //插入一個公式符號 +
 36             ShapeObject shape3 = para1.AppendShape(50, 50, ShapeType.Plus);
 37             shape3.FillColor = Color.DarkCyan;
 38             shape3.StrokeColor = Color.LightGreen;
 39             shape3.LineStyle = ShapeLineStyle.Single;
 40             shape3.StrokeWeight = 1;
 41             shape3.HorizontalPosition = 140;
 42             shape3.VerticalPosition = 20;
 43 
 44             //插入一顆星形
 45             ShapeObject shape4 = para1.AppendShape(50, 50, ShapeType.Star);
 46             shape4.FillColor = Color.Red;
 47             shape4.StrokeColor = Color.Gold;
 48             shape4.LineStyle = ShapeLineStyle.Single;
 49             shape4.HorizontalPosition = 200;
 50             shape4.VerticalPosition = 20;
 51 
 52             //插入一個立方體
 53             ShapeObject shape5 = para1.AppendShape(50, 50, ShapeType.Cube);
 54             shape5.FillColor = Color.OrangeRed;
 55             shape5.StrokeColor = Color.Orange;
 56             shape5.LineStyle = ShapeLineStyle.Single;
 57             shape5.HorizontalPosition = 260;
 58             shape5.VerticalPosition = 20;
 59 
 60             //插入一個圓柱體
 61             ShapeObject shape6 = para1.AppendShape(50, 50, ShapeType.Can);
 62             shape6.FillColor = Color.Goldenrod;
 63             shape6.StrokeColor = Color.Gold;
 64             shape6.LineStyle = ShapeLineStyle.Single;
 65             shape6.HorizontalPosition = 320;
 66             shape6.VerticalPosition = 20;
 67 
 68             //插入一個箭頭
 69             ShapeObject shape7 = para1.AppendShape(50, 50, ShapeType.Arrow);
 70             shape7.FillColor = Color.Yellow;
 71             shape7.StrokeColor = Color.Yellow;
 72             shape7.LineStyle = ShapeLineStyle.Single;
 73             shape7.HorizontalPosition = 20;
 74             shape7.VerticalPosition = 80;
 75 
 76             //插入一個v形臂章圖形
 77             ShapeObject shape8 = para1.AppendShape(50, 50, ShapeType.Chevron);
 78             shape8.FillColor = Color.YellowGreen;
 79             shape8.StrokeColor = Color.Yellow;
 80             shape8.LineStyle = ShapeLineStyle.Single;
 81             shape8.HorizontalPosition = 80;
 82             shape8.VerticalPosition = 80;
 83 
 84             //插入一個迴圈箭頭圖形
 85             ShapeObject shape9 = para1.AppendShape(50, 50, ShapeType.CircularArrow);
 86             shape9.FillColor = Color.Green;
 87             shape9.StrokeColor = Color.Yellow;
 88             shape9.LineStyle = ShapeLineStyle.Single;
 89             shape9.HorizontalPosition = 140;
 90             shape9.VerticalPosition = 80;
 91 
 92             //插入一個雲圖形
 93             ShapeObject shape10 = para1.AppendShape(50, 50, ShapeType.CloudCallout);
 94             shape10.FillColor = Color.LightSkyBlue;
 95             shape10.StrokeColor = Color.White;
 96             shape10.LineStyle = ShapeLineStyle.Single;
 97             shape10.HorizontalPosition = 200;
 98             shape10.VerticalPosition = 80;
 99 
100             //插入一個環形圖
101             ShapeObject shape11 = para1.AppendShape(50, 50, ShapeType.Donut);
102             shape11.FillColor = Color.Pink;
103             shape11.StrokeColor = Color.White;
104             shape11.LineStyle = ShapeLineStyle.Single;
105             shape11.HorizontalPosition = 260;
106             shape11.VerticalPosition = 80;
107 
108             //插入一個波浪形狀圖
109             ShapeObject shape12 = para1.AppendShape(50, 50, ShapeType.DoubleWave);
110             shape12.FillColor = Color.Plum;
111             shape12.StrokeColor = Color.White;
112             shape12.LineStyle = ShapeLineStyle.Single;
113             shape12.HorizontalPosition = 320;
114             shape12.VerticalPosition = 80;
115 
116             //插入一個禮結狀圖形
117             ShapeObject shape13 = para1.AppendShape(50, 50, ShapeType.EllipseRibbon);
118             shape13.FillColor = Color.RosyBrown;
119             shape13.StrokeColor = Color.White;
120             shape13.LineStyle = ShapeLineStyle.Single;
121             shape13.HorizontalPosition = 20;
122             shape13.VerticalPosition = 140;
123 
124             //插入一個心形圖
125             ShapeObject shape14 = para1.AppendShape(50, 50, ShapeType.Heart);
126             shape14.FillColor = Color.Red;
127             shape14.StrokeColor = Color.White;
128             shape14.LineStyle = ShapeLineStyle.Single;
129             shape14.HorizontalPosition = 80;
130             shape14.VerticalPosition = 140;
131 
132             //插入一個六邊形圖形
133             ShapeObject shape15 = para1.AppendShape(50, 50, ShapeType.Hexagon);
134             shape15.FillColor = Color.DarkCyan;
135             shape15.StrokeColor = Color.White;
136             shape15.LineStyle = ShapeLineStyle.Single;
137             shape15.HorizontalPosition = 140;
138             shape15.VerticalPosition = 140;
139 
140             //插入一個不規則圖形
141             ShapeObject shape16 = para1.AppendShape(50, 50, ShapeType.IrregularSeal1);
142             shape16.FillColor = Color.DeepPink;
143             shape16.StrokeColor = Color.White;
144             shape16.LineStyle = ShapeLineStyle.Single;
145             shape16.HorizontalPosition = 200;
146             shape16.VerticalPosition = 140;
147 
148             //插入一個月亮形狀
149             ShapeObject shape17 = para1.AppendShape(50, 50, ShapeType.Moon);
150             shape17.FillColor = Color.Violet;
151             shape17.StrokeColor = Color.White;
152             shape17.LineStyle = ShapeLineStyle.Single;
153             shape17.HorizontalPosition = 260;
154             shape17.VerticalPosition = 140;
155 
156             //插入一個"禁止"形狀
157             ShapeObject shape18 = para1.AppendShape(50, 50, ShapeType.NoSmoking);
158             shape18.FillColor = Color.Yellow;
159             shape18.StrokeColor = Color.Goldenrod;
160             shape18.LineStyle = ShapeLineStyle.Single;
161             shape18.HorizontalPosition = 320;
162             shape18.VerticalPosition = 140;
163 
164             //保存並打開文檔
165             doc.SaveToFile("InsertShapes.docx", FileFormat.Docx2010);
166             System.Diagnostics.Process.Start("InsertShapes.docx");
167         }
168     }
169 }
View Code

 

(二)添加組合形狀

步驟1:添加如下using指令

using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
using System.Drawing;

 

步驟2:創建文檔,添加section、paragraph

Document doc = new Document();
Section sec = doc.AddSection();
Paragraph para1 = sec.AddParagraph();

 

步驟3:添加文字,並應用格式到文字

para1.AppendText("中日文化交流");
ParagraphStyle style1 = new ParagraphStyle(doc);
style1.Name = "titleStyle";
style1.CharacterFormat.Bold = true;
style1.CharacterFormat.FontName = "隸書";
style1.CharacterFormat.FontSize = 30f;
doc.Styles.Add(style1);
para1.ApplyStyle("titleStyle");
para1.Format.HorizontalAlignment = HorizontalAlignment.Center;

 

步驟4:實例化段落2,並創建一個形狀組合,並設置大小

//實例化段落2
Paragraph para2 = sec.AddParagraph();
//創建一個形狀組合併設置大小
ShapeGroup shapegr = para2.AppendShapeGroup(300, 300);

 

步驟5:繪製一個中國國旗,這裡需要組合形狀矩形和五角星形,並填充相應的顏色

 //添加一個矩形到形狀組合
            shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Rectangle)
            {
                Width = 900,
                Height = 500,
                LineStyle = ShapeLineStyle.Single,
                FillColor = Color.Red,
                StrokeColor = Color.Red,                
                StrokeWeight = 1,
            });

            //添加第一個五角星到形狀組合
            shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Star)
            {
                Width = 100,
                Height = 100,
                VerticalPosition = 90,
                HorizontalPosition = 90,
                LineStyle = ShapeLineStyle.Single,
                FillColor = Color.Yellow,
                StrokeColor = Color.Yellow,
                StrokeWeight = 1,
            });
            //添加第二個五角星到形狀組合
            shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Star)
            {
                Width = 50,
                Height = 50,
                VerticalPosition = 40,
                HorizontalPosition = 210,
                LineStyle = ShapeLineStyle.Single,
                FillColor = Color.Yellow,
                StrokeColor = Color.Yellow,
                StrokeWeight = 1,
            });
            //添加第三個五角星到形狀組合
            shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Star)
            {
                Width = 50,
                Height = 50,
                VerticalPosition = 80,
                HorizontalPosition = 280,
                LineStyle = ShapeLineStyle.Single,
                FillColor = Color.Yellow,
                StrokeColor = Color.Yellow,
                StrokeWeight = 1,
            });
            //添加第四個五角星到形狀組合
            shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Star)
            {
                Width = 50,
                Height = 50,
                VerticalPosition = 160,
                HorizontalPosition = 280,
                LineStyle = ShapeLineStyle.Single,
                FillColor = Color.Yellow,
                StrokeColor = Color.Yellow,
                StrokeWeight = 1,
            });
            //添加第五個五角星到形狀組合
            shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Star)
            {
                Width = 50,
                Height = 50,
                VerticalPosition = 220,
                HorizontalPosition = 210,
                LineStyle = ShapeLineStyle.Single,
                FillColor = Color.Yellow,
                StrokeColor = Color.Yellow,
                StrokeWeight = 1,
            });

 

步驟6:繪製一個日本國旗,需要組合形狀矩形和圓形,並填充顏色

//繪製一個矩形並添加到形狀組合
            shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Rectangle)
            {
                Width = 900,
                Height = 500,
                VerticalPosition = 700,
                HorizontalPosition = 600,
                LineStyle = ShapeLineStyle.Single,
                FillColor = Color.WhiteSmoke,
                StrokeColor = Color.WhiteSmoke,
                StrokeWeight = 1,
            });
            //繪製一個圓形並添加到形狀組合
            shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Ellipse)
            {
                Width = 250,
                Height = 250,
                VerticalPosition = 800,
                HorizontalPosition = 900,
                LineStyle = ShapeLineStyle.Single,
                FillColor = Color.Red,
                StrokeColor = Color.Red,
                StrokeWeight = 1,
            });

 

步驟7:保存文檔

//保存並打開文檔
doc.SaveToFile("InsertShapegroups.docx", FileFormat.Docx2010);
System.Diagnostics.Process.Start("InsertShapegroups.docx");

 

添加效果:

(此時的圖形是組合後的效果,任意拖動圖形不會出現各個形狀分離、錯位的情況。)

全部代碼:

  1 using Spire.Doc;
  2 using Spire.Doc.Documents;
  3 using Spire.Doc.Fields;
  4 using System.Drawing;
  5 
  6 namespace InsertShapesGroup_Doc
  7 {
  8     class Program
  9     {
 10         static void Main(string[] args)
 11         {
 12             //創建一個Document實例並添加section及paragraph
 13             Document doc = new Document();
 14             Section sec = doc.AddSection();
 15             Paragraph para1 = sec.AddParagraph();
 16             //添加文字,並應用格式到文字
 17             para1.AppendText("中日文化交流");
 18             ParagraphStyle style1 = new ParagraphStyle(doc);
 19             style1.Name = "titleStyle";
 20             style1.CharacterFormat.Bold = true;
 21             style1.CharacterFormat.FontName = "隸書";
 22             style1.CharacterFormat.FontSize = 30f;
 23             doc.Styles.Add(style1);
 24             para1.ApplyStyle("titleStyle");
 25             para1.Format.HorizontalAlignment = HorizontalAlignment.Center;
 26 
 27             //實例化段落2
 28             Paragraph para2 = sec.AddParagraph();
 29             //創建一個形狀組合併設置大小
 30             ShapeGroup shapegr = para2.AppendShapeGroup(300, 300);
 31 
 32             //添加一個矩形到形狀組合
 33             shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Rectangle)
 34             {
 35                 Width = 900,
 36                 Height = 500,
 37                 LineStyle = ShapeLineStyle.Single,
 38                 FillColor = Color.Red,
 39                 StrokeColor = Color.Red,                
 40                 StrokeWeight = 1,
 41             });
 42 
 43             //添加第一個五角星到形狀組合
 44             shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Star)
 45             {
 46                 Width = 100,
 47                 Height = 100,
 48                 VerticalPosition = 90,
 49                 HorizontalPosition = 90,
 50                 LineStyle = ShapeLineStyle.Single,
 51                 FillColor = Color.Yellow,
 52                 StrokeColor = Color.Yellow,
 53                 StrokeWeight = 1,
 54             });
 55             //添加第二個五角星到形狀組合
 56             shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Star)
 57             {
 58                 Width = 50,
 59                 Height = 50,
 60                 VerticalPosition = 40,
 61                 HorizontalPosition = 210,
 62                 LineStyle = ShapeLineStyle.Single,
 63                 FillColor = Color.Yellow,
 64                 StrokeColor = Color.Yellow,
 65                 StrokeWeight = 1,
 66             });
 67             //添加第三個五角星到形狀組合
 68             shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Star)
 69             {
 70                 Width = 50,
 71                 Height = 50,
 72                 VerticalPosition = 80,
 73                 HorizontalPosition = 280,
 74                 LineStyle = ShapeLineStyle.Single,
 75                 FillColor = Color.Yellow,
 76                 StrokeColor = Color.Yellow,
 77                 StrokeWeight = 1,
 78             });
 79             //添加第四個五角星到形狀組合
 80             shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Star)
 81             {
 82                 Width = 50,
 83                 Height = 50,
 84                 VerticalPosition = 160,
 85                 HorizontalPosition = 280,
 86                 LineStyle = ShapeLineStyle.Single,
 87                 FillColor = Color.Yellow,
 88                 StrokeColor = Color.Yellow,
 89                 StrokeWeight = 1,
 90             });
 91             //添加第五個五角星到形狀組合
 92             shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Star)
 93             {
 94                 Width = 50,
 95                 Height = 50,
 96                 VerticalPosition = 220,
 97                 HorizontalPosition = 210,
 98                 LineStyle = ShapeLineStyle.Single,
 99                 FillColor = Color.Yellow,
100                 StrokeColor = Color.Yellow,
101                 StrokeWeight = 1,
102             });
103 
104             //繪製一個矩形並添加到形狀組合
105             shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Rectangle)
106             {
107                 Width = 900,
108                 Height = 500,
109                 VerticalPosition = 700,
110                 HorizontalPosition = 600,
111                 LineStyle = ShapeLineStyle.Single,
112                 FillColor = Color.WhiteSmoke,
113                 StrokeColor = Color.Wheat,
114                 StrokeWeight = 1,
115             });
116             //繪製一個圓形並添加到形狀組合
117             shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Ellipse)
118             {
119                 Width = 250,
120                 Height = 250,
121                 VerticalPosition = 800,
122                 HorizontalPosition = 900,
123                 LineStyle = ShapeLineStyle.Single,
124                 FillColor = Color.Red,
125                 StrokeColor = Color.Red,
126                 StrokeWeight = 1,
127             });    
128 
129             //保存並打開文檔
130             doc.SaveToFile("InsertShapegroups.docx", FileFormat.Docx2010);
131             System.Diagnostics.Process.Start("InsertShapegroups.docx");
132         }
133     }
134 }
View Code

 

以上全部是關於Word中繪製圖形形狀的內容。如需轉載,請註明出處!

感謝閱讀!


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 微軟發佈了.Net Core 2.1正式版,紙殼CMS也在第一時間做了升級,並做了一系列的優化和調整,性能大幅提升,並解決了一些歷史遺留問題,添加了一些新功能。 ...
  • 本質上適合非同步的操作有:HTTP請求,資料庫指令,Web服務調用等。 1、暫停一段時間(以非同步方式)。 以非同步的方式暫停一段時間,這在進行單元測試或者重試延遲時非常有用。 Task類有一個返回Task對象的靜態函數Delay,下麵是其中的一個 一個簡單的指數退避。指數退避是一種重試策略,重試的延遲時 ...
  • SVN 安裝後右鍵出現點擊滑鼠右鍵彈出錯誤提示:CrashHandler initialization error 原因是目標文件夾中缺少SendRpt.exe文件 解決方案:找svn是好的的同事將bin目錄複製替換本地的bin就可以解決 由於沒有找到上傳附件的地方,就沒有上鄙人的bin目錄了,實屬 ...
  • Scenario: 創建了一個WinForm的小程式,希望將它顯示在任務欄,所以在工具欄中的“公共控制項”里,拖入NotifyIcon控制項—notifyIcon1,這個是程式運行任務欄右側通知區域圖標顯示控制項,為控制項notifyIcon的屬性Icon添加一個icon圖標,或從代碼中加入。 Issue: ...
  • 在一些耗時的操作過程中,在長時間運行時可能會導致用戶界面 (UI) 處於停止響應狀態,用戶在這操作期間無法進行其他的操作,為了不使UI層處於停止響應狀態,我們傾向推薦用戶使用BackgroundWorker來進行處理,這個後臺的線程處理,可以很好的實現常規操作的同時,還可以及時通知UI,包括當前處理... ...
  • Select與Select Many 之前在項目中查詢資料庫中的數據,都是通過sql語句來查詢的,但是隨著時代的發展,微軟在.Net Framework 4.5版中推出的一個主要的特性——LINQ。 LINQ是Language Integrate Query的縮寫,意為語言集成查詢。其中有兩種查詢方 ...
  • Restful幾乎已算是API設計的標準,通過HTTP Method區分新增(Create)、查詢(Read)、修改(Update)和刪除(Delete),簡稱CRUD四種數據存取方式,簡約又直接的風格,讓人用的愛不釋手。本篇將介紹如何通過ASP.NET Core實踐REST-Like API。 為 ...
  • .net 這幾年國內確實不好過。 很多都選擇轉行。不過.net Core跨平臺 開源之後 。社區的生態在慢慢建立。往好的趨勢發展。 對於堅守在.NET戰線的開發者來說 是個挺不錯的消息。 特別是微軟收購75億美金GitHub。.net 生態 社區圈子。肯定會有所上升。 發展趨勢越來越好。(當然 這隻 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...