static void Main(string[] args) { Aspose.Words.License Wlicense = new Aspose.Words.License(); Wlicense.SetLicense("CoolTool.Aspose.Total.lic"); Aspose.Cells.License XLlicense = new Aspose.Cells.License(); XLlicense.SetLicense("CoolTool.Aspose.Total.lic"); Aspose.Pdf.License Plicense = new Aspose.Pdf.License(); Plicense.SetLicense("CoolTool.Aspose.Total.lic"); if (client == Client.Edimart) { grids.Add("Vendor grid", new int[] { 15, 15, 5, 15, 30, 70, 100, 100, 100 }); grids.Add("Ügyfél grid", new int[] { 30, 30, 20, 30, 50, 70, 100, 100, 100 }); } else if (client == Client.Afford) { grids.Add("Vendor grid", new int[] { 0, 10, 10, 10, 25, 40, 65, 100, 100 }); grids.Add("Ügyfél grid", new int[] { 0, 30, 30, 30, 45, 45, 75, 100, 100 }); } LanguageHelper.Initialize(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); mainWindow = new MainWindow(); Application.Run(mainWindow); }
public static void Main(string[] args) { string rootdir = Directory.GetCurrentDirectory(); //Read Configuration from appSettings var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); try { //Aspoe Aspose.Cells.License cellLicense = new Aspose.Cells.License(); string filePath = rootdir + "\\Resources\\" + "Aspose.Total.lic"; FileStream fileStream = new FileStream(filePath, FileMode.Open); cellLicense.SetLicense(fileStream); //Initialize Logger Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(config) .CreateLogger(); Log.Information("API Application Starting......................."); Test t = new Test(); CreateHostBuilder(args).Build().Run(); } catch (Exception ex) { Log.Fatal(ex, "Application start-up failed"); } finally { Log.CloseAndFlush(); } }
public static void Run() { // ExStart:DeterminingLicenseLoading // The path to the License File string licPath = @"Aspose.Cells.lic"; // Create workbook object before setting a license Workbook workbook = new Workbook(); // Check if the license is loaded or not. It will return false Console.WriteLine(workbook.IsLicensed); try { Aspose.Cells.License lic = new Aspose.Cells.License(); lic.SetLicense(licPath); } catch (Exception ex) { Console.WriteLine(ex.Message); } // Check if the license is loaded or not. Now it will return true Console.WriteLine(workbook.IsLicensed); // ExEnd:DeterminingLicenseLoading }
private static void RegisterLicenses() { lock (LicenseLock) { if (!IsLicenseRegistered) { try { // Aspose PDF License Aspose.Pdf.License asposePdfLicense = new Aspose.Pdf.License() { Embedded = true }; asposePdfLicense.SetLicense("Aspose.Pdf.lic"); // Aspose Cells License Aspose.Cells.License asposeCellsLicense = new Aspose.Cells.License(); asposeCellsLicense.SetLicense("Aspose.Cells.lic"); } catch (Exception) { System.Diagnostics.Debug.WriteLine("Aspose License Registration FAILED!"); } IsLicenseRegistered = true; } } }
/// <summary> /// Initialize for mapping manager /// </summary> /// <param name="manager">Mapping manager</param> /// <param name="ignoreBlobs">Flag to ingore blob pointer</param> private static void Initialize(string[] args) { // // Configure logservice LogService.Initialize(typeof(Program)); // // Apose license Aspose.Words.License word = new Aspose.Words.License(); word.SetLicense("Aspose.Total.lic"); Aspose.Cells.License excel = new Aspose.Cells.License(); excel.SetLicense("Aspose.Total.lic"); // // Configure blob pointer bool ignoreBlobs = false; if (args.Contains("/ignore-blobs")) { ignoreBlobs = true; } ManualMapping.IgnoreBlobs = ignoreBlobs; }
private void ExportXLS(string caseID, string Bu, string FormNo) { string templatePath = string.Empty; Aspose.Cells.License lic = new Aspose.Cells.License(); string AsposeLicPath = System.Configuration.ConfigurationSettings.AppSettings["AsposeLicPath"].ToString(); lic.SetLicense(AsposeLicPath); templatePath = Page.Server.MapPath("~/Web/E-Report/TempPrelaunch .xlsx"); //Instantiate a new Workbook object. Aspose.Cells.Workbook book = new Aspose.Cells.Workbook(templatePath); Aspose.Cells.Worksheet sheet1 = book.Worksheets[0]; Aspose.Cells.Worksheet sheet2 = book.Worksheets[1]; // REPLACE PUBLIC FIELDS BindHomePage(ref sheet1, caseID, Bu); BindCheckItem(ref sheet2, FormNo, Bu); this.Response.Clear(); book.Save("Prelaunch_Report.xls", Aspose.Cells.FileFormatType.Excel97To2003, Aspose.Cells.SaveType.OpenInExcel, this.Response, System.Text.Encoding.UTF8); }
protected void Application_Start() { var Key = db.Database.SqlQuery <SYS_CONFIG>("SELECT * FROM SYS_CONFIG WHERE CONFIG_ID = 11").FirstOrDefault(); Aspose.Words.License wordsLicense = new Aspose.Words.License(); wordsLicense.SetLicense(@"" + Key.CONFIG_VALUE); Aspose.Cells.License cellsLicense = new Aspose.Cells.License(); cellsLicense.SetLicense(@"" + Key.CONFIG_VALUE); Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License(); pdfLicense.SetLicense(@"" + Key.CONFIG_VALUE); Aspose.Tasks.License TaskLicense = new Aspose.Tasks.License(); TaskLicense.SetLicense(@"" + Key.CONFIG_VALUE); //AreaRegistration.RegisterAllAreas(); //WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); //BundleConfig.RegisterBundles(BundleTable.Bundles); }
protected void Application_Start(object sender, EventArgs e) { log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(Server.MapPath("~/Inst.config"))); Aspose.Cells.License lic = new Aspose.Cells.License(); lic.SetLicense("Aspose.Cells.lic"); try { Application["version"] = ConfigurationManager.AppSettings["version"]; Dictionary <string, string> dPars = GParametros.TraerParametros( "DistribucionInterfaz.TamanoPaginacion", "DistribucionInterfaz.LimiteTamanoAdjuntos", "DistribucionInterfaz.LimiteResultadosBusqueda", "General.DerechosReservados", "General.DerechosReservadosAnio", "General.NombreProveedor", "General.TituloPaginas", "General.TimeZoneId"); foreach (string clave in dPars.Keys) { Application[clave] = dPars[clave]; } RegisterRoutes(RouteTable.Routes); } catch (Exception ex) { Utils.Inst.Error("Error inesperado al iniciar la aplicación.", ex); } }
private void ExportXLS(string docno, string caseID, string Bu, string Building) { string templatePath = string.Empty; Aspose.Cells.License lic = new Aspose.Cells.License(); string AsposeLicPath = System.Configuration.ConfigurationSettings.AppSettings["AsposeLicPath"].ToString(); lic.SetLicense(AsposeLicPath); templatePath = Page.Server.MapPath("~/Web/E-Report/ReportTemp.xlsx"); //Instantiate a new Workbook object. Aspose.Cells.Workbook book = new Aspose.Cells.Workbook(templatePath); Aspose.Cells.Worksheet sheet1 = book.Worksheets[0]; //DFX Aspose.Cells.Worksheet sheet2 = book.Worksheets[1]; // PMFEA Aspose.Cells.Worksheet sheet3 = book.Worksheets[2]; // IssuesList Aspose.Cells.Worksheet sheet4 = book.Worksheets[3]; // CTQ // REPLACE PUBLIC FIELDS BindExcel(ref sheet1, caseID, Bu, Building, docno); BindPFMA(ref sheet2, caseID, Bu, Building, docno); BindIssuesList(ref sheet3, caseID, Bu, Building, docno); BindCTQ(ref sheet4, caseID, Bu, Building, docno); SetColumnAuto(ref sheet1); this.Response.Clear(); book.Save("NPI_Report.xls", Aspose.Cells.FileFormatType.Excel97To2003, Aspose.Cells.SaveType.OpenInExcel, this.Response, System.Text.Encoding.UTF8); }
static void Main() { Aspose.Cells.License license = new Aspose.Cells.License(); license.SetLicense("Aspose.Words.lic"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
/// <summary> /// Load liencse for apose /// </summary> private static void LicenseAspose() { Aspose.Words.License word = new Aspose.Words.License(); word.SetLicense("Aspose.Total.lic"); Aspose.Cells.License excel = new Aspose.Cells.License(); excel.SetLicense("Aspose.Total.lic"); }
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) { services.AddTransient <Helpers.MFUOperationsHelper, Helpers.MFUOperationsHelper>(); //Instantiate the License class Aspose.Cells.License license = new Aspose.Cells.License(); //Pass only the name of the license file embedded in the assembly license.SetLicense("Aspose.Cells.lic"); }
private void SetAsposeCellLicense() { Aspose.Cells.License Lic = new Aspose.Cells.License(); System.Text.ASCIIEncoding Encoder = new System.Text.ASCIIEncoding(); using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Encoder.GetBytes(라이센스Key))) { Lic.SetLicense(ms); } }
private static void RegistrarAspose() { var licenceTotalPath = @"Licenses/Aspose.Total.lic"; var asposeCellsLicense = new Aspose.Cells.License(); var asposeWordLicense = new Aspose.Words.License(); asposeCellsLicense.SetLicense(licenceTotalPath); asposeWordLicense.SetLicense(licenceTotalPath); }
public MainWindow() { InitializeComponent(); Register(); Aspose.Cells.License li = new Aspose.Cells.License(); string path = System.Windows.Forms.Application.StartupPath + "\\" + @"Aspose.Cells.lic"; li.SetLicense(path); }
///<Summary> /// SetAsposeCellsLicense method to Aspose.Cells License ///</Summary> public static void SetAsposeCellsLicense() { try { Aspose.Cells.License lic = new Aspose.Cells.License(); lic.SetLicense(_licenseFileName); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main() { Aspose.Cells.License lic = new Aspose.Cells.License(); using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Properties.Resources.Aspose_Total)) { lic.SetLicense(ms); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
public static void Main(string[] args) { string rootdir = Directory.GetCurrentDirectory(); try { Aspose.Cells.License cellLicense = new Aspose.Cells.License(); string filePath = rootdir + "\\Resources\\" + "Aspose.Total.lic"; FileStream fileStream = new FileStream(filePath, FileMode.Open); cellLicense.SetLicense(fileStream); } catch (Exception) { throw; } CreateHostBuilder(args).Build().Run(); }
protected void Page_Load(object sender, EventArgs e) { Aspose.Cells.License lic = new Aspose.Cells.License(); lic.SetLicense(@"C:\CellLicense\Aspose.Total.NET.lic"); if (!IsPostBack && !GridWeb1.IsPostBack) { GridWeb1.WorkSheets.Add(); //set sheets selectedIndex to 0 GridWeb1.WorkSheets.ActiveSheetIndex = 0; this.initData(); } }
static void Main(string[] args) { foreach (var process in Process.GetProcessesByName("AcroRd32")) { process.Kill(); } using var fileStream = File.Open("D:\\WorkAsposeFiles\\License.txt", FileMode.Open); var pdf = new Aspose.Pdf.License(); pdf.SetLicense(fileStream); fileStream.Seek(0, SeekOrigin.Begin); var word = new Aspose.Words.License(); word.SetLicense(fileStream); fileStream.Seek(0, SeekOrigin.Begin); var cells = new Aspose.Cells.License(); cells.SetLicense(fileStream); var model = new SkuPdfModel() { Characteristics = new List <Characteristic> { new Characteristic("Количество листов в пачке", "45 шт"), new Characteristic("Класс бумаги", "C"), new Characteristic("Плотность бумаги", "80 гр/м2"), new Characteristic("Страна происхождения", "Россия") }, Classifications = new List <Classification> { new Classification("ОКПД2", "32.99.12.120 Ручки и маркеры с наконечником из фетра и прочих пористых материалов"), new Classification("КПГЗ", "01.15.05.03.04 Принадлежности для досок и флипчартов"), new Classification("КТРУ", "32.99.12.120-00000001 Маркер") }, SupplierOffers = new List <SupplierOffer> { new SupplierOffer("ООО \"ЯСТРЕБ\"", "5427713792", "1219511-21", "5-10 дней", "г Москва, обл Московская", 47, 20), new SupplierOffer("ИП ВЛАДИМИР", "4767898456", "4578548-45", "2-3 часа", "г Казань, Татарстан", 30, 20), new SupplierOffer("ООО \"ЖЕНЕРИК\"", "7894598723", "6578459-12", "1-2 недели", "г Москва, обл Московская", 50, 20) } }; CreateTemplate(model); Process.Start("D:\\WorkAsposeFiles\\template.pdf"); }
private static void setLicense() { { //Enable Word support Aspose.Words.License license = new Aspose.Words.License(); license.SetLicense("Aspose.Total.lic"); } { //Enable Excel support Aspose.Cells.License license = new Aspose.Cells.License(); license.SetLicense("Aspose.Total.lic"); } { //Enable PDF support Aspose.Pdf.License license = new Aspose.Pdf.License(); license.SetLicense("Aspose.Total.lic"); } }
public static void License() { string licensePath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Aspose.Total.lic"; Aspose.Pdf.License pdf_license = new Aspose.Pdf.License(); pdf_license.SetLicense(licensePath); Aspose.Words.License word_license = new Aspose.Words.License(); word_license.SetLicense(licensePath); Aspose.Cells.License excel_license = new Aspose.Cells.License(); excel_license.SetLicense(licensePath); Aspose.Slides.License ppt_license = new Aspose.Slides.License(); ppt_license.SetLicense(licensePath); }
public static void Main(string[] args) { string rootdir = Directory.GetCurrentDirectory(); try { Aspose.Cells.License license = new Aspose.Cells.License(); string filePath = rootdir + "\\Resources\\" + "Aspose.Total.lic"; FileStream filestream = new FileStream(filePath, FileMode.Open); license.SetLicense(filestream); } catch (Exception ex) { Console.WriteLine("\nThere was an error setting the license: " + ex.Message); } CreateHostBuilder(args).Build().Run(); }
static void Main() { using (MemoryStream licdata = new MemoryStream(Properties.Resources.Aspose_Total)) { licdata.Seek(0, SeekOrigin.Begin); Aspose.Words.License word_lic = new Aspose.Words.License(); word_lic.SetLicense(licdata); licdata.Seek(0, SeekOrigin.Begin); Aspose.Cells.License cell_lic = new Aspose.Cells.License(); cell_lic.SetLicense(licdata); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
protected void Application_Start(object sender, EventArgs e) { base.BaseApplication_Start(); DbConfiguration.SetConfiguration(new DatabaseConfiguration()); log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(Server.MapPath("~/Web.config"))); AreaRegistration.RegisterAllAreas(); #if !DEBUG Aspose.Cells.License lic = new Aspose.Cells.License(); lic.SetLicense(Server.MapPath("Aspose.Cells.lic")); #endif RouteConfig.RegisterRoutes(RouteTable.Routes); //Registers the notifier that will send emails etc on notifications. DataContext.RegisteryNotifier(new Notifier()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); ModelBinders.Binders.Add(typeof(DateTime), new CustomDateBinder()); ModelBinders.Binders.Add(typeof(DateTime?), new NullableCustomDateBinder()); Stream stream = new MemoryStream(StrToByteArray(Resources.Licence)); stream.Position = 0; Aspose.Pdf.License licensePdf = new Aspose.Pdf.License(); Aspose.Words.License licenseWords = new Aspose.Words.License(); Aspose.Cells.License licenseCells = new Aspose.Cells.License(); Aspose.Slides.License licenseSlides = new Aspose.Slides.License(); Aspose.BarCode.License licenseBarCode = new Aspose.BarCode.License(); licensePdf.SetLicense(stream); stream.Position = 0; licenseWords.SetLicense(stream); stream.Position = 0; licenseCells.SetLicense(stream); stream.Position = 0; licenseSlides.SetLicense(stream); stream.Position = 0; licenseBarCode.SetLicense(stream); stream.Close(); // CreateLogins(); // CheckLogins(); LogHelper.InitLogger(); LogHelper.Log.Info("Application Start"); EmployePermissionHelper.Init(); QScheduler.Start(); }
public static bool ExportExcelWithAspose(DataSet ds, string path) { bool succeed = false; if (ds != null&&ds.Tables.Count>0) { try { Aspose.Cells.License li = new Aspose.Cells.License(); var lic = Resources.License; Stream s = new MemoryStream(lic); li.SetLicense(s); Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(); for (int tableCount = 0; tableCount < ds.Tables.Count; tableCount++) { workbook.Worksheets.Add(ds.Tables[tableCount].TableName); Aspose.Cells.Worksheet cellSheet = workbook.Worksheets[tableCount]; // cellSheet.Name = ds.Tables[tableCount].TableName; int rowIndex = 0; int colIndex = 0; int colCount = ds.Tables[tableCount].Columns.Count; int rowCount = ds.Tables[tableCount].Rows.Count; //列名的处理 for (int i = 0; i < colCount; i++) { cellSheet.Cells[rowIndex, colIndex].PutValue(ds.Tables[tableCount].Columns[i].ColumnName); cellSheet.Cells[rowIndex, colIndex].Style.Font.IsBold = true; cellSheet.Cells[rowIndex, colIndex].Style.Font.Name = "宋体"; colIndex++; } Aspose.Cells.Style style = workbook.Styles[workbook.Styles.Add()]; style.Font.Name = "Arial"; style.Font.Size = 10; Aspose.Cells.StyleFlag styleFlag = new Aspose.Cells.StyleFlag(); cellSheet.Cells.ApplyStyle(style, styleFlag); rowIndex++; for (int i = 0; i < rowCount; i++) { colIndex = 0; for (int j = 0; j < colCount; j++) { cellSheet.Cells[rowIndex, colIndex].PutValue(ds.Tables[tableCount].Rows[i][j].ToString()); colIndex++; } rowIndex++; } cellSheet.AutoFitColumns(); } path = Path.GetFullPath(path); workbook.Save(path); succeed = true; } catch (Exception ex) { succeed = false; } } return succeed; }
/// <summary> /// 載入表單 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_Load(object sender, EventArgs e) { if (!System.IO.File.Exists(Path.Combine(System.Windows.Forms.Application.StartupPath, "開發模式"))) Program.Update(); this.Icon = Resources.ischedule_logo; schLocal.ImportSourceComplete += (vsender, ve) => { GC.Collect(); lblMemoryUsage.Text = "使用記憶體:" + ((float)GC.GetTotalMemory(false) / (1024 * 1024)) + " MB"; }; schLocal.EventScheduled += (vsender, ve) => { GC.Collect(); lblMemoryUsage.Text = "使用記憶體:" + ((float)GC.GetTotalMemory(false) / (1024 * 1024)) + " MB"; }; #region 設定Aspose License Aspose.Cells.License License = new Aspose.Cells.License(); FileStream Stream = new FileStream(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\components\\Aspose.Total.lic", FileMode.Open); License.SetLicense(Stream); #endregion SetScheduleSourceCloseMenu(); schLocal.ImportSourceComplete += (vsender, ve) => SetScheduleSourceOpenMenu(); //測試OK btnClose.Click += (vsender, ve) => { //關閉時將密碼及路徑清空 Password = string.Empty; Filepath = string.Empty; //關閉左方資源列表 pnlTeacher.Controls.Clear(); pnlClass.Controls.Clear(); pnlClassroom.Controls.Clear(); //關閉分課表 TeacherEventsView.Close(); ClassEventsView.Close(); ClassroomEventsView.Close(); //關閉功課表 CloseLPView(tabTeacherLPView); CloseLPView(tabClassLPView); CloseLPView(tabClassroomLPView); //關閉選單 SetScheduleSourceCloseMenu(); //關閉資料 schLocal.Close(); }; //測試OK LeftNavigationPanel.NavigationBar.Visible = false; #region 當頁籤切換時的控制 btnTeacher.Checked = true; btnExit.Click += (vsender, ve) => Application.Exit(); ribbonTabTeacher.Click += (vsender, ve) => { btnTeacher.Checked = true; tabContent.SelectedTab = tabTeacher; }; ribbonTabClass.Click += (vsender, ve) => { btnClass.Checked = true; tabContent.SelectedTab = tabClass; }; ribbonTabClassroom.Click += (vsender, ve) => { btnClassroom.Checked = true; tabContent.SelectedTab = tabClassroom; }; #endregion this.TeacherEventsView = new EventsViewBL(Constants.lvWho, grdTeacherEvent, lblTeacher, btnTeacherAutoSchedule, btnTeacherLock, btnTeacherUnlock, btnTeacherFree, btnTeacherProperty, btnTeacherPrint); this.ClassEventsView = new EventsViewBL(Constants.lvWhom, grdClassEvent, lblClass, btnClassAutoSchedule, btnClassLock, btnClassUnLock, btnClassFree, btnClassProperty, btnClassPrint); this.ClassroomEventsView = new EventsViewBL(Constants.lvWhere, grdClassroomEvent, lblClassroom, btnClassroomAutoSchedule, btnClassroomLock, btnClassroomUnLock, btnClassroomFree, btnClassroomProperty, btnClassroomPrint); this.btnTeacherEventExpand.Click += (vsender, ve) => { if (splTeacher.Expanded) { //寫入紀錄(目前顯示欄位) btnTeacherEventExpand.Text = "<<"; btnTeacherEventExpand.Tooltip = "還原"; splTeacher.Expanded = false; } else { btnTeacherEventExpand.Text = ">>"; btnTeacherEventExpand.Tooltip = "最大化"; splTeacher.Expanded = true; } }; this.btnClassEventExpand.Click += (vsender, ve) => { if (splClass.Expanded) { //寫入紀錄(目前顯示欄位) btnClassEventExpand.Text = "<<"; btnClassEventExpand.Tooltip = "還原"; splClass.Expanded = false; } else { btnClassEventExpand.Text = ">>"; btnClassEventExpand.Tooltip = "最大化"; splClass.Expanded = true; } }; this.btnClassroomEventExpand.Click += (vsender, ve) => { if (splClassroom.Expanded) { //寫入紀錄(目前顯示欄位) btnClassroomEventExpand.Text = "<<"; btnClassroomEventExpand.Tooltip = "還原"; splClassroom.Expanded = false; } else { btnClassroomEventExpand.Text = ">>"; btnClassroomEventExpand.Tooltip = "最大化"; splClassroom.Expanded = true; } }; ribbonTabTeacher.Checked = true; this.pnlWhoLPView.Width = 600; this.pnlWhomLPView.Width = 600; this.pnlWhereLPView.Width = 600; //改由各個學校更新 //ServerModule.AutoManaged("http://module.ischool.com.tw/module/89/ischedule/udm.xml"); #region 測試用程式碼 //schLocal.Open("C:\\101學年度第2學期0210.xml"); //LoadResourceList(); #endregion }
private static void LoadLicense(string ext) { switch (ext) { case ".PDF": var pdfLicense = new Aspose.Pdf.License(); pdfLicense.SetLicense("Aspose.Total.lic"); break; case ".DOC": case ".DOCX": case ".RTF": var docLicense = new Aspose.Words.License(); docLicense.SetLicense("Aspose.Total.lic"); break; case ".XLS": case ".XLSX": case ".CSV": var xlsLicense = new Aspose.Cells.License(); xlsLicense.SetLicense("Aspose.Total.lic"); break; case ".PPT": case ".PPTX": var pptLicense = new Aspose.Slides.License(); pptLicense.SetLicense("Aspose.Total.lic"); break; case ".VSD": case ".VSDX": var vsdLicense = new Aspose.Diagram.License(); vsdLicense.SetLicense("Aspose.Total.lic"); break; case ".MSG": var emaiLicense = new Aspose.Email.License(); var msgPdfLicense = new Aspose.Words.License(); emaiLicense.SetLicense("Aspose.Total.lic"); msgPdfLicense.SetLicense("Aspose.Total.lic"); break; default: var license = new Aspose.Words.License(); license.SetLicense("Aspose.Total.lic"); break; } }
public static bool ExportExcelWithAspose(System.Data.DataTable dt, string path) { bool succeed = false; if (dt != null) { try { Aspose.Cells.License li = new Aspose.Cells.License(); string lic = @"<License> <Data> <SerialNumber>aed83727-21cc-4a91-bea4-2607bf991c21</SerialNumber> <EditionType>Enterprise</EditionType> <Products> <Product>Aspose.Total</Product> </Products> </Data> <Signature>CxoBmxzcdRLLiQi1kzt5oSbz9GhuyHHOBgjTf5w/wJ1V+lzjBYi8o7PvqRwkdQo4tT4dk3PIJPbH9w5Lszei1SV/smkK8SCjR8kIWgLbOUFBvhD1Fn9KgDAQ8B11psxIWvepKidw8ZmDmbk9kdJbVBOkuAESXDdtDEDZMB/zL7Y=</Signature> </License>"; Stream s = new MemoryStream(ASCIIEncoding.Default.GetBytes(lic)); li.SetLicense(s); Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(); Aspose.Cells.Worksheet cellSheet = workbook.Worksheets[0]; cellSheet.Name = "Sheet1"; int rowIndex = 0; int colIndex = 0; int colCount = dt.Columns.Count; int rowCount = dt.Rows.Count; //列名的处理 for (int i = 0; i < colCount; i++) { cellSheet.Cells[rowIndex, colIndex].PutValue(dt.Columns[i].ColumnName); cellSheet.Cells[rowIndex, colIndex].Style.Font.IsBold = true; cellSheet.Cells[rowIndex, colIndex].Style.Font.Name = "宋体"; colIndex++; } Aspose.Cells.Style style = workbook.Styles[workbook.Styles.Add()]; style.Font.Name = "Arial"; style.Font.Size = 10; Aspose.Cells.StyleFlag styleFlag = new Aspose.Cells.StyleFlag(); cellSheet.Cells.ApplyStyle(style, styleFlag); rowIndex++; for (int i = 0; i < rowCount; i++) { colIndex = 0; for (int j = 0; j < colCount; j++) { cellSheet.Cells[rowIndex, colIndex].PutValue(dt.Rows[i][j].ToString()); colIndex++; } rowIndex++; } cellSheet.AutoFitColumns(); path = Path.GetFullPath(path); workbook.Save(path); succeed = true; } catch (Exception ex) { succeed = false; } } return succeed; }
private void DownloadToExcel(DataTable tb) { //定义一个行和列的宽度 int col = 0; int row = 1; //定义一个执照 Aspose.Cells.License license = new Aspose.Cells.License(); license.SetLicense("Aspose.Cells.lic"); //license.SetLicense("License.lic"); //定义 excel一个工作薄 Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(); //定义一个工作页名称 Aspose.Cells.Worksheet worksheet = workbook.Worksheets[0]; //工作页的名称 worksheet.Name = "物流未签收"; //获取数据源 DataTable dt = tb; //设置第行的宽度 worksheet.Cells.SetColumnWidth(0, 0.4); #region 生成标题行 //设置行的高度 worksheet.Cells.SetRowHeight(row, 20); #region 买家昵称 worksheet.Cells.SetColumnWidth(col, 13); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("买家昵称"); FormatCellInBlue(worksheet.Cells[row, col++]);//01 #endregion #region 订单状态 worksheet.Cells.SetColumnWidth(col, 10); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("订单状态"); FormatCellInBlue(worksheet.Cells[row, col++]);//02 #endregion row++; #endregion #region 放值 for (int i = 0; i < dt.Rows.Count; i++) { //定义行数为1 col = 0; DataRow rows = dt.Rows[i]; //buyer_nick worksheet.Cells[row, col].PutValue(rows["buyer_nick"]); FormatCell(worksheet.Cells[row, col++]); //tid worksheet.Cells[row, col].PutValue(rows["stutas"]); FormatDateCell(worksheet.Cells[row, col++]); row++; } #endregion string filepath = ""; #region Sending file try { filepath = Server.MapPath("."); string filename = Users.Nick + ".xls"; workbook.Save(filepath + "\\" + filename); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); Response.WriteFile(filepath + "\\" + filename); Response.Flush(); System.IO.File.Delete(filepath + "\\" + filename); Response.Close(); } catch (Exception ex) { throw ex; } #endregion dt.Dispose(); }
static DocumentProcessing() { WORDS_LICENSE.SetLicense("Aspose.Total.lic"); CELLS_LICENSE.SetLicense("Aspose.Total.lic"); PDF_LICENSE.SetLicense("Aspose.Total.lic"); }
///<Summary> /// SetAsposeCellsLicense method to Aspose.Cells License ///</Summary> public static void SetCellsLicense() { var acLic = new Aspose.Cells.License(); acLic.SetLicense("Aspose.Total.lic"); }
private DataTable BuildDataTableFromFileExcel(System.IO.Stream dataStream) { var infoTb = BuildNewtable(); try { Aspose.Cells.License license = new Aspose.Cells.License(); license.SetLicense("Aspose.Cells.lic"); Aspose.Cells.Workbook document = new Aspose.Cells.Workbook(); document.Open(dataStream); if (document.Worksheets[0].Cells.Rows.Count <= 1) return infoTb; for (var i = 1; i < document.Worksheets[0].Cells.Rows.Count; i++) { if (string.IsNullOrEmpty(document.Worksheets[0].Cells[i, 0].Value.ToString())) continue; var row = infoTb.NewRow(); row["WorkingAccId"] = document.Worksheets[0].Cells[i, 3].Value; row["PaymentMethod"] = document.Worksheets[0].Cells[i, 0].Value; row["CreditAmount"] = String.Format(CultureInfo.InvariantCulture, "{0:0,0}", document.Worksheets[0].Cells[i, 5].Value); row["CreditAccount"] = string.Format("{0}-{1}-{2}", document.Worksheets[0].Cells[i, 4].Value, document.Worksheets[0].Cells[i, 3].Value, document.Worksheets[0].Cells[i, 2].Value); row["Exist"] = string.Empty; infoTb.Rows.Add(row); } UpdateDataInfo(infoTb); } catch (Exception ex) { labelNoResults.Text = "Wrong Selected Company Payment file"; } return infoTb; }
private void DownloadToExcel(DataTable tb) { //定义一个行和列的宽度 int col = 0; int row = 1; //定义一个执照 Aspose.Cells.License license = new Aspose.Cells.License(); license.SetLicense("Aspose.Cells.lic"); //license.SetLicense("License.lic"); //定义 excel一个工作薄 Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(); //定义一个工作页名称 Aspose.Cells.Worksheet worksheet = workbook.Worksheets[0]; //工作页的名称 worksheet.Name = "会员信息"; //获取数据源 DataTable dt = tb; //设置第行的宽度 worksheet.Cells.SetColumnWidth(0, 0.4); #region 生成标题行 //设置行的高度 worksheet.Cells.SetRowHeight(row, 20); #region 买家昵称 worksheet.Cells.SetColumnWidth(col, 8.9); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("买家昵称"); FormatCellInBlue(worksheet.Cells[row, col++]); // 01 #endregion #region 姓名 worksheet.Cells.SetColumnWidth(col, 12); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("姓名"); FormatCellInBlue(worksheet.Cells[row, col++]);//02 #endregion #region 所在省份 worksheet.Cells.SetColumnWidth(col, 11.6); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("所在省份"); FormatCellInBlue(worksheet.Cells[row, col++]);//03 #endregion #region 手机号码 worksheet.Cells.SetColumnWidth(col, 13); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("手机号码"); FormatCellInBlue(worksheet.Cells[row, col++]);//04 #endregion #region 会员级别 worksheet.Cells.SetColumnWidth(col, 10); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("会员级别"); FormatCellInBlue(worksheet.Cells[row, col++]);//05 #endregion #region 消费金额 worksheet.Cells.SetColumnWidth(col, 9.8); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("消费金额"); FormatCellInBlue(worksheet.Cells[row, col++]);//06 #endregion #region 购买宝贝数 worksheet.Cells.SetColumnWidth(col, 11); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("购买宝贝数"); FormatCellInBlue(worksheet.Cells[row, col++]);//07 #endregion #region 最近交易日期 worksheet.Cells.SetColumnWidth(col, 12); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("最近交易日期"); FormatCellInBlue(worksheet.Cells[row, col++]);//08 #endregion #region 地址 worksheet.Cells.SetColumnWidth(col, 35); worksheet.Cells[row, col].Style.IsTextWrapped = true; worksheet.Cells[row, col].PutValue("地址"); FormatCellInBlue(worksheet.Cells[row, col++]);//09 #endregion //#region 是否退过货 //worksheet.Cells.SetColumnWidth(col, 11); //worksheet.Cells[row, col].Style.IsTextWrapped = true; //worksheet.Cells[row, col].PutValue("是否退过货"); //FormatCellInBlue(worksheet.Cells[row, col++]);//10 //#endregion //#region 是否有过关闭交易 //worksheet.Cells.SetColumnWidth(col, 11); //worksheet.Cells[row, col].Style.IsTextWrapped = true; //worksheet.Cells[row, col].PutValue("是否有过关闭交易"); //FormatCellInBlue(worksheet.Cells[row, col++]);//10 //#endregion row++; #endregion #region 放值 for (int i = 0; i < dt.Rows.Count; i++) { //定义行数为1 col = 0; DataRow rows = dt.Rows[i]; //买家昵称 worksheet.Cells[row, col].PutValue(rows["buyer_nick"].ToString()); FormatCell(worksheet.Cells[row, col++]); // 01 //姓名 worksheet.Cells[row, col].PutValue(rows["buyer_reallName"]); FormatCell(worksheet.Cells[row, col++]); //所在省份 worksheet.Cells[row, col].PutValue(rows["province"]); FormatCell(worksheet.Cells[row, col++]); //手机号码 worksheet.Cells[row, col].PutValue(rows["cellPhone"]); FormatCell(worksheet.Cells[row, col++]); //会员级别 worksheet.Cells[row, col].PutValue(rows["grade"]); FormatCell(worksheet.Cells[row, col++]); //消费金额 worksheet.Cells[row, col].PutValue(rows["trade_amount"]); FormatCell(worksheet.Cells[row, col++]); //购买宝贝数 worksheet.Cells[row, col].PutValue(rows["item_num"].ToString()); FormatNumberCell(worksheet.Cells[row, col++]); //最近交易日期 worksheet.Cells[row, col].PutValue(rows["last_trade_time"].ToString()); FormatDateCell(worksheet.Cells[row, col++]); //地址 worksheet.Cells[row, col].PutValue(rows["address"].ToString()); FormatCell(worksheet.Cells[row, col++]); //是否退过货 //worksheet.Cells[row, col].PutValue(rows["isRefundBuyer"].ToString()); //if (!string.IsNullOrEmpty(rows["isRefundBuyer"].ToString()) && rows["isRefundBuyer"].ToString().Equals("是")) //{ // FormatCellInYellow(worksheet.Cells[row, col++]); //} //else //{ // FormatCell(worksheet.Cells[row, col++]); //} row++; } #endregion string filepath = ""; #region Sending file try { filepath = Server.MapPath("."); string filename = "buyresInfo.xls"; workbook.Save(filepath + "\\" + filename); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); Response.WriteFile(filepath + "\\" + filename); Response.Flush(); System.IO.File.Delete(filepath + "\\" + filename); Response.Close(); } catch (Exception ex) { throw ex; } #endregion dt.Dispose(); ReSet(); }
public static void SetLicense() { Aspose.Cells.License license = new Aspose.Cells.License(); license.SetLicense("Aspose.Cells.lic"); }