Form5.cs 4.4 KB

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