Form5.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Windows.Forms;
  3. using Aspose.Cells.Rendering;
  4. using Aspose.Cells;
  5. using System.Drawing.Imaging;
  6. using UMESDLLService;
  7. namespace FileWatcher
  8. {
  9. public partial class Form5 : Form
  10. {
  11. public Form5()
  12. {
  13. InitializeComponent();
  14. }
  15. private void label12_Click(object sender, EventArgs e)
  16. {
  17. }
  18. private void textBox7_TextChanged(object sender, EventArgs e)
  19. {
  20. }
  21. private void textBox3_TextChanged(object sender, EventArgs e)
  22. {
  23. }
  24. public void ExportRangeAsJpg()
  25. {
  26. Workbook book = new Workbook(@"C:\\Users\\callm\\Desktop\\新建文件夹\\99001-91A1C2079.xls");
  27. for (int i = 0; i < book.Worksheets.Count; i++)
  28. {
  29. Worksheet sheet = book.Worksheets[i];
  30. Console.WriteLine(sheet.CodeName);
  31. Console.WriteLine(sheet.Name);
  32. sheet.PageSetup.LeftMargin = 0;
  33. sheet.PageSetup.RightMargin = 0;
  34. sheet.PageSetup.BottomMargin = 0;
  35. sheet.PageSetup.TopMargin = 0;
  36. ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
  37. imgOptions.ImageFormat = ImageFormat.Png;
  38. imgOptions.OnePagePerSheet = true;
  39. imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
  40. SheetRender sr = new SheetRender((Aspose.Cells.Worksheet)sheet, imgOptions);
  41. sr.ToImage(0, sheet.Name + ".png");
  42. }
  43. }
  44. private void Form4_Load(object sender, EventArgs e)
  45. {
  46. MESHelper mes=new MESHelper();
  47. string str = "";
  48. string str1 = "";
  49. mes.GetMobileAllInfo("58875734C2000134", out str, out str1);
  50. Console.WriteLine( str);
  51. }
  52. //private void SaveFileToJPG(Worksheet sheet)
  53. //{
  54. // try
  55. // {
  56. // //DataHelper dh = new DataHelper();
  57. // OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】添加水印" + "\n");
  58. // ExcelPicture picture = sheet.Pictures.Add(@"图片\电子受控章.png");
  59. // picture.Width = 113;
  60. // picture.Height = 38;
  61. // picture.LeftColumn = 20;
  62. // picture.TopRowOffset = 20;
  63. // ExcelPicture picture1 = sheet.Pictures.Add(@"图片\签名.png");
  64. // picture1.Width = 100;
  65. // picture1.Height = 38;
  66. // picture1.LeftColumn = 15;
  67. // picture1.TopRowOffset = 600;
  68. // sheet.SaveToImage(@"C:\Users\callm\Desktop\" + "新建文件夹"+ @"\" + sheet.Name + ".jpg");
  69. // OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】" + "\n");
  70. // Dictionary<string, object> dic = new Dictionary<string, object>();
  71. // dic.Add("em_name", "管理员");
  72. // dic.Add("em_code", "ADMIN");
  73. // dic.Add("caller", "ProductSOP");
  74. // OperatResult.AppendText("上传文件【" + sheet.Name + ".jpg" + "】\n");
  75. // }
  76. // catch (Exception ex)
  77. // {
  78. // OperatResult.AppendText(ex.Message + ex.StackTrace);
  79. // }
  80. //}
  81. //private void SaveFileToPDF(Worksheet sheet)
  82. //{
  83. // //if (!Directory.Exists(Application.StartupPath + @"\" + pr_code.Text))
  84. // //{
  85. // // Directory.CreateDirectory(Application.StartupPath + @"\" + pr_code.Text);
  86. // //}
  87. // sheet.SaveToPdf(@"C:\Users\callm\Desktop\" + "新建文件夹" + @"\" + sheet.Name + ".pdf");
  88. // OperatResult.AppendText("解析PDF【" + sheet.Name + ".pdf】" + "\n");
  89. // Dictionary<string, object> dic = new Dictionary<string, object>();
  90. // dic.Add("em_name", "管理员");
  91. // dic.Add("em_code", "ADMIN");
  92. // dic.Add("caller", "ProductSOP");
  93. // OperatResult.AppendText("上传文件【" + sheet.Name + ".pdf" + "】\n");
  94. //}
  95. private void ExcelDocViewer(string fileName)
  96. {
  97. try
  98. {
  99. System.Diagnostics.Process.Start(fileName);
  100. }
  101. catch { }
  102. }
  103. private void textBox4_TextChanged(object sender, EventArgs e)
  104. {
  105. }
  106. }
  107. }