Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

列印_生產進度表.vb 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. Option Strict Off
  2. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  3. Imports Microsoft.Office.Interop.Excel.Constants
  4. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  5. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  6. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  7. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  8. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  9. Imports Microsoft.Office.Interop.Excel.XlWindowState
  10. Imports Microsoft.Office.Interop.Excel
  11. Public Class 列印_生產進度表
  12. Public Property ThisWorkbook As Object
  13. Public Property ActiveWorkbook As Object
  14. Private ReadOnly ds, ds1 As New DataSet
  15. Dim N1 As Integer = 0
  16. Dim ASS As String
  17. Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
  18. Private Sub Set_工廠清單()
  19. 工廠_DGV.DataSource = Nothing : ds1.Clear()
  20. 工廠_DGV.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  21. 工廠_DGV.ColumnHeadersHeight = 25
  22. 工廠_DGV.AllowUserToAddRows = False
  23. ConnOpen()
  24. SQL1 = "SELECT METOO選擇按鈕.選擇, QQ.生產工廠
  25. FROM METOO選擇按鈕 RIGHT OUTER JOIN
  26. (SELECT TOP (100) PERCENT 生產工廠 FROM 訂單控制表 WHERE (CXL = 0) AND (訂單數量 - 出貨數量 > 0)
  27. GROUP BY 生產工廠 ORDER BY 生產工廠) AS QQ ON METOO選擇按鈕.對應 = QQ.生產工廠"
  28. CmdSet_For_DGV() : da.Fill(ds1) : 工廠_DGV.DataSource = ds1.Tables(0) : conn.Close()
  29. 工廠_DGV.Columns(0).FillWeight = 30 : 工廠_DGV.Columns(1).FillWeight = 100
  30. For i As Integer = 0 To 工廠_DGV.Rows.Count - 1
  31. 工廠_DGV.Rows(i).Cells("選擇").Value = False
  32. Next
  33. End Sub
  34. Private Sub Set_訂單清單()
  35. DataGridView1.DataSource = Nothing : ds.Clear()
  36. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  37. DataGridView1.ColumnHeadersHeight = 25
  38. DataGridView1.AllowUserToAddRows = False
  39. ConnOpen()
  40. SQL1 = "SELECT 訂單明細表抬頭.下單日 AS 接單日, 訂單控制表.訂單流水號, 訂單控制表.客戶訂單號,
  41. 訂單控制表.GOODBOX AS 型體名稱, 訂單控制表.型體號碼, 訂單控制表.年份季度, 訂單控制表.TVW AS 楦型,
  42. 訂單控制表.APMA確認 AS 顏色, 訂單控制表.訂單數量, 訂單控制表.工廠回復交期 AS 最後交期, 訂單控制表.BUYER,
  43. 訂單控制表.材質, 訂單控制表.東莞業務備註, 訂單控制表.LEATHER AS 手剪全套, 訂單控制表.LEA_Note AS 斬刀全套,
  44. 訂單控制表.面料, 訂單控制表.副料, 訂單控制表.中底, 訂單控制表.鞋墊, 訂單控制表.大底, 訂單控制表.跟,
  45. 訂單控制表.包裝確認時間 AS 包裝, 訂單控制表.裁斷時間 AS 裁斷, 訂單控制表.針車時間 AS 針車,
  46. 訂單控制表.成型時間 AS 成形, 訂單控制表.驗貨時間 AS 驗貨, 訂單控制表.工廠進度表備註1 AS 驗貨結果,
  47. 訂單控制表.工廠進度表備註2 AS 工廠備註, 訂單控制表.驗貨報告圖片
  48. FROM 訂單控制表 LEFT OUTER JOIN
  49. 訂單明細表抬頭 ON 訂單控制表.客戶訂單號 = 訂單明細表抬頭.客戶訂單號 AND
  50. 訂單控制表.訂單流水號 = 訂單明細表抬頭.訂單流水號
  51. WHERE (訂單控制表.CXL = 0 OR
  52. 訂單控制表.CXL IS NULL) AND (訂單控制表.訂單數量 - 訂單控制表.出貨數量 <> 0) AND (訂單控制表.生產工廠 LIKE '" & ASS & "')
  53. ORDER BY 訂單控制表.訂單流水號 DESC, 訂單控制表.客戶交期1, 訂單控制表.型體號碼, 顏色, 楦型"
  54. CmdSet_For_DGV() : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  55. End Sub
  56. Private Sub 生產進度表列印_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  57. ASS = ""
  58. FormBorderStyle = FormBorderStyle.SizableToolWindow : ControlBox = False
  59. CheckBox1.Visible = False : CheckBox3.Visible = False : CheckBox6.Visible = False : CheckBox5.Visible = False : CheckBox4.Visible = False
  60. Set_工廠清單()
  61. End Sub
  62. Private Sub 工廠_DGV_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 工廠_DGV.CellClick
  63. If e.RowIndex = -1 Then : Else
  64. For i As Integer = 0 To 工廠_DGV.Rows.Count - 1
  65. If e.RowIndex = i Then
  66. 工廠_DGV.Rows(i).Cells("選擇").Value = True : ASS = 工廠_DGV.Rows(i).Cells("生產工廠").Value.ToString : Set_訂單清單()
  67. Else
  68. 工廠_DGV.Rows(i).Cells("選擇").Value = False
  69. End If
  70. Next
  71. End If
  72. End Sub
  73. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  74. If ASS <> "" Then
  75. xlApp = CType(CreateObject("Excel.Application"), Application)
  76. xlApp.Visible = True
  77. xlApp.DisplayAlerts = True
  78. xlApp.Application.WindowState = xlMaximized
  79. xlBook = xlApp.Workbooks.Add
  80. xlSheet = NewMethod(xlBook)
  81. xlApp.Sheets(1).Select
  82. xlBook.Activate() : xlSheet.Activate()
  83. xlApp.Sheets(1).Name = ASS
  84. xlSheet.Range("A1").Select()
  85. xlSheet.Cells(1, 13) = "淺藍色欄位為系統輸出,請勿做任何更改
  86. 淺綠色欄位為巨益辦公室填入"
  87. xlSheet.Cells(2, 14) = "量產樣品" : xlSheet.Cells(2, 16) = "PRODUCTION"
  88. xlSheet.Cells(3, 1) = "接單日" : xlSheet.Cells(3, 2) = "巨益PO#" : xlSheet.Cells(3, 3) = "客戶PO#" : xlSheet.Cells(3, 4) = "型體名稱"
  89. xlSheet.Cells(3, 5) = "型體號碼" : xlSheet.Cells(3, 6) = "年份季度" : xlSheet.Cells(3, 7) = "楦型" : xlSheet.Cells(3, 8) = "顏色"
  90. xlSheet.Cells(3, 9) = "訂單數" : xlSheet.Cells(3, 10) = "最後交期" : xlSheet.Cells(3, 11) = "BUYER" : xlSheet.Cells(3, 12) = "材質"
  91. xlSheet.Cells(3, 13) = "東莞業務備註" : xlSheet.Cells(3, 14) = "手剪全套" : xlSheet.Cells(3, 15) = "斬刀全套"
  92. xlSheet.Cells(3, 16) = "面料" : xlSheet.Cells(3, 17) = "副料" : xlSheet.Cells(3, 18) = "中底" : xlSheet.Cells(3, 19) = "鞋墊" : xlSheet.Cells(3, 20) = "大底"
  93. xlSheet.Cells(3, 21) = "跟" : xlSheet.Cells(3, 22) = "包裝" : xlSheet.Cells(3, 23) = "裁斷" : xlSheet.Cells(3, 24) = "針車" : xlSheet.Cells(3, 25) = "成型"
  94. xlSheet.Cells(3, 26) = "驗貨" : xlSheet.Cells(3, 27) = "驗貨結果" : xlSheet.Cells(3, 28) = "工廠備註"
  95. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  96. xlSheet.Cells(i + 4, 1) = DataGridView1.Rows(i).Cells("接單日").Value : xlSheet.Cells(i + 4, 2) = DataGridView1.Rows(i).Cells("訂單流水號").Value
  97. xlSheet.Cells(i + 4, 3) = DataGridView1.Rows(i).Cells("客戶訂單號").Value : xlSheet.Cells(i + 4, 4) = DataGridView1.Rows(i).Cells("型體名稱").Value
  98. xlSheet.Cells(i + 4, 5) = DataGridView1.Rows(i).Cells("型體號碼").Value : xlSheet.Cells(i + 4, 6) = DataGridView1.Rows(i).Cells("年份季度").Value
  99. xlSheet.Cells(i + 4, 7) = DataGridView1.Rows(i).Cells("楦型").Value : xlSheet.Cells(i + 4, 8) = DataGridView1.Rows(i).Cells("顏色").Value
  100. xlSheet.Cells(i + 4, 9) = DataGridView1.Rows(i).Cells("訂單數量").Value : xlSheet.Cells(i + 4, 10) = DataGridView1.Rows(i).Cells("最後交期").Value
  101. xlSheet.Cells(i + 4, 11) = DataGridView1.Rows(i).Cells("BUYER").Value
  102. xlSheet.Cells(i + 4, 12) = DataGridView1.Rows(i).Cells("材質").Value
  103. xlSheet.Cells(i + 4, 13) = DataGridView1.Rows(i).Cells("東莞業務備註").Value
  104. xlSheet.Cells(i + 4, 14) = DataGridView1.Rows(i).Cells("手剪全套").Value
  105. xlSheet.Cells(i + 4, 15) = DataGridView1.Rows(i).Cells("斬刀全套").Value
  106. xlSheet.Cells(i + 4, 16) = DataGridView1.Rows(i).Cells("面料").Value : xlSheet.Cells(i + 4, 17) = DataGridView1.Rows(i).Cells("副料").Value
  107. xlSheet.Cells(i + 4, 18) = DataGridView1.Rows(i).Cells("中底").Value : xlSheet.Cells(i + 4, 19) = DataGridView1.Rows(i).Cells("鞋墊").Value
  108. xlSheet.Cells(i + 4, 20) = DataGridView1.Rows(i).Cells("大底").Value : xlSheet.Cells(i + 4, 21) = DataGridView1.Rows(i).Cells("跟").Value
  109. xlSheet.Cells(i + 4, 22) = DataGridView1.Rows(i).Cells("包裝").Value : xlSheet.Cells(i + 4, 23) = DataGridView1.Rows(i).Cells("裁斷").Value
  110. xlSheet.Cells(i + 4, 24) = DataGridView1.Rows(i).Cells("針車").Value : xlSheet.Cells(i + 4, 25) = DataGridView1.Rows(i).Cells("成形").Value
  111. xlSheet.Cells(i + 4, 26) = DataGridView1.Rows(i).Cells("驗貨").Value : xlSheet.Cells(i + 4, 27) = DataGridView1.Rows(i).Cells("驗貨結果").Value
  112. xlSheet.Cells(i + 4, 28) = DataGridView1.Rows(i).Cells("工廠備註").Value
  113. With xlApp.Selection
  114. .Font.Bold = True
  115. End With
  116. N1 = i
  117. Next i
  118. BB(xlApp, xlSheet)
  119. xlSheet.Range("A4").Select()
  120. If xlApp.Sheets(2).Name = "工作表1" Then
  121. xlApp.Sheets("工作表1").Delete
  122. Else
  123. xlApp.Sheets("sheet1").Delete
  124. End If
  125. xlSheet.Cells(1, 1) = "巨益 量產進度管理表"
  126. xlSheet.PageSetup.PrintArea = ""
  127. xlApp.Cells.Select()
  128. xlApp.Application.WindowState = xlMinimized
  129. MsgBox("列印完成")
  130. Me.Close()
  131. Else
  132. MsgBox("請先選擇工廠")
  133. End If
  134. End Sub
  135. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  136. Me.Close()
  137. End Sub
  138. Private Shared Function NewMethod(xlBook As Microsoft.Office.Interop.Excel.Workbook) As Microsoft.Office.Interop.Excel.Worksheet
  139. Return CType(xlBook.Worksheets.Add, Worksheet)
  140. End Function
  141. Private Sub BB(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
  142. xlSheet.Cells.Select()
  143. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
  144. .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  145. xlSheet.Range("A1:L1").Select()
  146. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 24 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
  147. .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  148. xlSheet.Range("A2:A3").Select()
  149. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  150. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  151. xlSheet.Range("B2:B3").Select()
  152. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  153. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  154. xlSheet.Range("C2:C3").Select()
  155. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  156. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  157. xlSheet.Range("D2:D3").Select()
  158. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  159. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  160. xlSheet.Range("E2:E3").Select()
  161. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  162. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  163. xlSheet.Range("F2:F3").Select()
  164. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  165. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  166. xlSheet.Range("G2:G3").Select()
  167. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  168. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  169. xlSheet.Range("H2:H3").Select()
  170. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  171. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  172. xlSheet.Range("I2:I3").Select()
  173. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  174. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  175. xlSheet.Range("J2:J3").Select()
  176. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  177. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  178. xlSheet.Range("K2:K3").Select()
  179. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  180. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  181. xlSheet.Range("L2:L3").Select()
  182. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  183. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  184. xlSheet.Range("M2").Select()
  185. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  186. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  187. xlSheet.Range("N2:O2").Select()
  188. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  189. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  190. xlSheet.Range("P2:AB2").Select()
  191. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  192. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  193. xlSheet.Rows("2:3").Select
  194. With myExcel.Selection : .VerticalAlignment = xlTop : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  195. .ReadingOrder = xlContext : End With
  196. xlSheet.Rows("2:3").Select : myExcel.Selection.RowHeight = 25
  197. xlSheet.Rows("3:3").Select : myExcel.Selection.AutoFilter
  198. xlSheet.Rows("4:" & N1 + 5).Select
  199. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 9 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
  200. .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  201. With myExcel.Selection : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : End With
  202. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 9 : myExcel.Selection.NumberFormatLocal = "yyyy/mm/dd"
  203. With myExcel.Selection : .HorizontalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  204. .ReadingOrder = xlContext : End With
  205. xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 10
  206. With myExcel.Selection : .HorizontalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  207. .ReadingOrder = xlContext : End With
  208. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 11 : myExcel.Selection.NumberFormatLocal = "@"
  209. With myExcel.Selection : .HorizontalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  210. .ReadingOrder = xlContext : End With
  211. xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 11
  212. xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 10
  213. xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 9
  214. xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 5
  215. xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 10
  216. xlSheet.Columns("I:I").Select : myExcel.Selection.ColumnWidth = 6 : myExcel.Selection.NumberFormatLocal = "#,##0 "
  217. xlSheet.Columns("J:J").Select : myExcel.Selection.ColumnWidth = 9 : myExcel.Selection.NumberFormatLocal = "yyyy/mm/dd"
  218. With myExcel.Selection : .HorizontalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  219. .ReadingOrder = xlContext : End With
  220. xlSheet.Columns("K:K").Select : myExcel.Selection.ColumnWidth = 10
  221. xlSheet.Columns("L:L").Select : myExcel.Selection.ColumnWidth = 5
  222. xlSheet.Columns("M:M").Select : myExcel.Selection.ColumnWidth = 40
  223. xlSheet.Rows("4:" & N1 + 5).Select : myExcel.Selection.RowHeight = 40 : With myExcel.Selection : .WrapText = True : End With
  224. xlSheet.Columns("M:M").Select : myExcel.Selection.ColumnWidth = 12
  225. With myExcel.Selection : .HorizontalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  226. .ReadingOrder = xlContext : End With
  227. xlSheet.Columns("N:AA").Select : myExcel.Selection.ColumnWidth = 9
  228. xlSheet.Columns("N:N").Select
  229. With myExcel.Selection : .HorizontalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  230. .ReadingOrder = xlContext : End With
  231. xlSheet.Columns("O:O").Select
  232. With myExcel.Selection : .HorizontalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  233. .ReadingOrder = xlContext : End With
  234. xlSheet.Columns("M:AB").Select
  235. With myExcel.Selection : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : End With
  236. xlSheet.Columns("AB:AB").Select : myExcel.Selection.ColumnWidth = 9
  237. xlSheet.Range("A1:AB3").Select()
  238. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorDark1 : .TintAndShade = -0.249977111117893 : .PatternTintAndShade = 0 : End With
  239. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  240. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  241. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  242. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  243. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  244. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  245. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  246. xlSheet.Range("A4:K" & N1 + 5).Select()
  247. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  248. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  249. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  250. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  251. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  252. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  253. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  254. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
  255. xlSheet.Range("L4:M" & N1 + 5).Select()
  256. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  257. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  258. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  259. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  260. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  261. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  262. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  263. xlSheet.Columns("M:M").Select : myExcel.Selection.ColumnWidth = 40
  264. xlSheet.Range("L4:M" & N1 + 5).Select()
  265. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent6 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
  266. xlSheet.Range("N4:AB" & N1 + 5).Select()
  267. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  268. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  269. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  270. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  271. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  272. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  273. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  274. xlSheet.Range("A1:L1").Select()
  275. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  276. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  277. xlSheet.Range("M1:AB1").Select()
  278. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  279. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  280. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 40
  281. xlSheet.Range("M1:AB1").Select()
  282. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  283. .ReadingOrder = xlContext : .MergeCells = True : End With
  284. xlSheet.Range("L4").Select() : myExcel.ActiveWindow.FreezePanes = True
  285. myExcel.ActiveWindow.DisplayGridlines = False
  286. xlSheet.Range("M4:M" & N1 + 5).Select()
  287. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 7 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
  288. .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  289. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : End With
  290. xlSheet.Range("M1:AB1").Select() : With myExcel.Selection.Font : .Color = -16776961 : .TintAndShade = 0 : End With
  291. xlSheet.Range("M2:M3").Select() : myExcel.Selection.Merge
  292. End Sub
  293. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.Click
  294. If CheckBox1.Checked = True Then : CheckBox1.Checked = True
  295. CheckBox2.Checked = False : CheckBox3.Checked = False : CheckBox4.Checked = False : CheckBox5.Checked = False : CheckBox7.Checked = False : End If
  296. End Sub
  297. Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.Click
  298. If CheckBox2.Checked = True Then : CheckBox2.Checked = True
  299. CheckBox1.Checked = False : CheckBox3.Checked = False : CheckBox4.Checked = False : CheckBox6.Checked = False : CheckBox7.Checked = False : End If
  300. End Sub
  301. Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.Click
  302. If CheckBox3.Checked = True Then : CheckBox3.Checked = True
  303. CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox5.Checked = False : CheckBox6.Checked = False : CheckBox7.Checked = False : End If
  304. End Sub
  305. Private Sub CheckBox4_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox4.Click
  306. If CheckBox4.Checked = True Then : CheckBox4.Checked = True
  307. CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox5.Checked = False : CheckBox6.Checked = False : CheckBox7.Checked = False : End If
  308. End Sub
  309. Private Sub CheckBox5_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox5.Click
  310. If CheckBox5.Checked = True Then : CheckBox5.Checked = True
  311. CheckBox1.Checked = False : CheckBox3.Checked = False : CheckBox4.Checked = False : CheckBox6.Checked = False : CheckBox7.Checked = False : End If
  312. End Sub
  313. Private Sub CheckBox6_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox6.Click
  314. If CheckBox6.Checked = True Then : CheckBox6.Checked = True
  315. CheckBox2.Checked = False : CheckBox3.Checked = False : CheckBox4.Checked = False : CheckBox5.Checked = False : CheckBox7.Checked = False : End If
  316. End Sub
  317. Private Sub CheckBox7_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox7.Click
  318. If CheckBox7.Checked = True Then : CheckBox7.Checked = True
  319. CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = False : CheckBox4.Checked = False : CheckBox5.Checked = False : CheckBox6.Checked = False : End If
  320. End Sub
  321. End Class