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

簽呈.vb 44KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012
  1. Option Strict Off
  2. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  3. Imports Microsoft.Office.Interop.Excel.Constants
  4. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  5. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  6. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  7. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  8. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  9. Imports Microsoft.Office.Interop.Excel.XlWindowState
  10. Imports Microsoft.Office.Interop.Excel
  11. Imports System.Text.RegularExpressions
  12. Imports System.IO
  13. Public Class 簽呈
  14. Dim xlApp As Microsoft.Office.Interop.Excel.Application
  15. Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  16. Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  17. Dim 位置1 As String
  18. Dim N2 As Integer : Dim N3 As Integer
  19. ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet
  20. Private Sub 簽呈_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  21. Me.MdiParent = ICS_ASMS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  22. ComboBox1.Items.Add("")
  23. ComboBox2.Items.Add("")
  24. ComboBox3.Items.Add("")
  25. ComboBox4.Items.Add("")
  26. ComboBox5.Items.Add("")
  27. ComboBox6.Items.Add("")
  28. ComboBox7.Items.Add("")
  29. SQL_簽呈_公司稱謂()
  30. While (dr.Read())
  31. ComboBox1.Items.Add(dr("編號一")) : ComboBox1.Items.Add(dr("編號二")) : ComboBox1.Items.Add(dr("編號三"))
  32. ComboBox1.Items.Add(dr("編號四")) : ComboBox1.Items.Add(dr("編號五")) : ComboBox1.Items.Add(dr("編號六")) : ComboBox1.Items.Add(dr("編號七"))
  33. ComboBox2.Items.Add(dr("編號一")) : ComboBox2.Items.Add(dr("編號二")) : ComboBox2.Items.Add(dr("編號三"))
  34. ComboBox2.Items.Add(dr("編號四")) : ComboBox2.Items.Add(dr("編號五")) : ComboBox2.Items.Add(dr("編號六")) : ComboBox2.Items.Add(dr("編號七"))
  35. ComboBox3.Items.Add(dr("編號一")) : ComboBox3.Items.Add(dr("編號二")) : ComboBox3.Items.Add(dr("編號三"))
  36. ComboBox3.Items.Add(dr("編號四")) : ComboBox3.Items.Add(dr("編號五")) : ComboBox3.Items.Add(dr("編號六")) : ComboBox3.Items.Add(dr("編號七"))
  37. ComboBox4.Items.Add(dr("編號一")) : ComboBox4.Items.Add(dr("編號二")) : ComboBox4.Items.Add(dr("編號三"))
  38. ComboBox4.Items.Add(dr("編號四")) : ComboBox4.Items.Add(dr("編號五")) : ComboBox4.Items.Add(dr("編號六")) : ComboBox4.Items.Add(dr("編號七"))
  39. ComboBox5.Items.Add(dr("編號一")) : ComboBox5.Items.Add(dr("編號二")) : ComboBox5.Items.Add(dr("編號三"))
  40. ComboBox5.Items.Add(dr("編號四")) : ComboBox5.Items.Add(dr("編號五")) : ComboBox5.Items.Add(dr("編號六")) : ComboBox5.Items.Add(dr("編號七"))
  41. ComboBox6.Items.Add(dr("編號一")) : ComboBox6.Items.Add(dr("編號二")) : ComboBox6.Items.Add(dr("編號三"))
  42. ComboBox6.Items.Add(dr("編號四")) : ComboBox6.Items.Add(dr("編號五")) : ComboBox6.Items.Add(dr("編號六")) : ComboBox6.Items.Add(dr("編號七"))
  43. ComboBox7.Items.Add(dr("編號一")) : ComboBox7.Items.Add(dr("編號二")) : ComboBox7.Items.Add(dr("編號三"))
  44. ComboBox7.Items.Add(dr("編號四")) : ComboBox7.Items.Add(dr("編號五")) : ComboBox7.Items.Add(dr("編號六")) : ComboBox7.Items.Add(dr("編號七"))
  45. ComboBox1.Text = dr("編號一")
  46. ComboBox2.Text = dr("編號二")
  47. ComboBox3.Text = dr("編號三")
  48. ComboBox4.Text = dr("編號四")
  49. ComboBox5.Text = dr("編號五")
  50. ComboBox6.Text = dr("編號六")
  51. ComboBox7.Text = dr("編號七")
  52. End While : conn.Close()
  53. SQL_讀取公司資料()
  54. If dr.Read() Then
  55. 公司名稱.Text = dr("公司名稱")
  56. End If
  57. conn.Close()
  58. 已核准的營運成本收支單_rb.Checked = True
  59. 作廢的營運成本收支單_rb.Checked = False
  60. Set_清單1()
  61. 刪除_bt.Enabled = False : 儲存_bt.Enabled = False : 作廢_bt.Enabled = False : 列印_bt.Enabled = False
  62. End Sub
  63. Private Sub Set_清單1()
  64. 控制表_dgv.DataSource = Nothing : ds1.Clear()
  65. 控制表_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  66. 控制表_dgv.ColumnHeadersHeight = 25
  67. 控制表_dgv.AllowUserToAddRows = False
  68. 控制表_dgv.RowTemplate.Height = 30
  69. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  70. If 作廢的營運成本收支單_rb.Checked = True And 已核准的營運成本收支單_rb.Checked = False Then
  71. SQL_簽呈_控制表清單1()
  72. ElseIf 作廢的營運成本收支單_rb.Checked = False And 已核准的營運成本收支單_rb.Checked = True Then
  73. SQL_簽呈_控制表清單()
  74. End If
  75. da.Fill(ds1) : 控制表_dgv.DataSource = ds1.Tables(0) : conn.Close()
  76. 控制表_dgv.Columns(0).FillWeight = 30 : 控制表_dgv.Columns(1).FillWeight = 70 : 控制表_dgv.Columns(2).Visible = False
  77. 控制表_dgv.Columns(3).Visible = False : 控制表_dgv.Columns(4).Visible = False : 控制表_dgv.Columns(5).Visible = False
  78. 控制表_dgv.Columns(6).Visible = False : 控制表_dgv.Columns(7).Visible = False : 控制表_dgv.Columns(8).Visible = False
  79. 控制表_dgv.Columns(9).Visible = False : 控制表_dgv.Columns(10).Visible = False : 控制表_dgv.Columns(11).Visible = False
  80. 控制表_dgv.Columns(12).Visible = False : 控制表_dgv.Columns(13).Visible = False : 控制表_dgv.Columns(14).Visible = False
  81. 控制表_dgv.Columns(15).Visible = False : 控制表_dgv.Columns(16).Visible = False
  82. End Sub
  83. Private Sub 控制表_dgv_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles 控制表_dgv.CellClick
  84. If e.RowIndex = -1 Then : Else
  85. 單號_tb.Text = 控制表_dgv(2, e.RowIndex).Value.ToString
  86. Dim dateString As String = 控制表_dgv(0, e.RowIndex).Value.ToString
  87. Dim dateParts() As String = dateString.Split("/"c)
  88. Dim year As Integer = Integer.Parse(dateParts(0)) + 1911 ' 將民國年轉換為西元年
  89. Dim month As Integer = Integer.Parse(dateParts(1))
  90. Dim day As Integer = Integer.Parse(dateParts(2))
  91. Dim dateTime As New DateTime(year, month, day)
  92. 選擇日期_dtp.Value = dateTime
  93. 選擇日期_dtp.CustomFormat = "yyyy/MM/dd"
  94. 選擇日期_dtp.Format = DateTimePickerFormat.Custom
  95. 檔案名稱_tb.Text = 控制表_dgv(1, e.RowIndex).Value.ToString
  96. 主旨_tb.Text = 控制表_dgv(3, e.RowIndex).Value.ToString
  97. 說明_rtb.Text = 控制表_dgv(4, e.RowIndex).Value.ToString
  98. 擬辦_tb.Text = 控制表_dgv(5, e.RowIndex).Value.ToString
  99. 開單人_tb.Text = 控制表_dgv(15, e.RowIndex).Value.ToString
  100. 標題_tb.Text = 控制表_dgv(16, e.RowIndex).Value.ToString
  101. ComboBox1.Text = 控制表_dgv(6, e.RowIndex).Value.ToString
  102. ComboBox2.Text = 控制表_dgv(7, e.RowIndex).Value.ToString
  103. ComboBox3.Text = 控制表_dgv(8, e.RowIndex).Value.ToString
  104. ComboBox4.Text = 控制表_dgv(9, e.RowIndex).Value.ToString
  105. ComboBox5.Text = 控制表_dgv(10, e.RowIndex).Value.ToString
  106. ComboBox6.Text = 控制表_dgv(11, e.RowIndex).Value.ToString
  107. ComboBox7.Text = 控制表_dgv(12, e.RowIndex).Value.ToString
  108. If 登入人級別 <> "00" Then
  109. If 控制表_dgv(14, e.RowIndex).Value = True Then
  110. 刪除_bt.Enabled = False : 儲存_bt.Enabled = False : 作廢_bt.Enabled = False : 列印_bt.Enabled = True : 新增_bt.Enabled = True
  111. ElseIf 控制表_dgv(13, e.RowIndex).Value = True And 控制表_dgv(14, e.RowIndex).Value = False Then
  112. 刪除_bt.Enabled = False : 儲存_bt.Enabled = False : 作廢_bt.Enabled = True : 列印_bt.Enabled = True : 新增_bt.Enabled = True
  113. ElseIf 控制表_dgv(13, e.RowIndex).Value = False And 控制表_dgv(14, e.RowIndex).Value = False Then
  114. 刪除_bt.Enabled = True : 儲存_bt.Enabled = True : 作廢_bt.Enabled = True : 列印_bt.Enabled = True : 新增_bt.Enabled = True
  115. End If
  116. Else
  117. 刪除_bt.Enabled = True : 儲存_bt.Enabled = True : 作廢_bt.Enabled = True : 列印_bt.Enabled = True : 新增_bt.Enabled = True
  118. End If
  119. End If
  120. End Sub
  121. Private Sub 查詢_tb_Click(sender As Object, e As EventArgs) Handles 查詢_tb.Click
  122. PA56 = InputBox("請輸入要查詢的單號資料。") : Set_清單1() : PA56 = ""
  123. End Sub
  124. Private Sub 新增_bt_Click(sender As Object, e As EventArgs) Handles 新增_bt.Click
  125. 單號_tb.Text = "" : 檔案名稱_tb.Text = "" : 主旨_tb.Text = "" : 說明_rtb.Text = "" : 擬辦_tb.Text = ""
  126. ComboBox1.Text = "" : ComboBox2.Text = "" : ComboBox3.Text = "" : ComboBox4.Text = ""
  127. ComboBox5.Text = "" : ComboBox6.Text = "" : ComboBox7.Text = "" : 開單人_tb.Text = gUserName : 標題_tb.Text = ""
  128. Dim NUM1 As Integer
  129. Dim selectedDate As DateTime = 選擇日期_dtp.Value
  130. Dim taiwanYear As Integer = selectedDate.Year - 1911
  131. Dim str As String = String.Format("{0}{1:00}{2:00}", taiwanYear, selectedDate.Month, selectedDate.Day)
  132. PA1 = String.Format("{0}/{1:00}/{2:00}", taiwanYear, selectedDate.Month, selectedDate.Day)
  133. For i As Integer = 1 To 999
  134. NUM1 = 0 + i
  135. If NUM1 < 10 Then : 單號_tb.Text = str & "0" & NUM1
  136. ElseIf NUM1 > 9 Then : 單號_tb.Text = str & NUM1
  137. End If
  138. conn.Close()
  139. PA = 單號_tb.Text
  140. SQL_簽呈_查詢第一筆單號()
  141. If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
  142. Next
  143. PA = 單號_tb.Text
  144. SQL_簽呈_新增一筆公函控制表() : conn.Close()
  145. 刪除_bt.Enabled = True : 儲存_bt.Enabled = True : 作廢_bt.Enabled = False : 列印_bt.Enabled = False : 新增_bt.Enabled = False
  146. End Sub
  147. Private Sub 刪除_bt_Click(sender As Object, e As EventArgs) Handles 刪除_bt.Click
  148. SQL_簽呈_控制表刪除() : conn.Close() : MsgBox("刪除成功!!")
  149. 單號_tb.Text = "" : 檔案名稱_tb.Text = "" : 主旨_tb.Text = "" : 說明_rtb.Text = "" : 擬辦_tb.Text = ""
  150. ComboBox1.Text = "" : ComboBox2.Text = "" : ComboBox3.Text = "" : ComboBox4.Text = "" : 開單人_tb.Text = "" : 標題_tb.Text = ""
  151. ComboBox5.Text = "" : ComboBox6.Text = "" : ComboBox7.Text = "" : Set_清單1()
  152. 刪除_bt.Enabled = False : 儲存_bt.Enabled = False : 作廢_bt.Enabled = False : 列印_bt.Enabled = False : 新增_bt.Enabled = True
  153. End Sub
  154. Private Sub 儲存_bt_Click(sender As Object, e As EventArgs) Handles 儲存_bt.Click
  155. If 開單人_tb.Text = gUserName Or 登入人級別 = "00" Then
  156. Dim str As String = 檔案名稱_tb.Text
  157. str = Regex.Replace(str, "[^a-zA-Z0-9]", "")
  158. 檔案名稱_tb.Text = str
  159. SQL_簽呈_控制表修改() : conn.Close() : MsgBox("儲存成功!!") : Set_清單1()
  160. If 登入人級別 <> "00" Then
  161. 刪除_bt.Enabled = True : 儲存_bt.Enabled = True : 作廢_bt.Enabled = True : 列印_bt.Enabled = True : 新增_bt.Enabled = True
  162. End If
  163. Else
  164. MsgBox("請確認開單人是否為本人")
  165. End If
  166. End Sub
  167. Private Sub 作廢_bt_Click(sender As Object, e As EventArgs) Handles 作廢_bt.Click
  168. SQL_簽呈_控制表作廢() : conn.Close() : MsgBox("作廢成功!!") : Set_清單1()
  169. 刪除_bt.Enabled = False : 儲存_bt.Enabled = False : 作廢_bt.Enabled = False : 列印_bt.Enabled = True
  170. End Sub
  171. Private Sub 作廢的營運成本收支單_rb_CheckedChanged(sender As Object, e As EventArgs) Handles 作廢的營運成本收支單_rb.Click
  172. 作廢的營運成本收支單_rb.Checked = True : 已核准的營運成本收支單_rb.Checked = False
  173. Set_清單1()
  174. End Sub
  175. Private Sub 已核准的營運成本收支單_rb_CheckedChanged(sender As Object, e As EventArgs) Handles 已核准的營運成本收支單_rb.Click
  176. 作廢的營運成本收支單_rb.Checked = False : 已核准的營運成本收支單_rb.Checked = True
  177. Set_清單1()
  178. End Sub
  179. Private Sub 查詢_tb_MouseEnter(sender As Object, e As EventArgs) Handles 查詢_tb.MouseEnter
  180. ToolTip1.SetToolTip(Me.查詢_tb, "關鍵字搜尋")
  181. End Sub
  182. Private Sub 新增_bt_MouseEnter(sender As Object, e As EventArgs) Handles 新增_bt.MouseEnter
  183. ToolTip1.SetToolTip(Me.新增_bt, "新增")
  184. End Sub
  185. Private Sub 確認新增_bt_MouseEnter(sender As Object, e As EventArgs) Handles 儲存_bt.MouseEnter
  186. ToolTip1.SetToolTip(Me.儲存_bt, "儲存")
  187. End Sub
  188. Private Sub 修改_bt_MouseEnter(sender As Object, e As EventArgs) Handles 作廢_bt.MouseEnter
  189. ToolTip1.SetToolTip(Me.作廢_bt, "作廢")
  190. End Sub
  191. Private Sub 刪除_bt_MouseEnter(sender As Object, e As EventArgs) Handles 刪除_bt.MouseEnter
  192. ToolTip1.SetToolTip(Me.刪除_bt, "刪除")
  193. End Sub
  194. Private Sub 匯出EXCEL_bt_MouseEnter(sender As Object, e As EventArgs) Handles 列印_bt.MouseEnter
  195. ToolTip1.SetToolTip(Me.列印_bt, "匯出PDF")
  196. End Sub
  197. Private Sub 字體_NUD_ValueChanged(sender As Object, e As EventArgs) Handles 字體_NUD.ValueChanged
  198. 主旨_tb.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
  199. 說明_rtb.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
  200. 擬辦_tb.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
  201. End Sub
  202. Private Sub 列印_bt_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click
  203. SQL_簽呈_控制表鎖定() : conn.Close()
  204. If 登入人級別 <> "00" Then
  205. 刪除_bt.Enabled = False : 儲存_bt.Enabled = False : 作廢_bt.Enabled = True : 列印_bt.Enabled = True : 新增_bt.Enabled = True
  206. End If
  207. Set_清單1()
  208. xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
  209. xlApp.Visible = True
  210. xlApp.DisplayAlerts = True
  211. xlApp.Application.WindowState = xlMaximized
  212. xlBook = xlApp.Workbooks.Add
  213. xlSheet = NewMethod(xlBook)
  214. xlBook.Activate()
  215. xlSheet.Activate()
  216. xlSheet.Cells(1, 1) = "簽" : xlSheet.Cells(1, 2) = 標題_tb.Text
  217. Dim selectedDate As DateTime = 選擇日期_dtp.Value
  218. Dim taiwanYear As Integer = selectedDate.Year - 1911
  219. xlSheet.Cells(1, 8) = taiwanYear & "年" & selectedDate.Month & "月" & selectedDate.Day & "日"
  220. xlSheet.Cells(2, 1) = "主旨:" : xlSheet.Cells(2, 2) = 主旨_tb.Text : xlSheet.Cells(2, 9) = 主旨_tb.Text
  221. xlSheet.Cells(3, 1) = "說明:"
  222. Dim lines As New List(Of String)()
  223. Dim text As String = 說明_rtb.Text
  224. lines.Clear()
  225. ' 使用 Graphics.MeasureString 测量文本的宽度
  226. Using g As Graphics = CreateGraphics()
  227. Dim currentLine As String = ""
  228. For Each c As Char In text
  229. If c = ControlChars.Lf Then
  230. ' 如果遇到换行符号,添加一个新的段落
  231. lines.Add(currentLine)
  232. currentLine = ""
  233. Else
  234. currentLine += c
  235. ' 计算当前行的宽度
  236. Dim width As Integer = TextRenderer.MeasureText(currentLine, 說明_rtb.Font).Width
  237. ' 当宽度接近 RichTextBox 的宽度时,添加一个分段符号
  238. If width >= 450 Then
  239. lines.Add(currentLine)
  240. currentLine = ""
  241. End If
  242. End If
  243. Next
  244. ' 如果最后一行没有被添加,添加它
  245. If currentLine <> "" Then
  246. lines.Add(currentLine)
  247. End If
  248. End Using
  249. For i As Integer = 0 To lines.Count - 1
  250. 字串處理(lines(i))
  251. lines(i) = 已處理字串
  252. Next
  253. For i = 0 To lines.Count - 1
  254. xlSheet.Cells(3 + i, 3) = lines(i) : xlSheet.Cells(3 + i, 10) = lines(i)
  255. N2 = i + 3
  256. Next
  257. xlSheet.Cells(N2 + 1, 1) = "擬辦:" : xlSheet.Cells(N2 + 1, 2) = 擬辦_tb.Text : xlSheet.Cells(N2 + 1, 9) = 擬辦_tb.Text
  258. xlSheet.Cells(N2 + 2, 1) = "敬陳" : xlSheet.Cells(N2 + 2, 10) = "敬陳"
  259. xlSheet.Cells(N2 + 2, 4) = "敬會"
  260. xlSheet.Cells(N2 + 3, 1) = ComboBox1.Text : xlSheet.Cells(N2 + 3, 3) = ComboBox2.Text
  261. xlSheet.Cells(N2 + 3, 4) = ComboBox3.Text : xlSheet.Cells(N2 + 3, 5) = ComboBox4.Text : xlSheet.Cells(N2 + 3, 6) = ComboBox5.Text
  262. xlSheet.Cells(N2 + 3, 7) = ComboBox6.Text : xlSheet.Cells(N2 + 3, 8) = ComboBox7.Text : xlSheet.Cells(N2 + 3, 10) = "常務總監"
  263. BB(xlApp, xlSheet)
  264. xlApp.Sheets(2).Delete : xlSheet.PageSetup.PrintArea = ""
  265. Dim pdfFolderPath As String = Path.Combine(System.Windows.Forms.Application.StartupPath, "pdf")
  266. If Not Directory.Exists(pdfFolderPath) Then
  267. Directory.CreateDirectory(pdfFolderPath)
  268. End If
  269. Dim pdfFilePath As String = Path.Combine(pdfFolderPath, 檔案名稱_tb.Text & ".pdf")
  270. xlBook.Sheets(1).ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, pdfFilePath, XlFixedFormatQuality.xlQualityStandard, True)
  271. xlApp.Cells.Select() : xlApp.Application.WindowState = xlMinimized : xlBook.Close(False)
  272. Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
  273. Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
  274. Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
  275. xlApp.Quit() : xlSheet = Nothing : xlBook = Nothing : xlApp = Nothing : GC.Collect()
  276. Try
  277. Dim chromePath As String = "C:\Program Files\Google\Chrome\Application\chrome.exe"
  278. If System.IO.File.Exists(chromePath) Then
  279. Dim process As New Process()
  280. process.StartInfo.FileName = "chrome"
  281. process.StartInfo.Arguments = """" & pdfFilePath & """"
  282. process.Start()
  283. Else : Dim edgePath As String = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
  284. If System.IO.File.Exists(edgePath) Then
  285. Dim process As New Process()
  286. process.StartInfo.FileName = "msedge"
  287. process.StartInfo.Arguments = """" & pdfFilePath & """"
  288. process.Start()
  289. Else
  290. Process.Start(pdfFilePath)
  291. End If
  292. End If
  293. Catch ex As Exception
  294. MsgBox("以存檔至桌面 。" & vbCrLf & "檔案名稱:" & 檔案名稱_tb.Text & ".pdf")
  295. End Try
  296. End Sub
  297. Private Sub BB(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
  298. xlSheet.Cells.Select()
  299. With myExcel.Selection.Font
  300. .Name = "標楷體"
  301. .Size = 16
  302. .Strikethrough = False
  303. .Superscript = False
  304. .Subscript = False
  305. .OutlineFont = False
  306. .Shadow = False
  307. .Underline = xlUnderlineStyleNone
  308. .ThemeColor = xlThemeColorLight1
  309. .TintAndShade = 0
  310. .ThemeFont = xlThemeFontNone
  311. End With
  312. xlSheet.Columns("A:A").ColumnWidth = 8
  313. xlSheet.Columns("B:B").ColumnWidth = 8
  314. xlSheet.Columns("C:C").ColumnWidth = 13
  315. xlSheet.Columns("D:D").ColumnWidth = 13
  316. xlSheet.Columns("E:E").ColumnWidth = 13
  317. xlSheet.Columns("F:F").ColumnWidth = 13
  318. xlSheet.Columns("G:G").ColumnWidth = 13
  319. xlSheet.Columns("H:H").ColumnWidth = 13
  320. xlSheet.Range("A1").Select()
  321. With myExcel.Selection
  322. .HorizontalAlignment = xlLeft
  323. .VerticalAlignment = xlCenter
  324. .WrapText = False
  325. .Orientation = 0
  326. .AddIndent = False
  327. .IndentLevel = 0
  328. .ShrinkToFit = False
  329. .ReadingOrder = xlContext
  330. .MergeCells = False
  331. End With
  332. xlSheet.Range("B1:F1").Select()
  333. With myExcel.Selection
  334. .HorizontalAlignment = xlCenter
  335. .VerticalAlignment = xlCenter
  336. .WrapText = False
  337. .Orientation = 0
  338. .AddIndent = False
  339. .IndentLevel = 0
  340. .ShrinkToFit = False
  341. .ReadingOrder = xlContext
  342. .MergeCells = False
  343. End With
  344. myExcel.Selection.Merge
  345. xlSheet.Range("G1:H1").Select()
  346. With myExcel.Selection
  347. .HorizontalAlignment = xlRight
  348. .VerticalAlignment = xlCenter
  349. .WrapText = False
  350. .Orientation = 0
  351. .AddIndent = False
  352. .IndentLevel = 0
  353. .ShrinkToFit = False
  354. .ReadingOrder = xlContext
  355. .MergeCells = False
  356. End With
  357. myExcel.Selection.Merge
  358. xlSheet.Range("A2").Select()
  359. With myExcel.Selection
  360. .HorizontalAlignment = xlLeft
  361. .VerticalAlignment = xlTop
  362. .WrapText = False
  363. .Orientation = 0
  364. .AddIndent = False
  365. .IndentLevel = 0
  366. .ShrinkToFit = False
  367. .ReadingOrder = xlContext
  368. .MergeCells = False
  369. End With
  370. xlSheet.Range("A3").Select()
  371. With myExcel.Selection
  372. .HorizontalAlignment = xlLeft
  373. .VerticalAlignment = xlTop
  374. .WrapText = False
  375. .Orientation = 0
  376. .AddIndent = False
  377. .IndentLevel = 0
  378. .ShrinkToFit = False
  379. .ReadingOrder = xlContext
  380. .MergeCells = False
  381. End With
  382. xlSheet.Range("A" & N2 + 1).Select()
  383. With myExcel.Selection
  384. .HorizontalAlignment = xlLeft
  385. .VerticalAlignment = xlTop
  386. .WrapText = False
  387. .Orientation = 0
  388. .AddIndent = False
  389. .IndentLevel = 0
  390. .ShrinkToFit = False
  391. .ReadingOrder = xlContext
  392. .MergeCells = False
  393. End With
  394. xlSheet.Range("B2:H2").Select()
  395. With myExcel.Selection
  396. .HorizontalAlignment = xlLeft
  397. .VerticalAlignment = xlTop
  398. .WrapText = True
  399. .Orientation = 0
  400. .AddIndent = False
  401. .IndentLevel = 0
  402. .ShrinkToFit = False
  403. .ReadingOrder = xlContext
  404. .MergeCells = False
  405. End With
  406. myExcel.Selection.Merge
  407. For i = 3 To N2
  408. xlSheet.Range("B" & i & ":H" & i).Select()
  409. With myExcel.Selection
  410. .HorizontalAlignment = xlLeft
  411. .VerticalAlignment = xlTop
  412. .WrapText = True
  413. .Orientation = 0
  414. .AddIndent = False
  415. .IndentLevel = 0
  416. .ShrinkToFit = False
  417. .ReadingOrder = xlContext
  418. .MergeCells = False
  419. End With
  420. myExcel.Selection.Merge
  421. Next
  422. xlSheet.Range("B" & N2 + 1 & ":H" & N2 + 1).Select()
  423. With myExcel.Selection
  424. .HorizontalAlignment = xlLeft
  425. .VerticalAlignment = xlTop
  426. .WrapText = True
  427. .Orientation = 0
  428. .AddIndent = False
  429. .IndentLevel = 0
  430. .ShrinkToFit = False
  431. .ReadingOrder = xlContext
  432. .MergeCells = False
  433. End With
  434. myExcel.Selection.Merge
  435. xlSheet.Range("A" & N2 + 2 & ":C" & N2 + 2).Select()
  436. With myExcel.Selection
  437. .HorizontalAlignment = xlCenter
  438. .VerticalAlignment = xlCenter
  439. .WrapText = False
  440. .Orientation = XlOrientation.xlVertical
  441. .AddIndent = False
  442. .IndentLevel = 0
  443. .ShrinkToFit = False
  444. .ReadingOrder = xlContext
  445. .MergeCells = False
  446. End With
  447. myExcel.Selection.Merge
  448. xlSheet.Range("A" & N2 + 3 & ":B" & N2 + 3).Select()
  449. With myExcel.Selection
  450. .HorizontalAlignment = xlCenter
  451. .VerticalAlignment = xlCenter
  452. .WrapText = False
  453. .Orientation = XlOrientation.xlVertical
  454. .AddIndent = False
  455. .IndentLevel = 0
  456. .ShrinkToFit = False
  457. .ReadingOrder = xlContext
  458. .MergeCells = False
  459. End With
  460. myExcel.Selection.Merge
  461. xlSheet.Range("C" & N2 + 3).Select()
  462. With myExcel.Selection
  463. .HorizontalAlignment = xlCenter
  464. .VerticalAlignment = xlCenter
  465. .WrapText = False
  466. .Orientation = XlOrientation.xlVertical
  467. .AddIndent = False
  468. .IndentLevel = 0
  469. .ShrinkToFit = False
  470. .ReadingOrder = xlContext
  471. .MergeCells = False
  472. End With
  473. xlSheet.Range("J" & N2 + 2).Select()
  474. With myExcel.Selection
  475. .HorizontalAlignment = xlCenter
  476. .VerticalAlignment = xlCenter
  477. .WrapText = False
  478. .Orientation = XlOrientation.xlVertical
  479. .AddIndent = False
  480. .IndentLevel = 0
  481. .ShrinkToFit = False
  482. .ReadingOrder = xlContext
  483. .MergeCells = False
  484. End With
  485. xlSheet.Range("J" & N2 + 3).Select()
  486. With myExcel.Selection
  487. .HorizontalAlignment = xlCenter
  488. .VerticalAlignment = xlCenter
  489. .WrapText = False
  490. .Orientation = XlOrientation.xlVertical
  491. .AddIndent = False
  492. .IndentLevel = 0
  493. .ShrinkToFit = False
  494. .ReadingOrder = xlContext
  495. .MergeCells = False
  496. End With
  497. xlSheet.Rows(N2 + 4 & ":" & N2 + 4).RowHeight = 150
  498. xlSheet.Range("A" & N2 + 4 & ":B" & N2 + 4).Select()
  499. With myExcel.Selection
  500. .HorizontalAlignment = xlCenter
  501. .VerticalAlignment = xlCenter
  502. .WrapText = False
  503. .Orientation = 0
  504. .AddIndent = False
  505. .IndentLevel = 0
  506. .ShrinkToFit = False
  507. .ReadingOrder = xlContext
  508. .MergeCells = False
  509. End With
  510. myExcel.Selection.Merge
  511. If ComboBox3.Text <> "" And ComboBox4.Text <> "" And ComboBox5.Text <> "" And ComboBox6.Text <> "" And ComboBox7.Text <> "" Then
  512. xlSheet.Range("D" & N2 + 2 & ":H" & N2 + 2).Select()
  513. With myExcel.Selection
  514. .HorizontalAlignment = xlCenter
  515. .VerticalAlignment = xlCenter
  516. .WrapText = False
  517. .Orientation = XlOrientation.xlVertical
  518. .AddIndent = False
  519. .IndentLevel = 0
  520. .ShrinkToFit = False
  521. .ReadingOrder = xlContext
  522. .MergeCells = False
  523. End With
  524. myExcel.Selection.Merge
  525. xlSheet.Range("D" & N2 + 3).Select()
  526. With myExcel.Selection
  527. .HorizontalAlignment = xlCenter
  528. .VerticalAlignment = xlCenter
  529. .WrapText = False
  530. .Orientation = XlOrientation.xlVertical
  531. .AddIndent = False
  532. .IndentLevel = 0
  533. .ShrinkToFit = False
  534. .ReadingOrder = xlContext
  535. .MergeCells = False
  536. End With
  537. xlSheet.Range("E" & N2 + 3).Select()
  538. With myExcel.Selection
  539. .HorizontalAlignment = xlCenter
  540. .VerticalAlignment = xlCenter
  541. .WrapText = False
  542. .Orientation = XlOrientation.xlVertical
  543. .AddIndent = False
  544. .IndentLevel = 0
  545. .ShrinkToFit = False
  546. .ReadingOrder = xlContext
  547. .MergeCells = False
  548. End With
  549. xlSheet.Range("F" & N2 + 3).Select()
  550. With myExcel.Selection
  551. .HorizontalAlignment = xlCenter
  552. .VerticalAlignment = xlCenter
  553. .WrapText = False
  554. .Orientation = XlOrientation.xlVertical
  555. .AddIndent = False
  556. .IndentLevel = 0
  557. .ShrinkToFit = False
  558. .ReadingOrder = xlContext
  559. .MergeCells = False
  560. End With
  561. xlSheet.Range("G" & N2 + 3).Select()
  562. With myExcel.Selection
  563. .HorizontalAlignment = xlCenter
  564. .VerticalAlignment = xlCenter
  565. .WrapText = False
  566. .Orientation = XlOrientation.xlVertical
  567. .AddIndent = False
  568. .IndentLevel = 0
  569. .ShrinkToFit = False
  570. .ReadingOrder = xlContext
  571. .MergeCells = False
  572. End With
  573. xlSheet.Range("H" & N2 + 3).Select()
  574. With myExcel.Selection
  575. .HorizontalAlignment = xlCenter
  576. .VerticalAlignment = xlCenter
  577. .WrapText = False
  578. .Orientation = XlOrientation.xlVertical
  579. .AddIndent = False
  580. .IndentLevel = 0
  581. .ShrinkToFit = False
  582. .ReadingOrder = xlContext
  583. .MergeCells = False
  584. End With
  585. xlSheet.Range("A" & N2 + 2 & ":H" & N2 + 4).Select()
  586. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  587. myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  588. With myExcel.Selection.Borders(xlEdgeLeft)
  589. .LineStyle = xlContinuous
  590. .ColorIndex = 0
  591. .TintAndShade = 0
  592. .Weight = xlThin
  593. End With
  594. With myExcel.Selection.Borders(xlEdgeTop)
  595. .LineStyle = xlContinuous
  596. .ColorIndex = 0
  597. .TintAndShade = 0
  598. .Weight = xlThin
  599. End With
  600. With myExcel.Selection.Borders(xlEdgeBottom)
  601. .LineStyle = xlContinuous
  602. .ColorIndex = 0
  603. .TintAndShade = 0
  604. .Weight = xlThin
  605. End With
  606. With myExcel.Selection.Borders(xlEdgeRight)
  607. .LineStyle = xlContinuous
  608. .ColorIndex = 0
  609. .TintAndShade = 0
  610. .Weight = xlThin
  611. End With
  612. With myExcel.Selection.Borders(xlInsideVertical)
  613. .LineStyle = xlContinuous
  614. .ColorIndex = 0
  615. .TintAndShade = 0
  616. .Weight = xlThin
  617. End With
  618. With myExcel.Selection.Borders(xlInsideHorizontal)
  619. .LineStyle = xlContinuous
  620. .ColorIndex = 0
  621. .TintAndShade = 0
  622. .Weight = xlThin
  623. End With
  624. ElseIf ComboBox3.Text <> "" And ComboBox4.Text <> "" And ComboBox5.Text <> "" And ComboBox6.Text <> "" And ComboBox7.Text = "" Then
  625. xlSheet.Range("D" & N2 + 2 & ":G" & N2 + 2).Select()
  626. With myExcel.Selection
  627. .HorizontalAlignment = xlCenter
  628. .VerticalAlignment = xlCenter
  629. .WrapText = False
  630. .Orientation = XlOrientation.xlVertical
  631. .AddIndent = False
  632. .IndentLevel = 0
  633. .ShrinkToFit = False
  634. .ReadingOrder = xlContext
  635. .MergeCells = False
  636. End With
  637. myExcel.Selection.Merge
  638. xlSheet.Range("D" & N2 + 3).Select()
  639. With myExcel.Selection
  640. .HorizontalAlignment = xlCenter
  641. .VerticalAlignment = xlCenter
  642. .WrapText = False
  643. .Orientation = XlOrientation.xlVertical
  644. .AddIndent = False
  645. .IndentLevel = 0
  646. .ShrinkToFit = False
  647. .ReadingOrder = xlContext
  648. .MergeCells = False
  649. End With
  650. xlSheet.Range("E" & N2 + 3).Select()
  651. With myExcel.Selection
  652. .HorizontalAlignment = xlCenter
  653. .VerticalAlignment = xlCenter
  654. .WrapText = False
  655. .Orientation = XlOrientation.xlVertical
  656. .AddIndent = False
  657. .IndentLevel = 0
  658. .ShrinkToFit = False
  659. .ReadingOrder = xlContext
  660. .MergeCells = False
  661. End With
  662. xlSheet.Range("F" & N2 + 3).Select()
  663. With myExcel.Selection
  664. .HorizontalAlignment = xlCenter
  665. .VerticalAlignment = xlCenter
  666. .WrapText = False
  667. .Orientation = XlOrientation.xlVertical
  668. .AddIndent = False
  669. .IndentLevel = 0
  670. .ShrinkToFit = False
  671. .ReadingOrder = xlContext
  672. .MergeCells = False
  673. End With
  674. xlSheet.Range("G" & N2 + 3).Select()
  675. With myExcel.Selection
  676. .HorizontalAlignment = xlCenter
  677. .VerticalAlignment = xlCenter
  678. .WrapText = False
  679. .Orientation = XlOrientation.xlVertical
  680. .AddIndent = False
  681. .IndentLevel = 0
  682. .ShrinkToFit = False
  683. .ReadingOrder = xlContext
  684. .MergeCells = False
  685. End With
  686. xlSheet.Range("A" & N2 + 2 & ":G" & N2 + 4).Select()
  687. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  688. myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  689. With myExcel.Selection.Borders(xlEdgeLeft)
  690. .LineStyle = xlContinuous
  691. .ColorIndex = 0
  692. .TintAndShade = 0
  693. .Weight = xlThin
  694. End With
  695. With myExcel.Selection.Borders(xlEdgeTop)
  696. .LineStyle = xlContinuous
  697. .ColorIndex = 0
  698. .TintAndShade = 0
  699. .Weight = xlThin
  700. End With
  701. With myExcel.Selection.Borders(xlEdgeBottom)
  702. .LineStyle = xlContinuous
  703. .ColorIndex = 0
  704. .TintAndShade = 0
  705. .Weight = xlThin
  706. End With
  707. With myExcel.Selection.Borders(xlEdgeRight)
  708. .LineStyle = xlContinuous
  709. .ColorIndex = 0
  710. .TintAndShade = 0
  711. .Weight = xlThin
  712. End With
  713. With myExcel.Selection.Borders(xlInsideVertical)
  714. .LineStyle = xlContinuous
  715. .ColorIndex = 0
  716. .TintAndShade = 0
  717. .Weight = xlThin
  718. End With
  719. With myExcel.Selection.Borders(xlInsideHorizontal)
  720. .LineStyle = xlContinuous
  721. .ColorIndex = 0
  722. .TintAndShade = 0
  723. .Weight = xlThin
  724. End With
  725. ElseIf ComboBox3.Text <> "" And ComboBox4.Text <> "" And ComboBox5.Text <> "" And ComboBox6.Text = "" And ComboBox7.Text = "" Then
  726. xlSheet.Range("D" & N2 + 2 & ":F" & N2 + 2).Select()
  727. With myExcel.Selection
  728. .HorizontalAlignment = xlCenter
  729. .VerticalAlignment = xlCenter
  730. .WrapText = False
  731. .Orientation = XlOrientation.xlVertical
  732. .AddIndent = False
  733. .IndentLevel = 0
  734. .ShrinkToFit = False
  735. .ReadingOrder = xlContext
  736. .MergeCells = False
  737. End With
  738. myExcel.Selection.Merge
  739. xlSheet.Range("D" & N2 + 3).Select()
  740. With myExcel.Selection
  741. .HorizontalAlignment = xlCenter
  742. .VerticalAlignment = xlCenter
  743. .WrapText = False
  744. .Orientation = XlOrientation.xlVertical
  745. .AddIndent = False
  746. .IndentLevel = 0
  747. .ShrinkToFit = False
  748. .ReadingOrder = xlContext
  749. .MergeCells = False
  750. End With
  751. xlSheet.Range("E" & N2 + 3).Select()
  752. With myExcel.Selection
  753. .HorizontalAlignment = xlCenter
  754. .VerticalAlignment = xlCenter
  755. .WrapText = False
  756. .Orientation = XlOrientation.xlVertical
  757. .AddIndent = False
  758. .IndentLevel = 0
  759. .ShrinkToFit = False
  760. .ReadingOrder = xlContext
  761. .MergeCells = False
  762. End With
  763. xlSheet.Range("F" & N2 + 3).Select()
  764. With myExcel.Selection
  765. .HorizontalAlignment = xlCenter
  766. .VerticalAlignment = xlCenter
  767. .WrapText = False
  768. .Orientation = XlOrientation.xlVertical
  769. .AddIndent = False
  770. .IndentLevel = 0
  771. .ShrinkToFit = False
  772. .ReadingOrder = xlContext
  773. .MergeCells = False
  774. End With
  775. xlSheet.Range("A" & N2 + 2 & ":F" & N2 + 4).Select()
  776. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  777. myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  778. With myExcel.Selection.Borders(xlEdgeLeft)
  779. .LineStyle = xlContinuous
  780. .ColorIndex = 0
  781. .TintAndShade = 0
  782. .Weight = xlThin
  783. End With
  784. With myExcel.Selection.Borders(xlEdgeTop)
  785. .LineStyle = xlContinuous
  786. .ColorIndex = 0
  787. .TintAndShade = 0
  788. .Weight = xlThin
  789. End With
  790. With myExcel.Selection.Borders(xlEdgeBottom)
  791. .LineStyle = xlContinuous
  792. .ColorIndex = 0
  793. .TintAndShade = 0
  794. .Weight = xlThin
  795. End With
  796. With myExcel.Selection.Borders(xlEdgeRight)
  797. .LineStyle = xlContinuous
  798. .ColorIndex = 0
  799. .TintAndShade = 0
  800. .Weight = xlThin
  801. End With
  802. With myExcel.Selection.Borders(xlInsideVertical)
  803. .LineStyle = xlContinuous
  804. .ColorIndex = 0
  805. .TintAndShade = 0
  806. .Weight = xlThin
  807. End With
  808. With myExcel.Selection.Borders(xlInsideHorizontal)
  809. .LineStyle = xlContinuous
  810. .ColorIndex = 0
  811. .TintAndShade = 0
  812. .Weight = xlThin
  813. End With
  814. ElseIf ComboBox3.Text <> "" And ComboBox4.Text <> "" And ComboBox5.Text = "" And ComboBox6.Text = "" And ComboBox7.Text = "" Then
  815. xlSheet.Range("D" & N2 + 2 & ":E" & N2 + 2).Select()
  816. With myExcel.Selection
  817. .HorizontalAlignment = xlCenter
  818. .VerticalAlignment = xlCenter
  819. .WrapText = False
  820. .Orientation = XlOrientation.xlVertical
  821. .AddIndent = False
  822. .IndentLevel = 0
  823. .ShrinkToFit = False
  824. .ReadingOrder = xlContext
  825. .MergeCells = False
  826. End With
  827. myExcel.Selection.Merge
  828. xlSheet.Range("D" & N2 + 3).Select()
  829. With myExcel.Selection
  830. .HorizontalAlignment = xlCenter
  831. .VerticalAlignment = xlCenter
  832. .WrapText = False
  833. .Orientation = XlOrientation.xlVertical
  834. .AddIndent = False
  835. .IndentLevel = 0
  836. .ShrinkToFit = False
  837. .ReadingOrder = xlContext
  838. .MergeCells = False
  839. End With
  840. xlSheet.Range("E" & N2 + 3).Select()
  841. With myExcel.Selection
  842. .HorizontalAlignment = xlCenter
  843. .VerticalAlignment = xlCenter
  844. .WrapText = False
  845. .Orientation = XlOrientation.xlVertical
  846. .AddIndent = False
  847. .IndentLevel = 0
  848. .ShrinkToFit = False
  849. .ReadingOrder = xlContext
  850. .MergeCells = False
  851. End With
  852. xlSheet.Range("A" & N2 + 2 & ":E" & N2 + 4).Select()
  853. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  854. myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  855. With myExcel.Selection.Borders(xlEdgeLeft)
  856. .LineStyle = xlContinuous
  857. .ColorIndex = 0
  858. .TintAndShade = 0
  859. .Weight = xlThin
  860. End With
  861. With myExcel.Selection.Borders(xlEdgeTop)
  862. .LineStyle = xlContinuous
  863. .ColorIndex = 0
  864. .TintAndShade = 0
  865. .Weight = xlThin
  866. End With
  867. With myExcel.Selection.Borders(xlEdgeBottom)
  868. .LineStyle = xlContinuous
  869. .ColorIndex = 0
  870. .TintAndShade = 0
  871. .Weight = xlThin
  872. End With
  873. With myExcel.Selection.Borders(xlEdgeRight)
  874. .LineStyle = xlContinuous
  875. .ColorIndex = 0
  876. .TintAndShade = 0
  877. .Weight = xlThin
  878. End With
  879. With myExcel.Selection.Borders(xlInsideVertical)
  880. .LineStyle = xlContinuous
  881. .ColorIndex = 0
  882. .TintAndShade = 0
  883. .Weight = xlThin
  884. End With
  885. With myExcel.Selection.Borders(xlInsideHorizontal)
  886. .LineStyle = xlContinuous
  887. .ColorIndex = 0
  888. .TintAndShade = 0
  889. .Weight = xlThin
  890. End With
  891. End If
  892. xlSheet.Columns("I:I").Select
  893. With myExcel.Selection
  894. .HorizontalAlignment = xlLeft
  895. .VerticalAlignment = xlTop
  896. .WrapText = True
  897. .Orientation = 0
  898. .AddIndent = False
  899. .IndentLevel = 0
  900. .ShrinkToFit = False
  901. .ReadingOrder = xlContext
  902. .MergeCells = False
  903. End With
  904. xlSheet.Columns("I:I").ColumnWidth = 89.75
  905. For i = 2 To N2 + 3
  906. xlSheet.Rows(i & ":" & i).Select
  907. xlSheet.Rows(i & ":" & i).EntireRow.AutoFit
  908. Next
  909. xlSheet.Columns("I:J").Select
  910. myExcel.Selection.EntireColumn.Hidden = True
  911. For i = 1 To N2 + 3
  912. xlSheet.Rows(i).RowHeight = xlSheet.Rows(i).RowHeight + 5
  913. Next i
  914. myExcel.Application.PrintCommunication = False
  915. With myExcel.ActiveSheet.PageSetup
  916. .PrintTitleRows = ""
  917. .PrintTitleColumns = ""
  918. End With
  919. myExcel.Application.PrintCommunication = True
  920. myExcel.ActiveSheet.PageSetup.PrintArea = ""
  921. myExcel.Application.PrintCommunication = False
  922. With myExcel.ActiveSheet.PageSetup
  923. .LeftHeader = ""
  924. .CenterHeader = ""
  925. .RightHeader = ""
  926. .LeftFooter = ""
  927. .CenterFooter = ""
  928. .RightFooter = ""
  929. .LeftMargin = myExcel.Application.InchesToPoints(0.25)
  930. .RightMargin = myExcel.Application.InchesToPoints(0.25)
  931. .TopMargin = myExcel.Application.InchesToPoints(0.75)
  932. .BottomMargin = myExcel.Application.InchesToPoints(0.75)
  933. .HeaderMargin = myExcel.Application.InchesToPoints(0.3)
  934. .FooterMargin = myExcel.Application.InchesToPoints(0.3)
  935. .PrintHeadings = False
  936. .PrintGridlines = False
  937. .CenterHorizontally = False
  938. .CenterVertically = False
  939. .Draft = False
  940. .FirstPageNumber = xlAutomatic
  941. .BlackAndWhite = False
  942. .Zoom = False
  943. .FitToPagesWide = 1
  944. .FitToPagesTall = 0
  945. .OddAndEvenPagesHeaderFooter = False
  946. .DifferentFirstPageHeaderFooter = False
  947. .ScaleWithDocHeaderFooter = True
  948. .AlignMarginsHeaderFooter = True
  949. .EvenPage.LeftHeader.Text = ""
  950. .EvenPage.CenterHeader.Text = ""
  951. .EvenPage.RightHeader.Text = ""
  952. .EvenPage.LeftFooter.Text = ""
  953. .EvenPage.CenterFooter.Text = ""
  954. .EvenPage.RightFooter.Text = ""
  955. .FirstPage.LeftHeader.Text = ""
  956. .FirstPage.CenterHeader.Text = ""
  957. .FirstPage.RightHeader.Text = ""
  958. .FirstPage.LeftFooter.Text = ""
  959. .FirstPage.CenterFooter.Text = ""
  960. .FirstPage.RightFooter.Text = ""
  961. End With
  962. myExcel.Application.PrintCommunication = True
  963. End Sub
  964. Private Shared Function NewMethod(xlBook As Microsoft.Office.Interop.Excel.Workbook) As Microsoft.Office.Interop.Excel.Worksheet
  965. Return CType(xlBook.Worksheets.Add, Microsoft.Office.Interop.Excel.Worksheet)
  966. End Function
  967. Private Sub 字體大小調整_lb_Click(sender As Object, e As EventArgs) Handles 字體大小調整_lb.Click
  968. End Sub
  969. End Class