Query_SpecialReport.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using UAS_MES_NEW.DataOperate;
  10. using UAS_MES_NEW.Entity;
  11. using UAS_MES_NEW.PublicMethod;
  12. namespace UAS_MES_NEW.Query
  13. {
  14. public partial class Query_SpecialReport : Form
  15. {
  16. DataHelper dh = SystemInf.dh;
  17. public Query_SpecialReport()
  18. {
  19. InitializeComponent();
  20. }
  21. private void Export_Click(object sender, EventArgs e)
  22. {
  23. ExcelExport("");
  24. }
  25. //选择导出Excel时是选择导出数据的还是模板
  26. private void ExcelExport(string DataOrTemplet)
  27. {
  28. //Data表示导出数据
  29. //Templet表示导出模板
  30. folderBrowserDialog1.Description = "选择导出的路径";
  31. DialogResult result = folderBrowserDialog1.ShowDialog();
  32. if (result == DialogResult.OK)
  33. {
  34. string FolderPath = folderBrowserDialog1.SelectedPath;
  35. ExcelHandler eh = new ExcelHandler();
  36. DataTable dt = new DataTable();
  37. dt.Columns.Add("工单号");
  38. dt.Columns.Add("MAC");
  39. dt.Columns.Add("BT");
  40. dt.Columns.Add("拓展栏位1");
  41. dt.Columns.Add("拓展栏位2");
  42. dt.Columns.Add("拓展栏位3");
  43. dt.Columns.Add("备注");
  44. string prefix = BeginMac.Text.Substring(0, 8);
  45. string suffix = BeginMac.Text.Substring(8, 4);
  46. int num = Int32.Parse(suffix, System.Globalization.NumberStyles.HexNumber);
  47. for (int i = 0; i < int.Parse(Num.Text); i++)
  48. {
  49. DataRow dr = dt.NewRow();
  50. dr["工单号"] = ma_code.Text;
  51. dr["MAC"] = prefix + num.ToString("X");
  52. num = num + 1;
  53. dr["BT"] = prefix + num.ToString("X");
  54. num = num + 1;
  55. dt.Rows.Add(dr);
  56. }
  57. eh.ExportExcel(dt, FolderPath);
  58. }
  59. }
  60. private void Query_SpecialReport_Load(object sender, EventArgs e)
  61. {
  62. }
  63. }
  64. }