Aspose.Cells 8.6.3 - 8.7.1

简介: 版权声明:欢迎评论和转载,转载请注明来源。 https://blog.csdn.net/zy332719794/article/details/69388973 引用包后,在第一次调用前,执行以下方法就可以正常使用了。
版权声明:欢迎评论和转载,转载请注明来源。 https://blog.csdn.net/zy332719794/article/details/69388973

引用包后,在第一次调用前,执行以下方法就可以正常使用了。

internal static void InitializeAsposeCells()
{
    const BindingFlags BINDING_FLAGS_ALL = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
 
    const string CLASS_LICENSER = "\u0092\u0092\u0008.\u001C";
    const string CLASS_LICENSERHELPER = "\u0011\u0001\u0006.\u001A";
    const string ENUM_ISTRIAL = "\u0092\u0092\u0008.\u001B";
 
    const string FIELD_LICENSER_CREATED_LICENSE = "\u0001";     // static
    const string FIELD_LICENSER_EXPIRY_DATE = "\u0002";         // instance
    const string FIELD_LICENSER_ISTRIAL = "\u0001";             // instance
 
    const string FIELD_LICENSERHELPER_INT128 = "\u0001";        // static
    const string FIELD_LICENSERHELPER_BOOLFALSE = "\u0001";     // static
 
    const int CONST_LICENSER_ISTRIAL = 1;
    const int CONST_LICENSERHELPER_INT128 = 128;
    const bool CONST_LICENSERHELPER_BOOLFALSE = false;
 
    //- Field setter for convinient
    Action<FieldInfo, Type, string, object, object> setValue =
        delegate(FieldInfo field, Type chkType, string chkName, object obj, object value) {
            if ((field.FieldType == chkType) && (field.Name == chkName)) {
                field.SetValue(obj, value);
            }
        };
 
 
    //- Get types
    Assembly assembly = Assembly.GetAssembly(typeof(Aspose.Cells.License));
    Type typeLic = null, typeIsTrial = null, typeHelper = null;
    foreach (Type type in assembly.GetTypes()) {
        if ((typeLic == null) && (type.FullName == CLASS_LICENSER)) {
            typeLic = type;
        }
        else if ((typeIsTrial == null) && (type.FullName == ENUM_ISTRIAL)) {
            typeIsTrial = type;
        }
        else if ((typeHelper == null) && (type.FullName == CLASS_LICENSERHELPER)) {
            typeHelper = type;
        }
    }
    if (typeLic == null || typeIsTrial == null || typeHelper == null) {
        throw new Exception();
    }
 
    //- In class_Licenser
    object license = Activator.CreateInstance(typeLic);
    foreach (FieldInfo field in typeLic.GetFields(BINDING_FLAGS_ALL)) {
        setValue(field, typeLic, FIELD_LICENSER_CREATED_LICENSE, null, license);
        setValue(field, typeof(DateTime), FIELD_LICENSER_EXPIRY_DATE, license, DateTime.MaxValue);
        setValue(field, typeIsTrial, FIELD_LICENSER_ISTRIAL, license, CONST_LICENSER_ISTRIAL);
    }
 
    //- In class_LicenserHelper
    foreach (FieldInfo field in typeHelper.GetFields(BINDING_FLAGS_ALL)) {
        setValue(field, typeof(int), FIELD_LICENSERHELPER_INT128, null, CONST_LICENSERHELPER_INT128);
        setValue(field, typeof(bool), FIELD_LICENSERHELPER_BOOLFALSE, null, CONST_LICENSERHELPER_BOOLFALSE);
    }
}

目前已支持到9.0版本

Aspose 官网:http://www.aspose.com/
Aspose.Cells 官网:http://www.aspose.com/.net/excel-component.aspx




相关文章
|
4月前
|
移动开发 JavaScript 小程序
uView Cell 单元格
uView Cell 单元格
144 1
|
4月前
aspose实现word,excel等文件预览
aspose实现word,excel等文件预览
|
9月前
|
索引
POI(excel)中Cell应用实践总结
POI(excel)中Cell应用实践总结
187 0
C# Aspose.Words 用法
C# Aspose.Words 用法
214 0
C# Aspose.Words 用法
Aspose.Cells 读取受保护的Excel
  最近遇到一个需求,要能够读取受密码保护的Excel内容,之前都是直接读取Excel中的数据,不需要做任何其他的处理.    当Excel双击的时候,需要输入密码,在使用Aspose.Cells 组件读取的时候就会报错 Workbook book = new Workbook(full...
1202 0