zoukankan      html  css  js  c++  java
  • 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         }

    输出效果

    本文为开发软件原创文章 禁止转载

    喜欢的朋友点击一下关注 点关注不迷路

  • 相关阅读:
    MySQL迁移升级解决方案
    Python json和simplejson的使用
    ASP.NET使用Memcached高缓存实例的初级介绍
    Spring Cloud Stream在同一通道根据消息内容分发不同的消费逻辑
    JS高级---函数的几个成员
    JS高级---bind方法的使用
    JS高级---bind方法
    JS高级---总结apply和call方法的使用
    JS高级---apply和call都可以改变this的指向
    JS高级---复习
  • 原文地址:https://www.cnblogs.com/iaisoft/p/13534784.html
Copyright © 2011-2022 走看看