Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

列印_樣品單_NEW.vb 51KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. Option Strict Off
  2. Imports System.IO
  3. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  4. Imports Microsoft.Office.Interop.Excel.Constants
  5. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  6. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  7. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  8. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  9. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  10. Imports Microsoft.Office.Interop.Excel.XlWindowState
  11. Imports System.Threading
  12. Imports Microsoft.Office.Interop.Excel
  13. Public Class 列印_樣品單_NEW
  14. Private ReadOnly ds, ds1, ds2, ds3, ds5 As New DataSet
  15. Dim N1, N2, N3, N4, N5, Q1 As Integer
  16. Dim AAA1, AAA2 As String
  17. Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
  18. Private Sub Set_清單()
  19. DataGridView1.DataSource = Nothing : ds.Clear()
  20. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  21. DataGridView1.ColumnHeadersHeight = 25
  22. DataGridView1.AllowUserToAddRows = False
  23. ConnOpen()
  24. SQL1 = "SELECT 樣品訂單控制表.SO, 樣品訂單控制表.季節, 樣品訂單控制表.客戶, 樣品訂單控制表.型體號碼,
  25. 樣品訂單控制表.型體名稱, 樣品訂單控制表.國家, 樣品訂單控制表.狀態, 樣品訂單控制表.ISS_DATE,
  26. 樣品訂單控制表.ETA, 樣品訂單控制表.數量, 樣品訂單控制表.制單人, LEFT(樣品訂單控制表.制單時間, 10)
  27. AS 制單時間, 樣品訂單控制表.版次, 樣品訂單控制表.工廠, 樣品訂單控制表.REQ, 樣品訂單控制表.C_N,
  28. 樣品訂單控制表.中底, 樣品訂單控制表.楦頭編號, 楦頭規格控制表.楦頭名, 模具開發控制表.模具編號,
  29. 模具開發控制表.CN
  30. FROM 樣品訂單控制表 LEFT OUTER JOIN 模具開發控制表 ON 樣品訂單控制表.模具編號 = 模具開發控制表.模具編號 LEFT OUTER JOIN
  31. 楦頭規格控制表 ON 樣品訂單控制表.楦頭編號 = 楦頭規格控制表.楦頭編號
  32. WHERE (樣品訂單控制表.SO LIKE N'" & 列印用SQL & "') AND (樣品訂單控制表.版次 LIKE N'" & 列印用SQL2 & "')
  33. GROUP BY 樣品訂單控制表.SO, 樣品訂單控制表.季節, 樣品訂單控制表.客戶, 樣品訂單控制表.型體號碼,
  34. 樣品訂單控制表.型體名稱, 樣品訂單控制表.國家, 樣品訂單控制表.狀態, 樣品訂單控制表.ISS_DATE,
  35. 樣品訂單控制表.ETA, 樣品訂單控制表.數量, 樣品訂單控制表.制單人, LEFT(樣品訂單控制表.制單時間, 10),
  36. 樣品訂單控制表.版次, 樣品訂單控制表.工廠, 樣品訂單控制表.REQ, 樣品訂單控制表.C_N, 樣品訂單控制表.中底,
  37. 樣品訂單控制表.楦頭編號, 楦頭規格控制表.楦頭名, 模具開發控制表.模具編號, 模具開發控制表.CN
  38. ORDER BY 樣品訂單控制表.SO DESC, 樣品訂單控制表.版次 DESC"
  39. CmdSet_For_DGV() : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  40. End Sub
  41. Private Sub Set_清單2()
  42. DataGridView2.DataSource = Nothing : ds1.Clear()
  43. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  44. DataGridView2.ColumnHeadersHeight = 25
  45. DataGridView2.AllowUserToAddRows = False
  46. ConnOpen()
  47. SQL1 = "SELECT 項次, 顏色, 架號, 數量, SIZE, KEEP, 流水號, 版次, 備註, 借出者 FROM 樣品訂單清單 WHERE (SO LIKE N'" & 列印用SQL & "' AND 版次 LIKE N'" & 列印用SQL2 & "') ORDER BY 項次"
  48. CmdSet_For_DGV() : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close()
  49. End Sub
  50. Private Sub Set_清單3()
  51. DataGridView3.DataSource = Nothing : ds2.Clear()
  52. DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  53. DataGridView3.ColumnHeadersHeight = 25
  54. DataGridView3.AllowUserToAddRows = False
  55. ConnOpen()
  56. SQL1 = "SELECT 部件 FROM 樣品訂單部件表 WHERE (SO LIKE N'" & 列印用SQL & "') AND (版次 LIKE N'" & 列印用SQL2 & "') GROUP BY 部件 ORDER BY 部件"
  57. CmdSet_For_DGV() : da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close()
  58. End Sub
  59. Private Sub Set_清單4()
  60. DataGridView4.DataSource = Nothing : ds3.Clear()
  61. DataGridView4.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  62. DataGridView4.ColumnHeadersHeight = 25
  63. DataGridView4.AllowUserToAddRows = False
  64. ConnOpen()
  65. SQL1 = "SELECT SO, 項次, 部件, 材料名稱, 材料說明, 備註, 廠商, 版次, 流水號 FROM 樣品訂單部件表 WHERE (SO LIKE N'" & 列印用SQL & "') AND (版次 LIKE N'" & 列印用SQL2 & "') ORDER BY 流水號, 部件"
  66. CmdSet_For_DGV() : da.Fill(ds3) : DataGridView4.DataSource = ds3.Tables(0) : conn.Close()
  67. End Sub
  68. Private Sub Set_清單5()
  69. DataGridView5.DataSource = Nothing : ds5.Clear()
  70. DataGridView5.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  71. DataGridView5.ColumnHeadersHeight = 25
  72. DataGridView5.AllowUserToAddRows = False
  73. ConnOpen()
  74. SQL1 = "SELECT 項次, 備註 FROM 樣品訂單清單 WHERE (SO LIKE N'" & 列印用SQL & "' AND 版次 LIKE N'" & 列印用SQL2 & "') ORDER BY 項次"
  75. CmdSet_For_DGV() : da.Fill(ds5) : DataGridView5.DataSource = ds5.Tables(0) : conn.Close()
  76. End Sub
  77. Private Sub 森康_cb_CheckedChanged(sender As Object, e As EventArgs) Handles 森康_cb.Click
  78. 森康_cb.Checked = True : 巨益_cb.Checked = False
  79. End Sub
  80. Private Sub 巨益_cb_CheckedChanged(sender As Object, e As EventArgs) Handles 巨益_cb.Click
  81. 森康_cb.Checked = False : 巨益_cb.Checked = True
  82. End Sub
  83. Private Sub 列印_樣品單_NEW_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  84. FormBorderStyle = FormBorderStyle.SizableToolWindow : ControlBox = False
  85. N1 = 0 : N2 = 0 : N3 = 0 : N4 = 0 : N5 = 0 : Q1 = 0 : AAA1 = "" : AAA2 = ""
  86. Set_清單() : Set_清單2() : Set_清單3() : Set_清單4() : Set_清單5()
  87. End Sub
  88. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles 取消列印_bt.Click
  89. 列印用SQL = "" : 列印用SQL2 = "" : Me.Close()
  90. End Sub
  91. Private Sub 列印1()
  92. If 森康_cb.Checked = True Then
  93. xlSheet.Cells(1, 1) = "森康鞋業有限公司 SenKang Footwear Ltd."
  94. Else
  95. xlSheet.Cells(1, 1) = "巨益貿易有限公司 WTL Co., Ltd."
  96. End If
  97. If DataGridView1.Rows(0).Cells("狀態").Value.ToString = "DEVELOPMENT" Then : xlSheet.Cells(1, 4) = "DEVELOPMENT SAMPLE ORDER (開發樣品單)"
  98. ElseIf DataGridView1.Rows(0).Cells("狀態").Value.ToString = "SALES" Then : xlSheet.Cells(1, 4) = "SALES SAMPLE ORDER (銷樣樣品單)"
  99. ElseIf DataGridView1.Rows(0).Cells("狀態").Value.ToString = "CONFIRMATION" Then : xlSheet.Cells(1, 4) = "CONFIRMATION SAMPLE ORDER (確認樣品單)"
  100. ElseIf DataGridView1.Rows(0).Cells("狀態").Value.ToString = "SHOW" Then : xlSheet.Cells(1, 4) = "SHOW SAMPLE ORDER (秀展樣品單)"
  101. ElseIf DataGridView1.Rows(0).Cells("狀態").Value.ToString = "TRIAL " Then : xlSheet.Cells(1, 4) = "TRIAL SAMPLE ORDER (試穿樣品單)"
  102. End If
  103. xlSheet.Cells(2, 1) = "廣東東莞市厚街鎮湖景大道南1號"
  104. If 森康_cb.Checked = True Then
  105. xlSheet.Cells(3, 1) = "TEL:0769-38937740"
  106. Else
  107. xlSheet.Cells(3, 1) = ""
  108. End If
  109. xlSheet.Cells(3, 4) = "PRINT DATE :" : xlSheet.Cells(3, 5) = "=TODAY()"
  110. xlSheet.Cells(5, 1) = "S/O # (單號) :" : xlSheet.Cells(6, 1) = "CUST (客戶) :" : xlSheet.Cells(7, 1) = "FACTORY (工廠) :" : xlSheet.Cells(8, 1) = "STYLE # (型體號) :"
  111. xlSheet.Cells(9, 1) = "STY.NAME (型體名) :" : xlSheet.Cells(10, 1) = "COUNTRY (國家) :" : xlSheet.Cells(11, 1) = "PURPOSE (目的) :" : xlSheet.Cells(12, 1) = "楦頭編號/模具編號 :"
  112. xlSheet.Cells(5, 2) = DataGridView1.Rows(0).Cells("SO").Value : xlSheet.Cells(6, 2) = DataGridView1.Rows(0).Cells("客戶").Value
  113. xlSheet.Cells(7, 2) = DataGridView1.Rows(0).Cells("工廠").Value : xlSheet.Cells(8, 2) = DataGridView1.Rows(0).Cells("型體號碼").Value
  114. xlSheet.Cells(9, 2) = DataGridView1.Rows(0).Cells("型體名稱").Value : xlSheet.Cells(10, 2) = DataGridView1.Rows(0).Cells("國家").Value
  115. xlSheet.Cells(11, 2) = DataGridView1.Rows(0).Cells("狀態").Value : xlSheet.Cells(12, 2) = DataGridView1.Rows(0).Cells("楦頭編號").Value & "/" & DataGridView1.Rows(0).Cells("模具編號").Value
  116. xlSheet.Cells(5, 3) = "EDITION (版次) :" : xlSheet.Cells(6, 3) = "SEASON (季節) :" : xlSheet.Cells(7, 3) = "ISS. DATE (制單日期) :" : xlSheet.Cells(8, 3) = "ETD (預計寄出日期) :"
  117. xlSheet.Cells(9, 3) = "REQ. BY :" : xlSheet.Cells(10, 3) = "INVOICE :" : xlSheet.Cells(11, 3) = "TOTAL (總數) :" : xlSheet.Cells(12, 3) = "Construction Name :"
  118. xlSheet.Cells(5, 4) = DataGridView1.Rows(0).Cells("版次").Value : xlSheet.Cells(6, 4) = DataGridView1.Rows(0).Cells("季節").Value
  119. xlSheet.Cells(7, 4) = DataGridView1.Rows(0).Cells("ISS_DATE").Value : xlSheet.Cells(8, 4) = DataGridView1.Rows(0).Cells("ETA").Value
  120. xlSheet.Cells(9, 4) = DataGridView1.Rows(0).Cells("REQ").Value : xlSheet.Cells(10, 4) = ""
  121. xlSheet.Cells(11, 4) = DataGridView1.Rows(0).Cells("數量").Value : xlSheet.Cells(12, 4) = DataGridView1.Rows(0).Cells("CN").Value
  122. ConnOpen()
  123. SQL1 = "SELECT 中皮, 結構 FROM 中皮結構 WHERE 底台 LIKE N'" & DataGridView1.Rows(0).Cells("C_N").Value & "'"
  124. CmdSet_For_dr()
  125. If dr.Read() Then : AAA1 = dr("中皮") : AAA2 = dr("結構") : End If : conn.Close()
  126. xlSheet.Cells(13, 1) = "中皮 : " & DataGridView1.Rows(0).Cells("C_N").Value : xlSheet.Cells(13, 2) = AAA1 : xlSheet.Cells(13, 4) = AAA2
  127. ConnOpen()
  128. SQL1 = "SELECT 做法 FROM 中底做法 WHERE 中底 LIKE N'" & DataGridView1.Rows(0).Cells("中底").Value & "'"
  129. CmdSet_For_dr()
  130. If dr.Read() Then : AAA1 = dr("做法") : End If : conn.Close()
  131. xlSheet.Cells(14, 1) = "中底 : " & DataGridView1.Rows(0).Cells("中底").Value : xlSheet.Cells(14, 2) = AAA1
  132. PictureBox1.Image = Nothing
  133. ConnOpen()
  134. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
  135. "WHERE 客戶 LIKE N'" & DataGridView1.Rows(0).Cells("客戶").Value & "' AND 形體號 LIKE N'" & DataGridView1.Rows(0).Cells("型體號碼").Value &
  136. "' AND 形體名 LIKE N'" & DataGridView1.Rows(0).Cells("型體名稱").Value & "' AND 類別 LIKE N'設計圖'"
  137. CmdSet_For_dr()
  138. If dr.Read() Then
  139. PictureBox1.Image = Nothing
  140. ConnOpen()
  141. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
  142. "WHERE 客戶 LIKE N'" & DataGridView1.Rows(0).Cells("客戶").Value & "' AND 形體號 LIKE N'" & DataGridView1.Rows(0).Cells("型體號碼").Value &
  143. "' AND 形體名 LIKE N'" & DataGridView1.Rows(0).Cells("型體名稱").Value & "' AND 類別 LIKE N'設計圖'"
  144. CmdSet_For_dr()
  145. While dr.Read() = True
  146. Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  147. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  148. End While
  149. conn.Close()
  150. Else
  151. PictureBox1.Image = Nothing
  152. ConnOpen()
  153. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
  154. "WHERE 客戶 LIKE N'" & DataGridView1.Rows(0).Cells("客戶").Value & "' AND 形體號 LIKE N'" & DataGridView1.Rows(0).Cells("型體號碼").Value & "'"
  155. CmdSet_For_dr()
  156. If dr.Read() Then
  157. PictureBox1.Image = Nothing
  158. ConnOpen()
  159. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
  160. "WHERE 客戶 LIKE N'" & DataGridView1.Rows(0).Cells("客戶").Value & "' AND 形體號 LIKE N'" & DataGridView1.Rows(0).Cells("型體號碼").Value & "'"
  161. CmdSet_For_dr()
  162. While dr.Read() = True
  163. Dim unused1 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  164. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  165. End While
  166. conn.Close()
  167. Else
  168. PictureBox1.Image = Nothing
  169. ConnOpen()
  170. SQL1 = "SELECT 圖片 FROM 鞋樣素描圖控制表 WHERE 型體編號 LIKE N'" & DataGridView1.Rows(0).Cells("型體號碼").Value & "'"
  171. CmdSet_For_dr()
  172. If dr.Read() Then
  173. PictureBox1.Image = Nothing
  174. ConnOpen()
  175. SQL1 = "SELECT 圖片 FROM 鞋樣素描圖控制表 WHERE 型體編號 LIKE N'" & DataGridView1.Rows(0).Cells("型體號碼").Value & "'"
  176. CmdSet_For_dr()
  177. While dr.Read() = True
  178. Dim unused2 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  179. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  180. End While
  181. conn.Close()
  182. Else
  183. conn.Close()
  184. End If
  185. End If
  186. End If : PictureBox1.SizeMode = 4
  187. For ii As Integer = 0 To 20 : If PictureBox1.Image Is Nothing Then : Thread.Sleep(100) : Else : AA(xlApp, xlSheet) : ii = 20 : End If : Next ii
  188. If PictureBox1.Image Is Nothing Then : xlSheet.Cells(5, 5) = "系統中無圖片" : End If
  189. xlSheet.Cells(16, 1) = "Color (顏色) :" : xlSheet.Cells(17, 1) = "QTY (數量) :" : xlSheet.Cells(18, 1) = "SIZE (尺寸) :"
  190. N1 = 0
  191. For i As Integer = 0 To DataGridView3.Rows.Count - 1
  192. xlSheet.Cells(i + 19, 1) = DataGridView3.Rows(i).Cells("部件").Value
  193. N1 = i
  194. Next
  195. BB(xlApp, xlSheet) : CC(xlApp, xlSheet)
  196. If N2 > DataGridView2.Rows.Count - 1 Then
  197. N3 = DataGridView2.Rows.Count - 1
  198. Else
  199. N3 = N2
  200. End If
  201. Dim QQAA, WWSS As String
  202. If N2 = 3 Then
  203. For i As Integer = 0 To N3
  204. xlSheet.Cells(16, i + 2) = DataGridView2.Rows(i).Cells("顏色").Value
  205. xlSheet.Cells(17, i + 2) = DataGridView2.Rows(i).Cells("數量").Value
  206. xlSheet.Cells(18, i + 2) = DataGridView2.Rows(i).Cells("SIZE").Value
  207. QQAA = DataGridView2.Rows(i).Cells("流水號").Value
  208. For ii As Integer = 0 To DataGridView3.Rows.Count - 1
  209. WWSS = DataGridView3.Rows(ii).Cells("部件").Value
  210. For iii As Integer = 0 To DataGridView4.Rows.Count - 1
  211. If QQAA = DataGridView4.Rows(iii).Cells("流水號").Value And WWSS = DataGridView4.Rows(iii).Cells("部件").Value Then
  212. If DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  213. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  214. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  215. "-" & DataGridView4.Rows(iii).Cells("材料說明").Value & "-" & DataGridView4.Rows(iii).Cells("備註").Value & "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  216. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  217. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  218. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  219. "-" & DataGridView4.Rows(iii).Cells("材料說明").Value & "-" & DataGridView4.Rows(iii).Cells("備註").Value
  220. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  221. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  222. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  223. "-" & DataGridView4.Rows(iii).Cells("材料說明").Value & "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  224. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  225. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  226. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  227. "-" & DataGridView4.Rows(iii).Cells("備註").Value & "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  228. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  229. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  230. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料說明").Value &
  231. "-" & DataGridView4.Rows(iii).Cells("備註").Value & "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  232. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  233. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  234. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  235. "-" & DataGridView4.Rows(iii).Cells("材料說明").Value
  236. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  237. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  238. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  239. "-" & DataGridView4.Rows(iii).Cells("備註").Value
  240. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  241. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  242. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料說明").Value &
  243. "-" & DataGridView4.Rows(iii).Cells("備註").Value
  244. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  245. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  246. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  247. "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  248. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  249. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  250. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料說明").Value &
  251. "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  252. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  253. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  254. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("備註").Value &
  255. "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  256. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  257. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  258. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value
  259. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  260. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  261. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("材料說明").Value
  262. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  263. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  264. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("備註").Value
  265. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  266. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  267. xlSheet.Cells(ii + 19, i + 2) = DataGridView4.Rows(iii).Cells("廠商").Value
  268. End If
  269. End If
  270. Next
  271. Next
  272. Next
  273. ElseIf N2 > 3 Then
  274. N4 = 0
  275. For i As Integer = 4 To N3
  276. xlSheet.Cells(16, N4 + 2) = DataGridView2.Rows(i).Cells("顏色").Value
  277. xlSheet.Cells(17, N4 + 2) = DataGridView2.Rows(i).Cells("數量").Value
  278. xlSheet.Cells(18, N4 + 2) = DataGridView2.Rows(i).Cells("SIZE").Value
  279. QQAA = DataGridView2.Rows(i).Cells("流水號").Value
  280. For ii As Integer = 0 To DataGridView3.Rows.Count - 1
  281. WWSS = DataGridView3.Rows(ii).Cells("部件").Value
  282. For iii As Integer = 0 To DataGridView4.Rows.Count - 1
  283. If QQAA = DataGridView4.Rows(iii).Cells("流水號").Value And WWSS = DataGridView4.Rows(iii).Cells("部件").Value Then
  284. If DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  285. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  286. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  287. "-" & DataGridView4.Rows(iii).Cells("材料說明").Value & "-" & DataGridView4.Rows(iii).Cells("備註").Value & "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  288. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  289. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  290. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  291. "-" & DataGridView4.Rows(iii).Cells("材料說明").Value & "-" & DataGridView4.Rows(iii).Cells("備註").Value
  292. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  293. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  294. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  295. "-" & DataGridView4.Rows(iii).Cells("材料說明").Value & "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  296. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  297. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  298. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  299. "-" & DataGridView4.Rows(iii).Cells("備註").Value & "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  300. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  301. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  302. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料說明").Value &
  303. "-" & DataGridView4.Rows(iii).Cells("備註").Value & "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  304. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  305. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  306. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  307. "-" & DataGridView4.Rows(iii).Cells("材料說明").Value
  308. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  309. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  310. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  311. "-" & DataGridView4.Rows(iii).Cells("備註").Value
  312. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  313. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  314. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料說明").Value &
  315. "-" & DataGridView4.Rows(iii).Cells("備註").Value
  316. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  317. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  318. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value &
  319. "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  320. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  321. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  322. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料說明").Value &
  323. "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  324. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  325. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  326. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("備註").Value &
  327. "-" & DataGridView4.Rows(iii).Cells("廠商").Value
  328. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  329. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  330. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料名稱").Value
  331. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString <> "" And
  332. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  333. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("材料說明").Value
  334. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  335. DataGridView4.Rows(iii).Cells("備註").Value.ToString <> "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString = "" Then
  336. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("備註").Value
  337. ElseIf DataGridView4.Rows(iii).Cells("材料名稱").Value.ToString = "" And DataGridView4.Rows(iii).Cells("材料說明").Value.ToString = "" And
  338. DataGridView4.Rows(iii).Cells("備註").Value.ToString = "" And DataGridView4.Rows(iii).Cells("廠商").Value.ToString <> "" Then
  339. xlSheet.Cells(ii + 19, N4 + 2) = DataGridView4.Rows(iii).Cells("廠商").Value
  340. End If
  341. End If
  342. Next
  343. Next
  344. N4 += 1
  345. Next
  346. End If
  347. For i As Integer = 0 To DataGridView5.Rows.Count - 1
  348. xlSheet.Cells(N1 + 20 + i, 1) = "備註" & i + 1 & ":"
  349. xlSheet.Cells(N1 + 20 + i, 2) = DataGridView5.Rows(i).Cells("備註").Value.ToString
  350. N5 = N1 + 20 + i
  351. Next
  352. FF(xlApp, xlSheet) : DD(xlApp, xlSheet)
  353. End Sub
  354. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles 確認列印_bt.Click
  355. If 森康_cb.Checked = False And 巨益_cb.Checked = False Then
  356. MsgBox("請先選擇抬頭!!")
  357. Else
  358. xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
  359. xlBook = xlApp.Workbooks.Add
  360. xlApp.DisplayAlerts = True
  361. xlApp.Visible = True
  362. xlApp.Application.WindowState = xlMaximized
  363. N2 = 0
  364. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  365. If i = 0 Then : xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = "第一頁" : N2 = 3 : xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
  366. ElseIf i = 4 Then : xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = "第二頁" : N2 = 7 : xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
  367. ElseIf i = 8 Then : xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = "第三頁" : N2 = 11 : xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
  368. ElseIf i = 12 Then : xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = "第四頁" : N2 = 15 : xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
  369. End If
  370. Next
  371. xlSheet.PageSetup.PrintArea = ""
  372. xlApp.Cells.Select()
  373. xlSheet.Range("B1").Select()
  374. xlApp.Application.WindowState = xlMinimized
  375. MsgBox("列印完成")
  376. Me.Close()
  377. End If
  378. End Sub
  379. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  380. Return CType(xlBook.Worksheets.Add, Worksheet)
  381. End Function
  382. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  383. Clipboard.SetDataObject(PictureBox1.Image)
  384. xlSheet.Cells(1, 1).Select
  385. Thread.Sleep(100) '延迟0.1秒
  386. xlSheet.Range("E5").Select()
  387. myExcel.ActiveSheet.Paste
  388. If PictureBox1.Image.Height < PictureBox1.Image.Width Then
  389. myExcel.Selection.ShapeRange.Width = 120
  390. Else
  391. myExcel.Selection.ShapeRange.Height = 120
  392. End If
  393. myExcel.Selection.ShapeRange.IncrementLeft(2)
  394. myExcel.Selection.ShapeRange.IncrementTop(2)
  395. End Sub
  396. Private Sub BB(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  397. xlSheet.Cells.Select()
  398. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  399. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  400. xlSheet.Columns("A:E").Select : myExcel.Selection.ColumnWidth = 30
  401. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  402. .ReadingOrder = xlContext : .MergeCells = False : End With
  403. xlSheet.Range("A1:C1").Select()
  404. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  405. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  406. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 20 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  407. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  408. xlSheet.Range("D1:E1").Select()
  409. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  410. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  411. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 16 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  412. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  413. xlSheet.Range("A2:C2").Select()
  414. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  415. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  416. xlSheet.Range("A3:C3").Select()
  417. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  418. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  419. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 35 : xlSheet.Rows("2:3").Select : myExcel.Selection.RowHeight = 20
  420. xlSheet.Rows("4:4").Select : myExcel.Selection.RowHeight = 5 : xlSheet.Rows("5:12").Select : myExcel.Selection.RowHeight = 20
  421. xlSheet.Rows("13:13").Select : myExcel.Selection.RowHeight = 45 : xlSheet.Rows("14:14").Select : myExcel.Selection.RowHeight = 20
  422. xlSheet.Range("A3:E3").Select()
  423. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  424. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  425. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  426. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  427. xlSheet.Range("A12:E14").Select()
  428. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  429. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  430. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  431. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  432. xlSheet.Range("E5:E12").Select()
  433. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  434. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  435. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  436. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  437. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  438. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  439. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  440. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  441. xlSheet.Rows("15:15").Select : myExcel.Selection.RowHeight = 5
  442. xlSheet.Range("A5:A12").Select()
  443. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0
  444. End With
  445. xlSheet.Range("C5:C13").Select()
  446. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
  447. myExcel.ActiveWindow.DisplayGridlines = False
  448. xlSheet.Range("B13:C13").Select()
  449. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  450. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  451. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  452. .ReadingOrder = xlContext : .MergeCells = True : End With
  453. xlSheet.Range("D13:E13").Select()
  454. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  455. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  456. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  457. .ReadingOrder = xlContext : .MergeCells = True : End With
  458. xlSheet.Range("B14:E14").Select()
  459. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  460. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  461. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  462. .ReadingOrder = xlContext : .MergeCells = True : End With
  463. xlSheet.Range("A13:E14").Select()
  464. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  465. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  466. End With
  467. xlSheet.Range("A13").Select()
  468. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  469. .ReadingOrder = xlContext : .MergeCells = False
  470. End With
  471. End Sub
  472. Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  473. xlSheet.Rows("16:16").Select : myExcel.Selection.RowHeight = 30
  474. xlSheet.Rows("17:18").Select : myExcel.Selection.RowHeight = 20
  475. xlSheet.Rows("19:" & N1 + 19).Select : myExcel.Selection.RowHeight = 60
  476. xlSheet.Range("A16:E" & N1 + 19).Select()
  477. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  478. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  479. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  480. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  481. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  482. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  483. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  484. xlSheet.Range("B16:E16").Select()
  485. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent2 : .TintAndShade = 0.599993896298105 : .PatternTintAndShade = 0 : End With
  486. xlSheet.Range("A16:A" & N1 + 19).Select()
  487. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .Color = 65535 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
  488. End Sub
  489. Private Sub FF(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  490. xlSheet.Rows(N1 + 20 & ":" & N5).Select : myExcel.Selection.RowHeight = 30
  491. xlSheet.Range("A" & N1 + 20 & ":E" & N5).Select() : myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  492. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  493. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  494. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  495. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  496. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  497. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  498. xlSheet.Range("A" & N1 + 20 & ":A" & N5).Select()
  499. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  500. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  501. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.599993896298105 : .PatternTintAndShade = 0 : End With
  502. For I As Integer = N1 + 20 To N5
  503. xlSheet.Range("B" & I & ":E" & I).Select()
  504. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  505. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  506. Next
  507. xlSheet.Range("B" & N1 + 20 & ":E" & N5).Select()
  508. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  509. .ReadingOrder = xlContext : End With
  510. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  511. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  512. End Sub
  513. Private Sub DD(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  514. xlSheet.Range("B19:E" & N1 + 19).Select()
  515. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  516. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  517. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
  518. .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  519. myExcel.Application.PrintCommunication = False
  520. With myExcel.ActiveSheet.PageSetup
  521. .PrintTitleRows = ""
  522. .PrintTitleColumns = ""
  523. End With
  524. myExcel.Application.PrintCommunication = True
  525. myExcel.ActiveSheet.PageSetup.PrintArea = ""
  526. myExcel.Application.PrintCommunication = False
  527. With myExcel.ActiveSheet.PageSetup
  528. .LeftHeader = ""
  529. .CenterHeader = ""
  530. .RightHeader = ""
  531. .LeftFooter = ""
  532. .CenterFooter = ""
  533. .RightFooter = ""
  534. .LeftMargin = myExcel.Application.InchesToPoints(0.25)
  535. .RightMargin = myExcel.Application.InchesToPoints(0.25)
  536. .TopMargin = myExcel.Application.InchesToPoints(0.75)
  537. .BottomMargin = myExcel.Application.InchesToPoints(0.75)
  538. .HeaderMargin = myExcel.Application.InchesToPoints(0.3)
  539. .FooterMargin = myExcel.Application.InchesToPoints(0.3)
  540. .PrintHeadings = False
  541. .PrintGridlines = False
  542. ' .PrintQuality = 600
  543. .CenterHorizontally = False
  544. .CenterVertically = False
  545. .Draft = False
  546. .FirstPageNumber = xlAutomatic
  547. .BlackAndWhite = False
  548. .Zoom = False
  549. .FitToPagesWide = 1
  550. .FitToPagesTall = 1
  551. .OddAndEvenPagesHeaderFooter = False
  552. .DifferentFirstPageHeaderFooter = False
  553. .ScaleWithDocHeaderFooter = True
  554. .AlignMarginsHeaderFooter = True
  555. .EvenPage.LeftHeader.Text = ""
  556. .EvenPage.CenterHeader.Text = ""
  557. .EvenPage.RightHeader.Text = ""
  558. .EvenPage.LeftFooter.Text = ""
  559. .EvenPage.CenterFooter.Text = ""
  560. .EvenPage.RightFooter.Text = ""
  561. .FirstPage.LeftHeader.Text = ""
  562. .FirstPage.CenterHeader.Text = ""
  563. .FirstPage.RightHeader.Text = ""
  564. .FirstPage.LeftFooter.Text = ""
  565. .FirstPage.CenterFooter.Text = ""
  566. .FirstPage.RightFooter.Text = ""
  567. End With
  568. myExcel.Application.PrintCommunication = True
  569. End Sub
  570. End Class