(编辑:jimmy 日期: 2024/12/24 浏览:2)
image.png
image.png
image.png
image.png
image.png
image.png
forum.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
var wb = new Workbook();wb.Crack();
public static class SpireOfficeHelpers { public static void Print(string path) { var wb = new Workbook(); wb.Crack(); wb.LoadFromFile(path); var p = wb.PrintDocument;#pragma warning disable CA1416 // 验证平台兼容性 p.Print();#pragma warning restore CA1416 // 验证平台兼容性 } public static void Print(byte[] bytes) { MemoryStream memeStream = new(bytes); var wb = new Workbook(); wb.Crack(); wb.LoadFromStream(memeStream); var p = wb.PrintDocument;#pragma warning disable CA1416 // 验证平台兼容性 p.Print();#pragma warning restore CA1416 // 验证平台兼容性 } /// <summary> /// 注入激活信息 /// </summary> /// <param name="workbook"></param> public static void Crack(this Workbook workbook) { CrackLicense(workbook); } /// <summary> /// 注入激活信息 /// </summary> /// <param name="document"></param> public static void Crack(this Document document) { CrackLicense(document); } /// <summary> /// 注入激活信息,并返回该类型 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="t"></param> /// <returns></returns> public static T CrackLicense<T>(T t) where T : class { var InternalLicense = t.GetType().GetProperty("InternalLicense", BindingFlags.NonPublic | BindingFlags.Instance); var TypeLic = InternalLicense.PropertyType.Assembly.CreateInstance(InternalLicense.PropertyType.GetTypeInfo().FullName); foreach (var item in TypeLic.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) { if (item.FieldType.IsArray) { item.SetValue(TypeLic, new string[] { "Spire.Spreadsheet", "Spire.DocViewer.Wpf" }); } else if (item.FieldType.IsEnum) { item.SetValue(TypeLic, 3); } } InternalLicense.SetValue(t, TypeLic); return t; } }