Aspose.Cells設置授權與簡單使用教程Winform


本文詳細講解如何設置Aspose.Cells的授權與使用,閱讀時間2分鍾。

授權幫助類

 1 using System;
 2 using System.Collections.Generic;
 3 using System.IO;
 4 using System.Text;
 5 
 6 namespace AsposeCellsDemo
 7 {
 8     public sealed class AsposeLicenseHelper
 9     {
10         public static void SetCellLicense()
11         {
12             var txtLicense = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "License.txt");
13             var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(txtLicense));
14             new Aspose.Cells.License().SetLicense(memoryStream);
15         }
16     }
17 } 

加載授權

 1 using System;
 2 using System.Collections.Generic;
 3 using System.IO;
 4 using System.Linq;
 5 using System.Text;
 6 using System.Threading.Tasks;
 7 using System.Windows.Forms;
 8 
 9 namespace AsposeCellsDemo
10 {
11     static class Program
12     {
13         /// <summary>
14         ///  The main entry point for the application.
15         /// </summary>
16         [STAThread]
17         static void Main()
18         {
19             //設置授權
20             AsposeLicenseHelper.SetCellLicense();
21 
22             Application.SetHighDpiMode(HighDpiMode.SystemAware);
23             Application.EnableVisualStyles();
24             Application.SetCompatibleTextRenderingDefault(false);
25             Application.Run(new Form1());
26         }
27     }
28 }

簡單使用

1 private void bExport_Click(object sender, EventArgs e)
2         {
3             var workbook = new Workbook();
4             var sheet = workbook.Worksheets[0];
5             sheet.Cells[0, 0].PutValue("測試");
6             workbook.Save(AppDomain.CurrentDomain.BaseDirectory + "test.xlsx", SaveFormat.Xlsx);
7         }

輸出效果

本文為開發軟件原創文章 禁止轉載

喜歡的朋友點擊一下關注 點關注不迷路


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM