using Aspose.Cells; using Bowin.Common.Encoder.DES; using Bowin.Common.Encoder.HmacSHA1; using Bowin.Common.Office; using Bowin.Common.Utility; using Bowin.Common.WebModels; using NPOI.SS.Formula.Functions; using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Net; using System.Text; namespace Bowin.Common.Test { class Program { private static Style GetImportantStyle(Workbook workbook) { var style = workbook.CreateStyle(); style.ForegroundColor = Color.Red; style.Pattern = BackgroundType.Solid; style.Font.Underline = Aspose.Cells.FontUnderlineType.Single; return style; } //private bool TryMatchAdd(IList sourceList, ref decimal targetValue) //{ // var addSourceList = sourceList.ToList(); // addSourceList.Add(0M); // foreach (decimal source in addSourceList) // { // var newValue = targetValue + source; // if (newValue == 16224) // { // return true; // } // } //} static void Main(string[] args) { //var stream = new FileStream(@"D:\测试Aspose.xlsx", FileMode.Open); //var pictureStream = File.Open(@"I:\照片\DSC_0002.JPG", FileMode.Open); //var excel = new AsposeExcelHelper(); //var excelNewStream = excel.ExportToTemplate(stream, new List //{ // new PageItem // { // CellItemList = new List // { // new AsposeCellItem { Row = 3, Col = 1, Value = "单位名称:测试单位" }, // new AsposeCellItem { Row = 3, Col = 4, Value = "打印时间:马上" }, // new AsposeCellItem { Row = 4, Col = 1, Value = "结算时间:下次再说" }, // new AsposeCellItem { Row = 4, Col = 4, Value = "联系电话:不知道" }, // new AsposeCellItem { Row = 8, Col = 5, Value = "123456" } // }, // ListItemList = new List // { // new AsposeListItem { StartRow = 7, StartColumn = 0, EndColumn = 5, Values = new string[][] { // new string[] { "1", "船1", "1000", "普通作业", "201706050001", "120000" }, // new string[] { "2", "船2", "800", "普通作业", "201706050001", "3400" }, // new string[] { "3", "船3", "50", "普通作业", "201706050001", "56" } // }, StyleList = new List { // new AsposeExcelCellStyle { ColumnIndex = 2, RowIndex = 1, StyleFunc = GetImportantStyle } , // new AsposeExcelCellStyle { ColumnIndex = 1, RowIndex = 2, StyleFunc = GetImportantStyle } // } // } // }, // PictureItemList = new List // { // new PictureItem // { // StartRow = 10, // EndRow = 19, // StartColumn = 1, // EndColumn = 4, // Picture = pictureStream // } // } // } //}); //var fs = File.OpenText(@"C:\Users\reicarose\Downloads\银行工资表 (3).txt"); //var t = fs.ReadToEnd(); //var excelFile = new FileStream(@"D:\测试Aspose结果.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); //excelNewStream.WriteTo(excelFile); //excelFile.Flush(); //excelFile.Close(); //var excel = new AsposeExcelHelper(); //var dt = excel.Import(@"D:\测试Excel.xlsx"); //double totalYears = DateHelper.GetYearSpan(new DateTime(2005, 5, 5), new DateTime(2020, 9, 16)); //var pdfStream = ExcelToPDF.Export(excelNewStream); //var pdfFile = new FileStream(@"D:\测试Aspose.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite); //var pdfByte = pdfStream.ToArray(); //pdfFile.Write(pdfByte); //pdfFile.Flush(); //pdfFile.Close(); //var stream = new FileStream(@"D:\测试Aspose.xlsx", FileMode.Open); //var pdfStream = ExcelToPDF.Export(stream); //var pdfFile = new FileStream(@"D:\测试Aspose.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite); //var pdfByte = pdfStream.ToArray(); //pdfFile.Write(pdfByte); //pdfFile.Flush(); //pdfFile.Close(); //var s = HmacSHA1.HMACSHA1Encoder.Encode("sk", "\ntimestamp:1625653256663"); //var startTime = TimeSpan.Parse("00:00:00"); //var endTime = TimeSpan.Parse("08:00:00"); //var webHeaders = new Dictionary(); //var timstamps = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalMilliseconds).ToString(); //webHeaders.Add("timestamp", timstamps); //webHeaders.Add("authorization", "e2d1a7e91a7d4cf39a83f0ab1222eef0" + ":" + HMACSHA1Encoder.Encode("4203b64dd5d44ff1adce449a8f6450d0", "\ntimestamp:" + timstamps)); var systemID = "55ce2b0450082a7145b5ee9fd36dc3d9a81b13f8960b83ab9a0847efb597dd0f"; var secret = "a6cb3528"; var des = new DesAccessor(); var key = Encoding.UTF8.GetBytes(secret).Take(8).ToArray(); var iv = key; var tokenString = systemID + "|" + DateTime.Now.ToString("MMyyyyddmmHHss"); var encToken = des.Encrypt(tokenString, key, iv); var webHeaders = new WebHeaderCollection(); webHeaders.Add("auth-key", encToken); webHeaders.Add("auth-system", systemID); HttpWebRequest client = (HttpWebRequest)WebRequest.Create("http://localhost:5003/service/Employee/GetSailorList"); client.Headers = webHeaders; client.Method = "POST"; using (var response = client.GetResponse()) { var stream = response.GetResponseStream(); var reader = new StreamReader(stream, Encoding.UTF8); var responseText = reader.ReadToEnd(); } } } }