No Description
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.

列印_樣品單_NEW.vb 50KB

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