Option Strict Off Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle Imports Microsoft.Office.Interop.Excel.Constants Imports Microsoft.Office.Interop.Excel.XlBordersIndex Imports Microsoft.Office.Interop.Excel.XlLineStyle Imports Microsoft.Office.Interop.Excel.XlBorderWeight Imports Microsoft.Office.Interop.Excel.XlThemeFont Imports Microsoft.Office.Interop.Excel.XlThemeColor Imports Microsoft.Office.Interop.Excel.XlWindowState Imports Microsoft.Office.Interop.Excel Public Class 樣品物料調料單申請 Private ReadOnly ds, ds1, ds2 As New DataSet Dim DTP1, 位置1 As String Dim 已超出 As Boolean Dim N1, NUM1 As Integer Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet Private Sub Set_清單() 調料單_dgv.DataSource = Nothing : ds.Clear() 調料單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 調料單_dgv.ColumnHeadersHeight = 25 調料單_dgv.AllowUserToAddRows = False SQL_調料單清單() da.Fill(ds) : 調料單_dgv.DataSource = ds.Tables(0) : conn.Close() 調料單_dgv.Columns(0).FillWeight = 110 : 調料單_dgv.Columns(1).FillWeight = 130 : 調料單_dgv.Columns(2).FillWeight = 130 : 調料單_dgv.Columns(3).FillWeight = 70 調料單_dgv.Columns(4).FillWeight = 70 調料單_dgv.Columns(5).Visible = False : 調料單_dgv.Columns(6).Visible = False : 調料單_dgv.Columns(7).Visible = False : 調料單_dgv.Columns(8).Visible = False 調料單_dgv.Columns(9).Visible = False : 調料單_dgv.Columns(10).Visible = False End Sub Private Sub Set_使用者清單() 明細_dgv.DataSource = Nothing : ds1.Clear() 明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 明細_dgv.ColumnHeadersHeight = 25 明細_dgv.AllowUserToAddRows = False 明細_dgv.RowTemplate.Height = 35 SQL_明細清單() da.Fill(ds1) : 明細_dgv.DataSource = ds1.Tables(0) : conn.Close() 明細_dgv.Columns(0).Visible = False : 明細_dgv.Columns(1).FillWeight = 80 : 明細_dgv.Columns(2).FillWeight = 200 : 明細_dgv.Columns(3).FillWeight = 200 明細_dgv.Columns(4).FillWeight = 200 明細_dgv.Columns(5).FillWeight = 80 : 明細_dgv.Columns(6).FillWeight = 80 : 明細_dgv.Columns(7).FillWeight = 80 : 明細_dgv.Columns(8).FillWeight = 80 : 明細_dgv.Columns(9).FillWeight = 305 明細_dgv.Columns(8).DefaultCellStyle.Format = "#,##0.00" : 明細_dgv.Columns(6).DefaultCellStyle.Format = "#,##0.00" : 明細_dgv.Columns(7).DefaultCellStyle.Format = "#,##0.00" 明細_dgv.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight 明細_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight 明細_dgv.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight 明細_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight 明細_dgv.EditMode = DataGridViewEditMode.EditOnEnter 明細_dgv.Columns("項次").ReadOnly = True : 明細_dgv.Columns("金額").ReadOnly = True 總金額_tb.Text = "0.00" For i As Integer = 0 To 明細_dgv.Rows.Count - 1 總金額_tb.Text = Val(總金額_tb.Text) + 明細_dgv.Rows(i).Cells("金額").Value Next i 總金額_tb.Text = Strings.Format(Val(總金額_tb.Text), "#,##0.00") End Sub Private Sub ComboBox1下拉表單資料載入() SQL_廠商類別() 供應商_cb.Items.Clear() : 供應商編碼_cb.Items.Clear() While (dr.Read()) : 供應商_cb.Items.Add(dr("廠商")) : 供應商編碼_cb.Items.Add(dr("供應商編碼")) : End While : conn.Close() End Sub Private Sub ComboBox下拉表單資料載入() SQL_廠商停用() 供應商_cb.Items.Clear() : 供應商編碼_cb.Items.Clear() While (dr.Read()) : 供應商_cb.Items.Add(dr("廠商")) : 供應商編碼_cb.Items.Add(dr("供應商編碼")) : End While : conn.Close() End Sub Private Sub ComboBox3下拉表單資料載入() SQL_權限表() 發件人_cb.Items.Clear() : 提取人_cb.Items.Clear() While (dr.Read()) : 發件人_cb.Items.Add(dr("姓名")) : 提取人_cb.Items.Add(dr("姓名")) : End While : conn.Close() End Sub Private Sub ComboBox5下拉表單資料載入() SQL_年份清單() 年份_cb.Items.Clear() : While (dr.Read()) : 年份_cb.Items.Add(dr("年份")) : End While : conn.Close() End Sub Private Sub ComboBox7下拉表單資料載入() SQL_客戶表() for_cb.Items.Clear() : While (dr.Read()) : for_cb.Items.Add(dr("客戶簡稱")) : End While : conn.Close() End Sub Private Sub ComboBox18下拉表單資料載入() SQL_公司傳真() 廠商類別_cb.Items.Clear() : While (dr.Read()) : 廠商類別_cb.Items.Add(dr("類別")) : End While : conn.Close() End Sub Private Sub Set_日期格式轉換() DTP = Strings.Format(日期_dtp.Value, "yyyy/MM/dd") : DTP1 = Strings.Format(Today(), "yyyyMMdd") End Sub Private Sub 樣品物料調料單_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True Set_清單() : ComboBox18下拉表單資料載入() : ComboBox3下拉表單資料載入() : ComboBox5下拉表單資料載入() : ComboBox7下拉表單資料載入() 申請完成_bt.Enabled = False : 新增_bt.Enabled = False : 刪除_bt.Enabled = False : 修改_bt.Enabled = False : 修改存檔_bt.Enabled = False : 刪除1_bt.Enabled = False 樣品物料調料單單號_tb.Enabled = False : 項次_tb.Enabled = False End Sub Private Sub 樣品物料調料單_Unload(sender As Object, e As EventArgs) Handles MyBase.Closing If 申請完成_bt.Enabled = True Then SQL_刪除樣品物料調料單抬頭() : conn.Close() SQL_刪除樣品物料調料單明細() : conn.Close() End If End Sub Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 調料單_dgv.CellClick If e.RowIndex = -1 Then : Else ComboBox下拉表單資料載入() 樣品物料調料單單號_tb.Text = 調料單_dgv.Rows(e.RowIndex).Cells("調料單號").Value.ToString : 修改_bt.Enabled = True : 刪除1_bt.Enabled = True 供應商編碼_cb.Text = 調料單_dgv.Rows(e.RowIndex).Cells("供應商編號").Value : 發件人_cb.Text = 調料單_dgv.Rows(e.RowIndex).Cells("發件人").Value 提取人_cb.Text = 調料單_dgv.Rows(e.RowIndex).Cells("收件人").Value : 日期_dtp.Value = 調料單_dgv.Rows(e.RowIndex).Cells("日期").Value 制表人_tb.Text = 調料單_dgv.Rows(e.RowIndex).Cells("制表人").Value : for_cb.Text = 調料單_dgv.Rows(e.RowIndex).Cells("客戶").Value 年份_cb.Text = 調料單_dgv.Rows(e.RowIndex).Cells("SHOW年").Value : 月份_cb.Text = 調料單_dgv.Rows(e.RowIndex).Cells("SHOW月").Value Set_使用者清單() End If End Sub Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 明細_dgv.CellClick If e.RowIndex = -1 Then : Else 項次_tb.Text = 明細_dgv.Rows(e.RowIndex).Cells("項次").Value End If End Sub Private Sub DataGridView2_CellContentClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 明細_dgv.CellEndEdit 總金額_tb.Text = "0.00" For i As Integer = 0 To 明細_dgv.Rows.Count - 1 明細_dgv.Rows(i).Cells("金額").Value = Val(明細_dgv.Rows(i).Cells("數量").Value) * Val(明細_dgv.Rows(i).Cells("單價").Value) 總金額_tb.Text = Val(總金額_tb.Text) + 明細_dgv.Rows(i).Cells("金額").Value Next i 總金額_tb.Text = Strings.Format(Val(總金額_tb.Text), "#,##0.00") End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick If 尚未存檔_lb.Visible = True Then : 尚未存檔_lb.Visible = False : Else : 尚未存檔_lb.Visible = True : End If End Sub Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 供應商_cb.SelectedIndexChanged 供應商編碼_cb.SelectedIndex = 供應商_cb.SelectedIndex End Sub Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 供應商編碼_cb.SelectedIndexChanged 供應商_cb.SelectedIndex = 供應商編碼_cb.SelectedIndex SQL_供應商清單() If dr.Read() Then : 供應商公司全稱_tb.Text = dr("公司名") : 供應商聯繫人_tb.Text = dr("聯繫人1") : 供應商公司電話_tb.Text = dr("公司電話1") : End If conn.Close() End Sub Private Sub ComboBox18_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles 廠商類別_cb.SelectedIndexChanged ComboBox1下拉表單資料載入() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles 開立樣品物料調料單_bt.Click Timer1.Enabled = True : 調料單_dgv.Enabled = False 開立樣品物料調料單_bt.Enabled = False : 申請完成_bt.Enabled = True : 新增_bt.Enabled = True : 刪除_bt.Enabled = True Set_日期格式轉換() : Dim NUM1 As Integer For i As Integer = 1 To 999 NUM1 = 0 + i If NUM1 < 10 Then : 樣品物料調料單單號_tb.Text = "L-" & DTP1 & "-00" & NUM1 ElseIf NUM1 > 9 And NUM1 < 100 Then : 樣品物料調料單單號_tb.Text = "L-" & DTP1 & "-0" & NUM1 ElseIf NUM1 > 99 Then : 樣品物料調料單單號_tb.Text = "L-" & DTP1 & "-" & NUM1 End If SQL_新增調料單號() If dr.Read() Then Else i = 999 conn.Close() End If conn.Close() Next SQL_新增樣品物料調料單抬頭() 明細_dgv.DataSource = Nothing : ds1.Clear() conn.Close() End Sub Private Sub Button5_Click(sender As Object, e As EventArgs) Handles 刪除1_bt.Click Dim aa As MsgBoxResult aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel) If aa = MsgBoxResult.Ok Then SQL_刪除樣品物料調料單抬頭() : conn.Close() SQL_刪除樣品物料調料單明細() : conn.Close() 樣品物料調料單單號_tb.Text = "" : 供應商公司全稱_tb.Text = "" : 供應商聯繫人_tb.Text = "" : 供應商公司電話_tb.Text = "" ComboBox18下拉表單資料載入() : ComboBox3下拉表單資料載入() : ComboBox5下拉表單資料載入() : ComboBox7下拉表單資料載入() 明細_dgv.DataSource = Nothing : ds1.Clear() Set_清單() End If End Sub Private Sub 存檔1() Set_日期格式轉換() SQL_修改樣品物料調料單抬頭() conn.Close() End Sub Private Sub 存檔() For i As Integer = 0 To 明細_dgv.Rows.Count - 1 資料數 = 明細_dgv.Rows.Count : MyModule1.進度條() PA5 = 明細_dgv.Rows(i).Cells("名稱").Value : PA6 = 明細_dgv.Rows(i).Cells("規格").Value PA7 = 明細_dgv.Rows(i).Cells("顏色").Value : PA8 = 明細_dgv.Rows(i).Cells("單位").Value PA9 = 明細_dgv.Rows(i).Cells("數量").Value : PA10 = 明細_dgv.Rows(i).Cells("單價").Value PA11 = 明細_dgv.Rows(i).Cells("備註").Value : PA12 = 明細_dgv.Rows(i).Cells("項次").Value SQL_修改樣品物料調料單明細() conn.Close() Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 End Sub Private Sub Button6_Click(sender As Object, e As EventArgs) Handles 新增_bt.Click 存檔() SQL_查詢最後一筆項次1() If dr.Read() Then : 新項次 = dr("項次") : Else : 新項次 = "00" : End If : conn.Close() NUM1 = Double.Parse(新項次) + 1 If NUM1 < 10 Then : 新項次 = "0" & NUM1 ElseIf NUM1 > 9 And NUM1 < 100 Then : 新項次 = NUM1 End If SQL_新增樣品物料調料單明細() : conn.Close() Set_使用者清單() End Sub Private Sub Button15_Click(sender As Object, e As EventArgs) Handles 刪除_bt.Click If 項次_tb.Text = "" Then MsgBox("未選擇需要刪除的資料") Else 存檔() SQL_刪除樣品物料調料單明細2() conn.Close() Set_使用者清單() Dim NUM1 As Integer = 0 For i As Integer = 0 To 明細_dgv.Rows.Count - 1 NUM1 += 1 : If NUM1 < 10 Then : 新項次 = "0" & NUM1 : ElseIf NUM1 > 9 And NUM1 < 100 Then : 新項次 = NUM1 : End If PA16 = 明細_dgv.Rows(i).Cells("項次").Value SQL_修改項次1() conn.Close() Next Set_使用者清單() End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles 申請完成_bt.Click 調料單_dgv.Enabled = True If 供應商_cb.Text = "" Or 發件人_cb.Text = "" Or 提取人_cb.Text = "" Or 年份_cb.Text = "" Or 月份_cb.Text = "" Or for_cb.Text = "" Then MsgBox("所有的下拉清單都要選擇,請重新確定資料是否正確。") Else If 供應商公司全稱_tb.Text = "" Or 供應商聯繫人_tb.Text = "" Or 供應商公司電話_tb.Text = "" Then MsgBox("供應商資料內容有缺失,請先完善供應商資料。") Else Timer1.Enabled = False : 尚未存檔_lb.Visible = False 開立樣品物料調料單_bt.Enabled = True : 申請完成_bt.Enabled = False : 新增_bt.Enabled = False : 刪除_bt.Enabled = False 存檔1() : 存檔() : 制表人_tb.Text = gUserName MsgBox("申請完成,請通知主管核準。") : Set_清單() End If End If End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles 修改_bt.Click 修改_bt.Enabled = False : 修改存檔_bt.Enabled = True : 新增_bt.Enabled = True : 刪除_bt.Enabled = True : Timer1.Enabled = True 調料單_dgv.Enabled = False End Sub Private Sub Button4_Click(sender As Object, e As EventArgs) Handles 修改存檔_bt.Click If 供應商_cb.Text = "" Or 發件人_cb.Text = "" Or 提取人_cb.Text = "" Or 年份_cb.Text = "" Or 月份_cb.Text = "" Or for_cb.Text = "" Then MsgBox("所有的下拉清單都要選擇,請重新確定資料是否正確。") Else If 供應商公司全稱_tb.Text = "" Or 供應商聯繫人_tb.Text = "" Or 供應商公司電話_tb.Text = "" Then MsgBox("供應商資料內容有缺失,請先完善供應商資料。") Else 調料單_dgv.Enabled = True Timer1.Enabled = False : 尚未存檔_lb.Visible = False 修改_bt.Enabled = True : 修改存檔_bt.Enabled = False : 新增_bt.Enabled = False : 刪除_bt.Enabled = False 存檔1() : 存檔() : 制表人_tb.Text = gUserName MsgBox("申請完成,請通知主管核準。") : Set_清單() End If End If End Sub Private Sub 明細_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 明細_dgv.MouseUp If 明細_dgv.SelectedCells.Count = 1 Then 已超出 = False End If If 明細_dgv.SelectedCells.Count > 0 Then '設定滑鼠點擊DGV時候的範圍,超出範圍時有可能不是數字所以不計算 If 明細_dgv.SelectedCells(0).ColumnIndex = 6 Or 明細_dgv.SelectedCells(0).ColumnIndex = 8 Then If 已超出 = False Then Dim x As Double = 0 For i As Integer = 0 To 明細_dgv.SelectedCells.Count - 1 '明細_dgv.SelectedCells.Item(i).ColumnIndex + 8 是因為該DGV顯示項與計算像剛好差8格,使用時要注意可直接計算的不需要加數字。 x += Val(明細_dgv.Rows(明細_dgv.SelectedCells.Item(i).RowIndex).Cells(明細_dgv.SelectedCells.Item(i).ColumnIndex).Value) Next i '將計算好的資料放置到指定的控件中 WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(x, "#,##0.00") Else WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0.00") End If Else 已超出 = True WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0.00") End If End If End Sub Private Sub Button7_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click xlApp = CType(CreateObject("Excel.Application"), Application) xlBook = xlApp.Workbooks.Add xlApp.DisplayAlerts = True xlBook.Activate() xlSheet = NewMethod(xlBook) xlSheet.Activate() xlApp.Visible = True xlApp.Application.WindowState = xlMaximized xlSheet.Cells(1, 1) = "森康鞋業有限公司 SenKang Footwear Ltd." xlSheet.Cells(3, 1) = "廣東東莞市厚街鎮湖景大道南150米 TEL:0769-38851258 FAX:0769-38851259" : xlSheet.Cells(6, 1) = "MATERIALS REQUEST FORM" : xlSheet.Cells(7, 1) = " 物料调料单" xlSheet.Cells(8, 1) = "Purchase NO#" : xlSheet.Cells(8, 3) = 樣品物料調料單單號_tb.Text : xlSheet.Cells(10, 1) = "TO:" : xlSheet.Cells(10, 2) = 供應商公司全稱_tb.Text xlSheet.Cells(11, 1) = "ATTN:" : xlSheet.Cells(11, 2) = 供應商聯繫人_tb.Text : xlSheet.Cells(12, 1) = "TEL:" : xlSheet.Cells(12, 2) = 供應商公司電話_tb.Text xlSheet.Cells(10, 10) = "DATE:" : xlSheet.Cells(10, 11) = 日期_dtp.Value : xlSheet.Cells(11, 10) = "FROM:" : xlSheet.Cells(11, 11) = 發件人_cb.Text xlSheet.Cells(12, 10) = "EXT:" : xlSheet.Cells(12, 11) = 提取人_cb.Text : xlSheet.Cells(14, 1) = "PLS ALWAYS REFER TO OUR PO#请于送货单上注明我们的订单号码" xlSheet.Cells(16, 1) = "Item" : xlSheet.Cells(16, 2) = "Description" : xlSheet.Cells(16, 4) = "Spec" : xlSheet.Cells(16, 6) = "Color" : xlSheet.Cells(16, 7) = "Unit" xlSheet.Cells(16, 8) = "Q'TY" : xlSheet.Cells(16, 9) = "Unit Price" : xlSheet.Cells(16, 10) = "Amount" : xlSheet.Cells(16, 11) = "Remark" : xlSheet.Cells(17, 1) = "项次" xlSheet.Cells(17, 2) = "名称" : xlSheet.Cells(17, 4) = "規格" : xlSheet.Cells(17, 6) = "颜色" : xlSheet.Cells(17, 7) = "单位" : xlSheet.Cells(17, 8) = "数量" xlSheet.Cells(17, 9) = "单价" : xlSheet.Cells(17, 10) = "金额" : xlSheet.Cells(17, 11) = "备注" For i As Integer = 0 To 明細_dgv.Rows.Count - 1 xlSheet.Cells(i + 18, 1) = 明細_dgv.Rows(i).Cells("項次").Value : xlSheet.Cells(i + 18, 2) = 明細_dgv.Rows(i).Cells("名稱").Value xlSheet.Cells(i + 18, 4) = 明細_dgv.Rows(i).Cells("規格").Value : xlSheet.Cells(i + 18, 6) = 明細_dgv.Rows(i).Cells("顏色").Value xlSheet.Cells(i + 18, 7) = 明細_dgv.Rows(i).Cells("單位").Value : xlSheet.Cells(i + 18, 8) = 明細_dgv.Rows(i).Cells("數量").Value xlSheet.Cells(i + 18, 9) = 明細_dgv.Rows(i).Cells("單價").Value : xlSheet.Cells(i + 18, 10) = 明細_dgv.Rows(i).Cells("金額").Value xlSheet.Cells(i + 18, 11) = 明細_dgv.Rows(i).Cells("備註").Value With xlApp.Selection .Font.Bold = True End With N1 = i + 18 Next i xlSheet.Cells(N1 + 1, 6) = "TOTAL:" : xlSheet.Cells(N1 + 1, 8) = "=SUM(H18:H" & N1 & ")" : xlSheet.Cells(N1 + 1, 10) = "=SUM(J18:J" & N1 & ")" : xlSheet.Cells(N1 + 2, 4) = "'AMOUNT金额(大写):" xlSheet.Cells(N1 + 2, 8) = "=J" & N1 + 1 : xlSheet.Cells(N1 + 3, 3) = "FOR" : xlSheet.Cells(N1 + 3, 4) = for_cb.Text : xlSheet.Cells(N1 + 3, 7) = 年份_cb.Text : xlSheet.Cells(N1 + 3, 9) = "SHOW" xlSheet.Cells(N1 + 3, 8) = 月份_cb.Text : xlSheet.Cells(N1 + 5, 1) = "样品请寄:廣東東莞市厚街鎮湖景大道南150米森康鞋業有限公司 人名 電話 收。" xlSheet.Cells(N1 + 7, 1) = "IMPORTANT: **请回复交期并提供物料报价" : xlSheet.Cells(N1 + 11, 3) = "驗證碼" : xlSheet.Cells(N1 + 11, 4) = "" : xlSheet.Cells(N1 + 12, 3) = "核准:" xlSheet.Cells(N1 + 12, 10) = "制表人:" : xlSheet.Cells(N1 + 12, 11) = 制表人_tb.Text AA(xlApp, xlSheet) xlSheet.PageSetup.PrintArea = "" xlApp.Cells.Select() xlSheet.Range("B1").Select() xlApp.Application.WindowState = xlMinimized xlApp.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="0911274990") xlApp.ActiveSheet.EnableSelection = 1 MsgBox("列印完成") End Sub Private Shared Function NewMethod(xlBook As Workbook) As Worksheet Return CType(xlBook.Worksheets.Add, Worksheet) End Function Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet) xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 5.86 : xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 8 xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 30 : xlSheet.Columns("D:E").Select : myExcel.Selection.ColumnWidth = 10 xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 20 : xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 6.47 xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 10 : xlSheet.Columns("I:I").Select : myExcel.Selection.ColumnWidth = 12 xlSheet.Columns("J:J").Select : myExcel.Selection.ColumnWidth = 12 : xlSheet.Columns("K:K").Select : myExcel.Selection.ColumnWidth = 25.14 xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 86 : xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 8.25 xlSheet.Rows("4:5").Select : myExcel.Selection.RowHeight = 8.25 : xlSheet.Rows("9:9").Select : myExcel.Selection.RowHeight = 8.25 xlSheet.Rows("13:13").Select : myExcel.Selection.RowHeight = 8.25 : xlSheet.Rows("14:14").Select : myExcel.Selection.RowHeight = 25 xlSheet.Rows("15:15").Select : myExcel.Selection.RowHeight = 8.25 xlSheet.Range("A1:K1").Select() : myExcel.Selection.Merge With myExcel.Selection.Font : .Name = "新細明體" : .Size = 28 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontMinor : End With xlSheet.Range("A3:K3").Select() : myExcel.Selection.Merge : myExcel.Selection.Font.Bold = True xlSheet.Range("A6:K6").Select() : myExcel.Selection.Merge : myExcel.Selection.Font.Bold = True xlSheet.Range("A7:K7").Select() : myExcel.Selection.Merge : myExcel.Selection.Font.Bold = True xlSheet.Range("B10:I10").Select() : myExcel.Selection.Merge With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("B11:I11").Select() : myExcel.Selection.Merge With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("B12:I12").Select() : myExcel.Selection.Merge With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("K10").Select() With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Rows("14:14").Select : myExcel.Selection.Font.Bold = True xlSheet.Range("B16:C16").Select() : myExcel.Selection.Merge : xlSheet.Range("D16:E16").Select() : myExcel.Selection.Merge xlSheet.Range("B17:C17").Select() : myExcel.Selection.Merge : xlSheet.Range("D17:E17").Select() : myExcel.Selection.Merge xlSheet.Range("A16:K17").Select() : myExcel.Selection.Font.Bold = True xlSheet.Rows("8:8").Select : myExcel.Selection.Font.Bold = True 位置1 = "18:" & N1 : xlSheet.Range(位置1).Select() : myExcel.Selection.RowHeight = 35.25 位置1 = N1 + 5 & ":" & N1 + 5 : xlSheet.Range(位置1).Select() : myExcel.Selection.RowHeight = 35.25 : 位置1 = N1 + 1 & ":" & N1 + 3 : xlSheet.Range(位置1).Select() : myExcel.Selection.RowHeight = 20 位置1 = N1 + 4 & ":" & N1 + 4 : xlSheet.Range(位置1).Select() : myExcel.Selection.RowHeight = 8.5 : 位置1 = N1 + 6 & ":" & N1 + 6 : xlSheet.Range(位置1).Select() : myExcel.Selection.RowHeight = 8.5 位置1 = N1 + 8 & ":" & N1 + 10 : xlSheet.Range(位置1).Select() : myExcel.Selection.RowHeight = 8.5 For i As Integer = 18 To N1 xlSheet.Range("B" & i & ":C" & i & "").Select() : myExcel.Selection.Merge : xlSheet.Range("D" & i & ":E" & i & "").Select() : myExcel.Selection.Merge xlSheet.Range("H" & i & ":J" & i & "").Select() : myExcel.Selection.Style = "Comma" Next i xlSheet.Rows("18:" & N1 + 2).Select With myExcel.Selection.Font : .Name = "新細明體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontMinor : End With xlSheet.Range("C" & N1 + 3).Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("D" & N1 + 3 & ":F" & N1 + 3).Select() : myExcel.Selection.Merge xlSheet.Range("A" & N1 + 5 & ":K" & N1 + 5).Select() : myExcel.Selection.Merge With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("A16:K" & N1).Select() myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With xlSheet.Range("A4:K4").Select() myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xlSheet.Range("A9:K9").Select() myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xlSheet.Range("A12:K12").Select() myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xlSheet.Range("D" & N1 + 2 & ":G" & N1 + 2).Select() : myExcel.Selection.Merge xlSheet.Range("H" & N1 + 2 & ":J" & N1 + 2).Select() : myExcel.Selection.Merge xlSheet.Range("H" & N1 + 2 & ":J" & N1 + 2).Select() : myExcel.Selection.NumberFormatLocal = "[DBNum2][$-zh-CN]G/通用格式" myExcel.ActiveWindow.Zoom = 80 : myExcel.ActiveWindow.DisplayGridlines = False xlSheet.Range("C" & N1 + 11).Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("C" & N1 + 12).Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("A" & N1 + 5 & ":K" & N1 + 5).Select() myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xlSheet.Range("A7:K7").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("A6:K6").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("A3:K3").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("A1:K1").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("N12").Select() xlSheet.Range("B18:C" & N1).Select() With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : End With xlSheet.Range("D18:F" & N1).Select() With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : End With End Sub End Class