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

應付款日報表.vb 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. Option Strict Off
  2. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  3. Imports Microsoft.Office.Interop.Excel.Constants
  4. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  5. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  6. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  7. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  8. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  9. Imports Microsoft.Office.Interop.Excel.XlWindowState
  10. Imports Microsoft.Office.Interop.Excel
  11. Public Class 應付款日報表
  12. Dim 縮起來 As Boolean = False : Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet : Dim GGHH As Long = 0 : Dim BN As Long = 0
  13. Private Sub 語言轉換讀取()
  14. If 系統語言 = "繁體中文" Then : 語言 = "CH" : ElseIf 系統語言 = "English" Then : 語言 = "EN" : ElseIf 系統語言 = "Indonesian" Then : 語言 = "IN" : End If
  15. Me.Text = 系統語言字典("H001-141-" & 語言)
  16. 表頭(0) = 系統語言字典("H314-124-" & 語言) : 表頭(1) = 系統語言字典("G000-177-" & 語言) : 表頭(2) = 系統語言字典("H318-100-" & 語言)
  17. 表頭(3) = 系統語言字典("H318-101-" & 語言) : 表頭(4) = 系統語言字典("H318-102-" & 語言) : 表頭(5) = 系統語言字典("H314-124-" & 語言)
  18. Label2.Text = 系統語言字典("H318-103-" & 語言) : Label1.Text = 系統語言字典("H318-102-" & 語言)
  19. End Sub
  20. Private Sub 支付日期清單()
  21. Dim ds1 As New DataSet : 單據_dgv.DataSource = Nothing : ds1.Clear()
  22. 單據_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  23. 單據_dgv.ColumnHeadersHeight = 25 : 單據_dgv.AllowUserToAddRows = False
  24. If HX_ch.Checked = True And PGS_ch.Checked = False Then : PA = "HXI" : Else : PA = "PGS" : End If
  25. SQL_支付日期(PA)
  26. da.Fill(ds1) : 單據_dgv.DataSource = ds1.Tables(0) : conn.Close()
  27. End Sub
  28. Private Sub 單據讀取()
  29. Dim ds1 As New DataSet : 餘額_dgv.DataSource = Nothing : ds1.Clear()
  30. 餘額_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  31. 餘額_dgv.ColumnHeadersHeight = 30 : 餘額_dgv.AllowUserToAddRows = False : 餘額_dgv.RowTemplate.Height = 65
  32. SQL_餘額查詢(PA1, PA)
  33. da.Fill(ds1) : 餘額_dgv.DataSource = ds1.Tables(0) : conn.Close()
  34. 餘額_dgv.Columns(0).FillWeight = 40 : 餘額_dgv.Columns(1).FillWeight = 80 : 餘額_dgv.Columns(2).FillWeight = 250 : 餘額_dgv.Columns("排序").Visible = False
  35. 餘額_dgv.Columns(3).DefaultCellStyle.Format = "#,##0" : 餘額_dgv.Columns(4).DefaultCellStyle.Format = "#,##0"
  36. 餘額_dgv.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  37. 餘額_dgv.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  38. 餘額_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  39. 餘額_dgv.Columns(3).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  40. 餘額_dgv.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  41. 餘額_dgv.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  42. 餘額_dgv.EditMode = DataGridViewEditMode.EditOnEnter : 餘額_dgv.Columns(0).ReadOnly = True : 餘額_dgv.Columns(1).ReadOnly = True
  43. 單據讀取1()
  44. If 餘額_dgv.Rows.Count > 0 Then : 餘額_dgv(1, 0).Value = PA1 : 餘額_dgv(2, 0).Value = "SISA SALDO SEBELUMNYA" : 餘額_dgv(3, 0).Value = "0" : End If
  45. For i As Integer = 0 To 餘額_dgv.Rows.Count - 1 : 餘額_dgv(0, i).Value = "" : 餘額_dgv(3, i).Value = "0" : Next
  46. Dim panel1Width As Integer : If 餘額_dgv.Rows.Count = 0 Then : panel1Width = 45 : Else : panel1Width = (65 * (餘額_dgv.Rows.Count)) + 3 + 30 : End If
  47. SplitContainer1.SplitterDistance = panel1Width : Dim totalHeight As Integer = SplitContainer1.Height - SplitContainer1.SplitterWidth
  48. SplitContainer1.Panel1MinSize = panel1Width : SplitContainer1.Panel2MinSize = totalHeight - panel1Width
  49. If 餘額_dgv.Rows.Count = 0 Then : panel1Width = 45 : Else : panel1Width = (65 * (餘額_dgv.Rows.Count)) + 3 + 30 : End If
  50. SplitContainer1.SplitterDistance = panel1Width : totalHeight = SplitContainer1.Height - SplitContainer1.SplitterWidth
  51. SplitContainer1.Panel1MinSize = panel1Width : SplitContainer1.Panel2MinSize = totalHeight - panel1Width
  52. Dim 可放 As Double = 付款資料_dgv.Size.Height / 65
  53. If 付款資料_dgv.Rows.Count >= 可放 Then
  54. If 縮起來 = False Then : 餘額_dgv.Size = New Size(餘額_dgv.Size.Width - 19, 餘額_dgv.Size.Height) : 縮起來 = True : End If
  55. Else
  56. If 縮起來 = True Then : 餘額_dgv.Size = New Size(餘額_dgv.Size.Width + 19, 餘額_dgv.Size.Height) : 縮起來 = False : End If
  57. End If
  58. 餘額計算()
  59. End Sub
  60. Private Sub 單據讀取1()
  61. Dim ds1 As New DataSet : 付款資料_dgv.DataSource = Nothing : ds1.Clear()
  62. 付款資料_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  63. 付款資料_dgv.ColumnHeadersHeight = 25 : 付款資料_dgv.AllowUserToAddRows = False
  64. 付款資料_dgv.RowTemplate.Height = 65 : 付款資料_dgv.ColumnHeadersVisible = False
  65. SQL_帳務查詢(PA1, PA)
  66. da.Fill(ds1) : 付款資料_dgv.DataSource = ds1.Tables(0) : conn.Close()
  67. 付款資料_dgv.Columns(0).FillWeight = 40 : 付款資料_dgv.Columns(1).FillWeight = 80 : 付款資料_dgv.Columns(2).FillWeight = 250
  68. 付款資料_dgv.Columns(0).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  69. 付款資料_dgv.Columns(0).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  70. 付款資料_dgv.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  71. 付款資料_dgv.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  72. 付款資料_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  73. 付款資料_dgv.Columns(3).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  74. 付款資料_dgv.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  75. 付款資料_dgv.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  76. 付款資料_dgv.Columns(0).ReadOnly = True : 付款資料_dgv.Columns(1).ReadOnly = True : 付款資料_dgv.Columns(2).ReadOnly = True
  77. 付款資料_dgv.Columns(3).ReadOnly = True : 付款資料_dgv.Columns(4).ReadOnly = True
  78. For i As Integer = 0 To 付款資料_dgv.Rows.Count - 1
  79. 付款資料_dgv(0, i).Value = i + 1
  80. 付款資料_dgv(3, i).Value = Strings.Format(CDbl(付款資料_dgv(3, i).Value.ToString), "#,##0")
  81. 付款資料_dgv(4, i).Value = Strings.Format(CDbl(付款資料_dgv(4, i).Value.ToString), "#,##0")
  82. Next
  83. End Sub
  84. Private Sub 應付款日報表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  85. Me.MdiParent = HX_PGS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  86. H(318) = True : 介面 = "H318" : 顯示說明(999, False)
  87. 單據_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  88. End Sub
  89. Private Sub 應付款日報表_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  90. PictureBox2.SendToBack() : 語言轉換讀取() : 支付日期清單()
  91. End Sub
  92. Private Sub 應付款日報表_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
  93. H(318) = False : MyMod.虛擬桌面開啟()
  94. End Sub
  95. Private Sub 應付款日報表_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
  96. MyMod.清單字體大小調整()
  97. 單據_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  98. End Sub
  99. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  100. timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
  101. End Sub
  102. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  103. timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
  104. End Sub
  105. Private Sub 餘額計算()
  106. 支出_tb.Text = "0" : 彙總_tb.Text = "0"
  107. For i As Integer = 0 To 付款資料_dgv.Rows.Count - 1 : 支出_tb.Text = CDbl(支出_tb.Text) + CDbl(付款資料_dgv(3, i).Value.ToString) : Next
  108. For i As Integer = 0 To 餘額_dgv.Rows.Count - 1 : 彙總_tb.Text = CDbl(彙總_tb.Text) + CDbl(餘額_dgv(4, i).Value.ToString) : Next
  109. 彙總_tb.Text = Strings.Format((CDbl(彙總_tb.Text) - CDbl(支出_tb.Text)), "#,##0") : 支出_tb.Text = Strings.Format(CDbl(支出_tb.Text), "#,##0")
  110. End Sub
  111. Private Sub 餘額_dgv_CellContentCl(sender As Object, e As DataGridViewCellEventArgs) Handles 餘額_dgv.CellEndEdit
  112. 餘額計算()
  113. End Sub
  114. Private Sub HX_ch_CheckedChanged(sender As Object, e As EventArgs) Handles HX_ch.Click
  115. PictureBox2.SendToBack() : HX_ch.Checked = True : PGS_ch.Checked = False : 支付日期清單()
  116. End Sub
  117. Private Sub PGS_ch_CheckedChanged(sender As Object, e As EventArgs) Handles PGS_ch.Click
  118. PictureBox1.SendToBack() : HX_ch.Checked = False : PGS_ch.Checked = True : 支付日期清單()
  119. End Sub
  120. Private Sub 單據_dgv_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles 單據_dgv.CellClick
  121. If e.RowIndex = -1 Then : Else
  122. PA1 = 單據_dgv(0, e.RowIndex).Value.ToString : If HX_ch.Checked = True And PGS_ch.Checked = False Then : PA = "HXI" : Else : PA = "PGS" : End If : PA4 = ""
  123. 單據讀取() : If 餘額_dgv.Rows.Count = 0 Then : PA2 = "SISA SALDO SEBELUMNYA" : PA3 = "1" : SQL_餘額查詢_新增(PA1, PA, PA2, PA3) : 單據讀取() : End If
  124. End If
  125. End Sub
  126. Private Sub 餘額_dgv_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles 餘額_dgv.CellClick
  127. If e.RowIndex = -1 Then : Else : PA4 = 餘額_dgv("排序", e.RowIndex).Value.ToString : End If
  128. End Sub
  129. Private Sub 開立收支單_bt_Click(sender As Object, e As EventArgs) Handles 開立收支單_bt.Click
  130. If 付款資料_dgv.Rows.Count > 0 Then
  131. PA3 = 餘額_dgv.Rows.Count + 1 : PA2 = "" : If HX_ch.Checked = True And PGS_ch.Checked = False Then : PA = "HXI" : Else : PA = "PGS" : End If
  132. SQL_餘額查詢_新增(PA1, PA, PA2, PA3) : 單據讀取()
  133. End If
  134. End Sub
  135. Private Sub 刪除收支單_bt_Click(sender As Object, e As EventArgs) Handles 刪除收支單_bt.Click
  136. If PA4 <> "" And PA4 <> "1" Then
  137. If HX_ch.Checked = True And PGS_ch.Checked = False Then : PA = "HXI" : Else : PA = "PGS" : End If : SQL_餘額查詢_刪除(PA1, PA, PA4) : 單據讀取() : PA4 = ""
  138. End If
  139. End Sub
  140. Private Sub 申請完成_bt_Click(sender As Object, e As EventArgs) Handles 申請完成_bt.Click
  141. If 餘額_dgv.Rows.Count > 0 Then
  142. If HX_ch.Checked = True And PGS_ch.Checked = False Then : PA = "HXI" : Else : PA = "PGS" : End If
  143. For i As Integer = 0 To 餘額_dgv.Rows.Count - 1
  144. PA5 = 餘額_dgv(4, i).Value.ToString : PA4 = 餘額_dgv("排序", i).Value.ToString : PA2 = 餘額_dgv(2, i).Value.ToString
  145. SQL_餘額查詢_修改(PA1, PA, PA5, PA4, PA2)
  146. Next : MGB(系統語言字典("G000-119-" & 語言), 1)
  147. End If
  148. End Sub
  149. Private Sub 列印成EXCEL_bt_Click(sender As Object, e As EventArgs) Handles 列印成EXCEL_bt.Click
  150. If 餘額_dgv.Rows.Count > 0 Then
  151. xlApp = CType(CreateObject("Excel.Application"), Application)
  152. xlBook = xlApp.Workbooks.Add
  153. xlApp.DisplayAlerts = True
  154. xlApp.Visible = True
  155. xlApp.Application.WindowState = xlMaximized
  156. xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Select
  157. xlApp.Sheets(1).Name = PA1.Replace("/", "_") : xlBook.Activate() : xlSheet.Activate()
  158. xlSheet.Cells(5, 2) = "No" : xlSheet.Cells(5, 3) = 表頭(1) : xlSheet.Cells(5, 4) = 表頭(2) : xlSheet.Cells(5, 5) = 表頭(3) : xlSheet.Cells(5, 6) = 表頭(4)
  159. GGHH = 0 : BN = 0
  160. For i As Integer = 0 To 餘額_dgv.Rows.Count - 1
  161. xlSheet.Cells(i + 6, 2) = 餘額_dgv.Rows(i).Cells(0).Value.ToString : xlSheet.Cells(i + 6, 3) = 餘額_dgv.Rows(i).Cells(1).Value.ToString
  162. xlSheet.Cells(i + 6, 4) = 餘額_dgv.Rows(i).Cells(2).Value.ToString : xlSheet.Cells(i + 6, 5) = 餘額_dgv.Rows(i).Cells(3).Value.ToString
  163. xlSheet.Cells(i + 6, 6) = 餘額_dgv.Rows(i).Cells(4).Value.ToString : GGHH += 1
  164. Next : BN = GGHH
  165. For i As Integer = 0 To 付款資料_dgv.Rows.Count - 1
  166. xlSheet.Cells(i + 6 + GGHH, 2) = 付款資料_dgv.Rows(i).Cells(0).Value.ToString : xlSheet.Cells(i + 6 + GGHH, 3) = 付款資料_dgv.Rows(i).Cells(1).Value.ToString
  167. xlSheet.Cells(i + 6 + GGHH, 4) = 付款資料_dgv.Rows(i).Cells(2).Value.ToString : xlSheet.Cells(i + 6 + GGHH, 5) = 付款資料_dgv.Rows(i).Cells(3).Value.ToString
  168. xlSheet.Cells(i + 6 + GGHH, 6) = 付款資料_dgv.Rows(i).Cells(4).Value.ToString : BN += 1
  169. Next
  170. xlSheet.Cells(6 + BN, 2) = Label2.Text : xlSheet.Cells(6 + BN, 5) = 支出_tb.Text
  171. xlSheet.Cells(6 + BN + 1, 2) = Label1.Text : xlSheet.Cells(6 + BN + 1, 5) = 彙總_tb.Text
  172. AA(xlApp, xlSheet) : FF(xlApp, xlSheet)
  173. If HX_ch.Checked = True And PGS_ch.Checked = False Then : CC(xlApp, xlSheet) : Else : DD(xlApp, xlSheet) : End If
  174. xlApp.Sheets(2).Delete : xlSheet.PageSetup.PrintArea = ""
  175. '-------------轉換成PDF---------------------------------------------------------------------
  176. Dim SERT As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
  177. xlBook.Sheets(1).ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, SERT & "\" & PA1.Replace("/", "_") & ".pdf", XlFixedFormatQuality.xlQualityStandard, True)
  178. '-------------關閉EXCEL---------------------------------------------------------------------
  179. xlApp.Cells.Select() : xlApp.Application.WindowState = xlMinimized
  180. xlBook.Close(False)
  181. Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
  182. Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
  183. Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
  184. xlApp.Quit() : xlSheet = Nothing : xlBook = Nothing : xlApp = Nothing : GC.Collect()
  185. '-------------開啟PDF---------------------------------------------------------------------
  186. Dim pdfFilePath As String = SERT & "\" & PA1.Replace("/", "_") & ".pdf"
  187. If IsChromeInstalled() Then
  188. Try
  189. Dim chromeProcess As New Process()
  190. chromeProcess.StartInfo.FileName = "chrome"
  191. chromeProcess.StartInfo.Arguments = """" & pdfFilePath & """"
  192. chromeProcess.Start()
  193. Catch ex As Exception
  194. End Try
  195. Else
  196. Try
  197. System.Diagnostics.Process.Start("""" & pdfFilePath & """")
  198. Catch ex As Exception
  199. End Try
  200. End If
  201. MGB(系統語言字典("H508-121-" & 語言), 1) : 首次開啟 = False
  202. End If
  203. End Sub
  204. Private Function IsChromeInstalled() As Boolean
  205. Dim key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
  206. If key IsNot Nothing Then
  207. For Each subkeyName As String In key.GetSubKeyNames()
  208. Dim subkey As Microsoft.Win32.RegistryKey = key.OpenSubKey(subkeyName)
  209. Dim displayName As Object = subkey.GetValue("DisplayName")
  210. If displayName IsNot Nothing AndAlso displayName.ToString().Contains("Google Chrome") Then
  211. Return True
  212. End If
  213. Next
  214. End If
  215. Return False
  216. End Function
  217. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  218. Return CType(xlBook.Worksheets.Add, Worksheet)
  219. End Function
  220. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  221. xlSheet.Cells.Select()
  222. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  223. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  224. xlSheet.Rows("5:5").Select : myExcel.Selection.RowHeight = 35
  225. With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  226. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  227. xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 6
  228. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  229. .ReadingOrder = xlContext : .MergeCells = False : End With
  230. xlSheet.Columns("C:C").Select : myExcel.Selection.NumberFormatLocal = "yyyy/mm/dd" : myExcel.Selection.ColumnWidth = 12
  231. xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 18
  232. xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 18
  233. xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 70
  234. With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  235. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  236. xlSheet.Range("C5:F5").Select()
  237. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  238. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  239. xlSheet.Range("B" & BN + 6 & ":D" & BN + 6).Select()
  240. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  241. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  242. xlSheet.Range("B" & BN + 6 + 1 & ":D" & BN + 6 + 1).Select()
  243. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  244. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  245. xlSheet.Range("E" & BN + 6 + 1 & ":F" & BN + 6 + 1).Select()
  246. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  247. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  248. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  249. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  250. xlSheet.Rows(BN + 6 & ":" & BN + 6 + 1).Select : myExcel.Selection.RowHeight = 30
  251. xlSheet.Range("B5:F5").Select()
  252. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent2 : .TintAndShade = 0.599993896298105
  253. .PatternTintAndShade = 0 : End With
  254. xlSheet.Range("B5:F" & BN + 6 + 1).Select()
  255. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  256. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  257. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  258. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  259. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  260. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  261. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  262. xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 30
  263. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 35
  264. xlSheet.Rows(BN + 6 & ":" & BN + 6 + 1).Select : myExcel.Selection.Font.Bold = True : myExcel.ActiveWindow.DisplayGridlines = False
  265. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 1
  266. xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 1
  267. xlSheet.Range("E6:F" & BN + 6 + 1).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
  268. Dim 攔寬 As Double
  269. For i As Integer = 6 To BN + 6 - 1
  270. xlSheet.Rows(i & ":" & i).Select : 攔寬 = xlSheet.Rows(i & ":" & i).RowHeight
  271. xlSheet.Rows(i & ":" & i).Select : myExcel.Selection.RowHeight = 攔寬 + 10
  272. Next
  273. End Sub
  274. Private Sub CC(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Worksheet)
  275. Clipboard.SetDataObject(合約報價單.PictureBox1.Image)
  276. xlSheet.Range("B1").Select()
  277. myExcel.ActiveSheet.Pictures.Paste.Select
  278. myExcel.Selection.ShapeRange.Height = 93
  279. myExcel.Selection.ShapeRange.IncrementLeft(50)
  280. myExcel.Selection.ShapeRange.IncrementTop(0)
  281. End Sub
  282. Private Sub DD(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Worksheet)
  283. Clipboard.SetDataObject(合約報價單.PictureBox2.Image)
  284. xlSheet.Range("B1").Select()
  285. myExcel.ActiveSheet.Pictures.Paste.Select
  286. myExcel.Selection.ShapeRange.Height = 93
  287. myExcel.Selection.ShapeRange.IncrementLeft(50)
  288. myExcel.Selection.ShapeRange.IncrementTop(0)
  289. End Sub
  290. Private Sub FF(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  291. If HX_ch.Checked = True And PGS_ch.Checked = False Then
  292. myExcel.ActiveSheet.PageSetup.CenterHeaderPicture.Filename =
  293. Str01 & "\HXBWLOG.png"
  294. Else
  295. myExcel.ActiveSheet.PageSetup.CenterHeaderPicture.Filename =
  296. Str01 & "\PGSBWLOG.png"
  297. End If
  298. myExcel.Application.PrintCommunication = False
  299. With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$10" : .PrintTitleColumns = "" : End With
  300. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  301. With myExcel.ActiveSheet.PageSetup : .LeftHeader = ""
  302. .CenterHeader = "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "&G"
  303. .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = ""
  304. .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945) : .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  305. .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992) : .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  306. .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126) : .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  307. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = False : .CenterVertically = False : .Draft = False
  308. .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False : .OddAndEvenPagesHeaderFooter = False
  309. .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True : .EvenPage.LeftHeader.Text = ""
  310. .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = "" : .EvenPage.CenterFooter.Text = ""
  311. .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = "" : .FirstPage.RightHeader.Text = ""
  312. .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  313. End With : myExcel.Application.PrintCommunication = True
  314. End Sub
  315. End Class