Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

列印_樣品單_NEW.vb 53KB

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