Option Strict Off
Imports System.Data.SqlClient
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
Public Class 列印_量產訂單控制表
    Dim conn As New SqlConnection
    Dim da As New SqlDataAdapter
    Dim cmd As New SqlCommand
    Dim ds As New DataSet
    Dim dr As SqlDataReader
    Dim OPEXC(5) As Boolean
    Dim P As Integer = 0 : Dim R As Integer = 0 : Dim A As Integer = 0 : Dim Q As Integer = 0 : Dim G As Integer = 0 : Dim H As Integer = 0 : Dim J As Integer = 0
    Dim 位置1 As String : Dim 位置2 As String : Dim 位置3 As String : Dim 位置4 As String : Dim 位置5 As String : Dim 位置6 As String : Dim 位置7 As String
    Dim xlApp As Microsoft.Office.Interop.Excel.Application
    Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
    Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
    Dim SQL字串1 As String = "SELECT  訂單流水號, 年份季度, 客戶訂單號, 型體號碼, GOODBOX AS 型體名稱, APMA確認 AS 顏色, TVW AS 楦型, 訂單數量, 工廠回復交期 AS 工廠交期, 客戶交期 AS 交期開始, 
                                      客戶交期1 AS 交期結束, 單價, 總金額, 備註, 生產工廠, 訂單種類, BUYER, CFMSPEC AS 訂單屬性, 明細建檔, 材質, 東莞業務備註, LEATHER AS 手剪全套, LEA_Note AS 斬刀全套, 
                                      面料, 副料, 中底, 鞋墊, 大底, 跟, 包裝確認時間 AS 包裝, 裁斷時間, 針車時間, 成型時間, 驗貨時間, 工廠進度表備註1 AS 驗貨結果, 工廠進度表備註2 AS 工廠備註, 
                                      資料流水號, 實際離廠日, 出貨數量, CXL, CXLTime, 驗貨報告圖片,
                                      CFMSAMPLE, TRIAL1, TRIAL2, TRIAL3, TRIAL4, 貼標時間, PO_S_Date, Requested_XF, Confirm_XF, Revised_XF, 
                                      Special_Packaging, Remarks, 出貨地, 楦頭號, 長期試穿, 七號模具, 國標測試, 客戶包裝確認
                              FROM 訂單控制表 "
    Dim SQL字串2 As String = " ORDER BY 訂單流水號 DESC, 型體號碼, APMA確認, TVW"
    Private Sub Set_DGV1載入前設定()
        DataGridView1.DataSource = Nothing : ds.Clear()
        DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView1.ColumnHeadersHeight = 25
        DataGridView1.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub Set_DGV1載入後設定()
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.SelectCommand.CommandTimeout = 900 : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_訂單清單()
        Set_DGV1載入前設定()
        If OPEXC(0) = True Then
            SQL1 = SQL字串1 & 列印用SQL & " WHERE ((CXL = 0) OR (CXL IS NULL)) AND (訂單數量 - 出貨數量 <> 0) AND (CFMSPEC LIKE 'LANDED BRANDED')" & SQL字串2
        ElseIf OPEXC(1) = True Then
            SQL1 = SQL字串1 & 列印用SQL & "WHERE ((CXL = 0) OR (CXL IS NULL)) AND (訂單數量 - 出貨數量 <> 0)  AND (CFMSPEC LIKE 'FIRST COST')" & SQL字串2
        ElseIf OPEXC(2) = True Then
            SQL1 = SQL字串1 & 列印用SQL & " WHERE ((CXL = 0) OR (CXL IS NULL)) AND (訂單數量 - 出貨數量 = 0) AND (CFMSPEC LIKE 'LANDED BRANDED')" & SQL字串2
        ElseIf OPEXC(3) = True Then
            SQL1 = SQL字串1 & 列印用SQL & " WHERE ((CXL = 0) OR (CXL IS NULL)) AND (訂單數量 - 出貨數量 = 0) AND (CFMSPEC LIKE 'FIRST COST')" & SQL字串2
        ElseIf OPEXC(4) = True Then
            SQL1 = SQL字串1 & 列印用SQL & " WHERE (CXL = 1) AND (CFMSPEC LIKE 'LANDED BRANDED')" & SQL字串2
        ElseIf OPEXC(5) = True Then
            SQL1 = SQL字串1 & 列印用SQL & " WHERE (CXL = 1) AND (CFMSPEC LIKE 'FIRST COST')" & SQL字串2
        End If
        Set_DGV1載入後設定()
    End Sub
    Private Sub Set_循環列印()
        Dim W As Integer = 2
        If CheckBox1.Checked = True Then : xlSheet.Cells(3, W) = "巨益 PO#" : Q = W : W = W + 1 : End If
        If CheckBox2.Checked = True Then : xlSheet.Cells(3, W) = "SEASON" : Q = W : W = W + 1 : End If
        If CheckBox3.Checked = True Then : xlSheet.Cells(3, W) = "CUST PO#" : Q = W : W = W + 1 : End If
        If CheckBox4.Checked = True Then : xlSheet.Cells(3, W) = "STYLE#" : Q = W : W = W + 1 : End If
        If CheckBox5.Checked = True Then : xlSheet.Cells(3, W) = "STYLE NAME" : Q = W : W = W + 1 : End If
        If CheckBox6.Checked = True Then : xlSheet.Cells(3, W) = "COLOR" : Q = W : W = W + 1 : End If
        If CheckBox7.Checked = True Then : xlSheet.Cells(3, W) = "DM" : Q = W : W = W + 1 : End If
        If CheckBox8.Checked = True Then : xlSheet.Cells(3, W) = "PRS" : Q = W : W = W + 1 : End If
        If CheckBox9.Checked = True Then : xlSheet.Cells(3, W) = "FTY X/F" : Q = W : W = W + 1 : End If
        If CheckBox10.Checked = True Then : xlSheet.Cells(3, W) = "CUST START XF" : Q = W : W = W + 1 : End If
        If CheckBox11.Checked = True Then : xlSheet.Cells(3, W) = "CUST CXL XF" : Q = W : W = W + 1 : End If
        If CheckBox12.Checked = True Then : xlSheet.Cells(3, W) = "PRICE" : Q = W : W = W + 1 : End If
        If CheckBox13.Checked = True Then : xlSheet.Cells(3, W) = "AMOUNT" : Q = W : W = W + 1 : End If
        If CheckBox14.Checked = True Then : xlSheet.Cells(3, W) = "REMARK" : Q = W : W = W + 1 : End If
        If CheckBox15.Checked = True Then : xlSheet.Cells(3, W) = "FTY" : Q = W : W = W + 1 : End If
        If CheckBox16.Checked = True Then : xlSheet.Cells(3, W) = "DIV" : Q = W : W = W + 1 : End If
        If CheckBox17.Checked = True Then : xlSheet.Cells(3, W) = "BUYER" : Q = W : W = W + 1 : End If
        If CheckBox18.Checked = True Then : xlSheet.Cells(3, W) = "材質" : Q = W : W = W + 1 : End If
        If CheckBox19.Checked = True Then : xlSheet.Cells(3, W) = "東莞業務備註" : Q = W : W = W + 1 : End If
        If CheckBox20.Checked = True Then : xlSheet.Cells(3, W) = "Pattern trial full size" : Q = W : W = W + 1 : End If
        If CheckBox21.Checked = True Then : xlSheet.Cells(3, W) = "Cutting dies full size" : Q = W : W = W + 1 : End If
        If CheckBox22.Checked = True Then : xlSheet.Cells(3, W) = "面料" : Q = W : W = W + 1 : End If
        If CheckBox23.Checked = True Then : xlSheet.Cells(3, W) = "副料" : Q = W : W = W + 1 : End If
        If CheckBox24.Checked = True Then : xlSheet.Cells(3, W) = "中底" : Q = W : W = W + 1 : End If
        If CheckBox25.Checked = True Then : xlSheet.Cells(3, W) = "鞋墊" : Q = W : W = W + 1 : End If
        If CheckBox26.Checked = True Then : xlSheet.Cells(3, W) = "大底" : Q = W : W = W + 1 : End If
        If CheckBox27.Checked = True Then : xlSheet.Cells(3, W) = "跟" : Q = W : W = W + 1 : End If
        If CheckBox28.Checked = True Then : xlSheet.Cells(3, W) = "包裝" : Q = W : W = W + 1 : End If
        If CheckBox29.Checked = True Then : xlSheet.Cells(3, W) = "cutting" : Q = W : W = W + 1 : End If
        If CheckBox30.Checked = True Then : xlSheet.Cells(3, W) = "stitching" : Q = W : W = W + 1 : End If
        If CheckBox31.Checked = True Then : xlSheet.Cells(3, W) = "lasting" : Q = W : W = W + 1 : End If
        If CheckBox32.Checked = True Then : xlSheet.Cells(3, W) = "inspection" : Q = W : W = W + 1 : End If
        If CheckBox33.Checked = True Then : xlSheet.Cells(3, W) = "result" : Q = W : W = W + 1 : End If
        If CheckBox34.Checked = True Then : xlSheet.Cells(3, W) = "工廠備註" : Q = W : W = W + 1 : End If
        If CheckBox35.Checked = True Then : xlSheet.Cells(3, W) = "資料流水號" : Q = W : W = W + 1 : End If
        If CheckBox36.Checked = True Then : xlSheet.Cells(3, W) = "實際離廠日" : Q = W : W = W + 1 : End If
        If CheckBox37.Checked = True Then : xlSheet.Cells(3, W) = "出貨數量" : Q = W : W = W + 1 : End If
        If CheckBox38.Checked = True Then : xlSheet.Cells(3, W) = "CXLTime" : Q = W : W = W + 1 : End If
        If CheckBox39.Checked = True Then : xlSheet.Cells(3, W) = "驗貨報告圖片" : Q = W : W = W + 1 : End If
        Set_訂單清單()
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            W = 2
            If CheckBox1.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("訂單流水號").Value : W = W + 1 : End If
            If CheckBox2.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("年份季度").Value : W = W + 1 : End If
            If CheckBox3.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("客戶訂單號").Value : W = W + 1 : End If
            If CheckBox4.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("型體號碼").Value : W = W + 1 : End If
            If CheckBox5.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("型體名稱").Value : W = W + 1 : End If
            If CheckBox6.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("顏色").Value : W = W + 1 : End If
            If CheckBox7.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("楦型").Value : W = W + 1 : End If
            If CheckBox8.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("訂單數量").Value : P = W : W = W + 1 : End If
            If CheckBox9.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("工廠交期").Value : G = W : W = W + 1 : End If
            If CheckBox10.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("交期開始").Value : H = W : W = W + 1 : End If
            If CheckBox11.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("交期結束").Value : J = W : W = W + 1 : End If
            If CheckBox12.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("單價").Value : R = W : W = W + 1 : End If
            If CheckBox13.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("總金額").Value : A = W : W = W + 1 : End If
            If CheckBox14.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("備註").Value : W = W + 1 : End If
            If CheckBox15.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("生產工廠").Value : W = W + 1 : End If
            If CheckBox16.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("訂單種類").Value : W = W + 1 : End If
            If CheckBox17.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("BUYER").Value : W = W + 1 : End If
            If CheckBox18.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("材質").Value : W = W + 1 : End If
            If CheckBox19.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("東莞業務備註").Value : W = W + 1 : End If
            If CheckBox20.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("手剪全套").Value : W = W + 1 : End If
            If CheckBox21.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("斬刀全套").Value : W = W + 1 : End If
            If CheckBox22.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("面料").Value : W = W + 1 : End If
            If CheckBox23.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("副料").Value : W = W + 1 : End If
            If CheckBox24.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("中底").Value : W = W + 1 : End If
            If CheckBox25.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("鞋墊").Value : W = W + 1 : End If
            If CheckBox26.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("大底").Value : W = W + 1 : End If
            If CheckBox27.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("跟").Value : W = W + 1 : End If
            If CheckBox28.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("包裝").Value : W = W + 1 : End If
            If CheckBox29.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("裁斷時間").Value : W = W + 1 : End If
            If CheckBox30.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("針車時間").Value : W = W + 1 : End If
            If CheckBox31.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("成型時間").Value : W = W + 1 : End If
            If CheckBox32.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("驗貨時間").Value : W = W + 1 : End If
            If CheckBox33.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("驗貨結果").Value : W = W + 1 : End If
            If CheckBox34.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("工廠備註").Value : W = W + 1 : End If
            If CheckBox35.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("資料流水號").Value : W = W + 1 : End If
            If CheckBox36.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("實際離廠日").Value : W = W + 1 : End If
            If CheckBox37.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("出貨數量").Value : W = W + 1 : End If
            If CheckBox38.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("CXLTime").Value : W = W + 1 : End If
            If CheckBox39.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("驗貨報告圖片").Value : W = W + 1 : End If
            With xlApp.Selection
                .Font.Bold = True
            End With
        Next i
        BB(xlApp, xlSheet)
    End Sub

    Private Sub 列印_量產訂單控制表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FormBorderStyle = FormBorderStyle.SizableToolWindow
        DataGridView1.Visible = False : CheckBox40.Checked = True : CheckBox45.Checked = False : CheckBox46.Checked = False
        If gUserName = "李協叡" Then
            CheckBox12.Visible = True : CheckBox13.Visible = True
        Else
            CheckBox12.Visible = False : CheckBox13.Visible = False
        End If
    End Sub
    Private Sub 列印1()
        xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = "LANDED BRANDED" : xlBook.Activate() : xlSheet.Activate()
        OPEXC(0) = True : OPEXC(1) = False : OPEXC(2) = False : OPEXC(3) = False : OPEXC(4) = False : OPEXC(5) = False
        xlSheet.Range("A1").Select() : xlSheet.Cells(2, 2) = "Production Schedule - LANDED BRANDED" : Set_循環列印()
    End Sub
    Private Sub 列印2()
        xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = "FIRST COST" : xlBook.Activate() : xlSheet.Activate()
        OPEXC(0) = False : OPEXC(1) = True : OPEXC(2) = False : OPEXC(3) = False : OPEXC(4) = False : OPEXC(5) = False
        xlSheet.Range("A1").Select() : xlSheet.Cells(2, 2) = "Production Schedule - FIRST COST" : Set_循環列印()
    End Sub
    Private Sub 列印3()
        xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = "LANDED BRANDED(Shipped)" : xlBook.Activate() : xlSheet.Activate()
        OPEXC(0) = False : OPEXC(1) = False : OPEXC(2) = True : OPEXC(3) = False : OPEXC(4) = False : OPEXC(5) = False
        xlSheet.Range("A1").Select() : xlSheet.Cells(2, 2) = "Production Schedule - LANDED BRANDED(Shipped)" : Set_循環列印()
    End Sub
    Private Sub 列印4()
        xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = "FIRST COST(Shipped)" : xlBook.Activate() : xlSheet.Activate()
        OPEXC(0) = False : OPEXC(1) = False : OPEXC(2) = False : OPEXC(3) = True : OPEXC(4) = False : OPEXC(5) = False
        xlSheet.Range("A1").Select() : xlSheet.Cells(2, 2) = "Production Schedule - FIRST COST(Shipped)" : Set_循環列印()
    End Sub
    Private Sub 列印5()
        xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = "LANDED BRANDED(CXL)" : xlBook.Activate() : xlSheet.Activate()
        OPEXC(0) = False : OPEXC(1) = False : OPEXC(2) = False : OPEXC(3) = False : OPEXC(4) = True : OPEXC(5) = False
        xlSheet.Range("A1").Select() : xlSheet.Cells(2, 2) = "Production Schedule - LANDED BRANDED(CXL)" : Set_循環列印()
    End Sub
    Private Sub 列印6()
        xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = "FIRST COST(CXL)" : xlBook.Activate() : xlSheet.Activate()
        OPEXC(0) = False : OPEXC(1) = False : OPEXC(2) = False : OPEXC(3) = False : OPEXC(4) = False : OPEXC(5) = True
        xlSheet.Range("A1").Select() : xlSheet.Cells(2, 2) = "Production Schedule - FIRST COST(CXL)" : Set_循環列印()
    End Sub
    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
        xlApp.Visible = True
        xlApp.DisplayAlerts = True
        xlApp.Application.WindowState = xlMaximized
        xlBook = xlApp.Workbooks.Add

        If CheckBox40.Checked = True And CheckBox45.Checked = False And CheckBox46.Checked = False Then
            列印2() : 列印1()
        ElseIf CheckBox40.Checked = False And CheckBox45.Checked = True And CheckBox46.Checked = False Then
            列印4() : 列印3() : 列印2() : 列印1()
        ElseIf CheckBox40.Checked = False And CheckBox45.Checked = False And CheckBox46.Checked = True Then
            列印6() : 列印5() : 列印4() : 列印3() : 列印2() : 列印1()
        End If

        xlSheet.PageSetup.PrintArea = ""
        xlApp.Cells.Select()
        xlApp.Application.WindowState = xlMinimized
        MsgBox("列印完成")
        Me.Close()
    End Sub
    Private Shared Function NewMethod(xlBook As Microsoft.Office.Interop.Excel.Workbook) As Microsoft.Office.Interop.Excel.Worksheet
        Return CType(xlBook.Worksheets.Add, Microsoft.Office.Interop.Excel.Worksheet)
    End Function
    Private Sub BB(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        Dim 位置41 As String
        If CheckBox8.Checked = True Then
            If P = 0 Then
            Else
                If P = 2 Then : 位置1 = "B" : ElseIf P = 3 Then : 位置1 = "C" : ElseIf P = 4 Then : 位置1 = "D" : ElseIf P = 5 Then : 位置1 = "E" : ElseIf P = 6 Then : 位置1 = "F"
                ElseIf P = 7 Then : 位置1 = "G" : ElseIf P = 8 Then : 位置1 = "H" : ElseIf P = 9 Then : 位置1 = "I" : ElseIf P = 10 Then : 位置1 = "J" : ElseIf P = 11 Then : 位置1 = "K"
                ElseIf P = 12 Then : 位置1 = "L" : ElseIf P = 13 Then : 位置1 = "M" : ElseIf P = 14 Then : 位置1 = "N" : ElseIf P = 15 Then : 位置1 = "O" : ElseIf P = 16 Then : 位置1 = "P"
                ElseIf P = 17 Then : 位置1 = "Q" : ElseIf P = 18 Then : 位置1 = "R" : ElseIf P = 19 Then : 位置1 = "S" : ElseIf P = 20 Then : 位置1 = "T" : ElseIf P = 21 Then : 位置1 = "U"
                ElseIf P = 22 Then : 位置1 = "V" : ElseIf P = 23 Then : 位置1 = "W" : ElseIf P = 24 Then : 位置1 = "X" : ElseIf P = 25 Then : 位置1 = "Y" : ElseIf P = 26 Then : 位置1 = "Z"
                ElseIf P = 27 Then : 位置1 = "AA" : ElseIf P = 28 Then : 位置1 = "AB" : ElseIf P = 29 Then : 位置1 = "AC" : ElseIf P = 30 Then : 位置1 = "AD" : ElseIf P = 31 Then : 位置1 = "AE"
                ElseIf P = 32 Then : 位置1 = "AF" : ElseIf P = 33 Then : 位置1 = "AG" : ElseIf P = 34 Then : 位置1 = "AH" : ElseIf P = 35 Then : 位置1 = "AI" : ElseIf P = 36 Then : 位置1 = "AJ"
                ElseIf P = 37 Then : 位置1 = "AK" : ElseIf P = 38 Then : 位置1 = "AL" : ElseIf P = 39 Then : 位置1 = "AM" : ElseIf P = 40 Then : 位置1 = "AN" : ElseIf P = 41 Then : 位置1 = "AO"
                ElseIf P = 42 Then : 位置1 = "AP" : ElseIf P = 43 Then : 位置1 = "AQ" : ElseIf P = 44 Then : 位置1 = "AR" : ElseIf P = 45 Then : 位置1 = "AS" : ElseIf P = 46 Then : 位置1 = "AT"
                ElseIf P = 47 Then : 位置1 = "AU"
                End If
                位置1 = 位置1 & "3" & ":" & 位置1 & "10000"
                xlSheet.Range(位置1).Select()
                myExcel.Selection.NumberFormatLocal = "#,##0"
            End If
        End If

        If CheckBox9.Checked = True Then
            If G = 0 Then
            Else
                If G = 2 Then : 位置5 = "B" : ElseIf G = 3 Then : 位置5 = "C" : ElseIf G = 4 Then : 位置5 = "D" : ElseIf G = 5 Then : 位置5 = "E" : ElseIf G = 6 Then : 位置5 = "F"
                ElseIf G = 7 Then : 位置5 = "G" : ElseIf G = 8 Then : 位置5 = "H" : ElseIf G = 9 Then : 位置5 = "I" : ElseIf G = 10 Then : 位置5 = "J" : ElseIf G = 11 Then : 位置5 = "K"
                ElseIf G = 12 Then : 位置5 = "L" : ElseIf G = 13 Then : 位置5 = "M" : ElseIf G = 14 Then : 位置5 = "N" : ElseIf G = 15 Then : 位置5 = "O" : ElseIf G = 16 Then : 位置5 = "G"
                ElseIf G = 17 Then : 位置5 = "Q" : ElseIf G = 18 Then : 位置5 = "R" : ElseIf G = 19 Then : 位置5 = "S" : ElseIf G = 20 Then : 位置5 = "T" : ElseIf G = 21 Then : 位置5 = "U"
                ElseIf G = 22 Then : 位置5 = "V" : ElseIf G = 23 Then : 位置5 = "W" : ElseIf G = 24 Then : 位置5 = "X" : ElseIf G = 25 Then : 位置5 = "Y" : ElseIf G = 26 Then : 位置5 = "Z"
                ElseIf G = 27 Then : 位置5 = "AA" : ElseIf G = 28 Then : 位置5 = "AB" : ElseIf G = 29 Then : 位置5 = "AC" : ElseIf G = 30 Then : 位置5 = "AD" : ElseIf G = 31 Then : 位置5 = "AE"
                ElseIf G = 32 Then : 位置5 = "AF" : ElseIf G = 33 Then : 位置5 = "AG" : ElseIf G = 34 Then : 位置5 = "AH" : ElseIf G = 35 Then : 位置5 = "AI" : ElseIf G = 36 Then : 位置5 = "AJ"
                ElseIf G = 37 Then : 位置5 = "AK" : ElseIf G = 38 Then : 位置5 = "AL" : ElseIf G = 39 Then : 位置5 = "AM" : ElseIf G = 40 Then : 位置5 = "AN" : ElseIf G = 41 Then : 位置5 = "AO"
                ElseIf G = 42 Then : 位置5 = "AG" : ElseIf G = 43 Then : 位置5 = "AQ" : ElseIf G = 44 Then : 位置5 = "AR" : ElseIf G = 45 Then : 位置5 = "AS" : ElseIf G = 46 Then : 位置5 = "AT"
                ElseIf G = 47 Then : 位置5 = "AU"
                End If
                位置5 = 位置5 & "3" & ":" & 位置5 & "10000"
                xlSheet.Range(位置5).Select()
                myExcel.Selection.NumberFormatLocal = "yyy/mm/dd"
            End If
        End If

        If CheckBox10.Checked = True Then
            If H = 0 Then
            Else
                If H = 2 Then : 位置6 = "B" : ElseIf H = 3 Then : 位置6 = "C" : ElseIf H = 4 Then : 位置6 = "D" : ElseIf H = 5 Then : 位置6 = "E" : ElseIf H = 6 Then : 位置6 = "F"
                ElseIf H = 7 Then : 位置6 = "G" : ElseIf H = 8 Then : 位置6 = "H" : ElseIf H = 9 Then : 位置6 = "I" : ElseIf H = 10 Then : 位置6 = "J" : ElseIf H = 11 Then : 位置6 = "K"
                ElseIf H = 12 Then : 位置6 = "L" : ElseIf H = 13 Then : 位置6 = "M" : ElseIf H = 14 Then : 位置6 = "N" : ElseIf H = 15 Then : 位置6 = "O" : ElseIf H = 16 Then : 位置6 = "P"
                ElseIf H = 17 Then : 位置6 = "Q" : ElseIf H = 18 Then : 位置6 = "R" : ElseIf H = 19 Then : 位置6 = "S" : ElseIf H = 20 Then : 位置6 = "T" : ElseIf H = 21 Then : 位置6 = "U"
                ElseIf H = 22 Then : 位置6 = "V" : ElseIf H = 23 Then : 位置6 = "W" : ElseIf H = 24 Then : 位置6 = "X" : ElseIf H = 25 Then : 位置6 = "Y" : ElseIf H = 26 Then : 位置6 = "Z"
                ElseIf H = 27 Then : 位置6 = "AA" : ElseIf H = 28 Then : 位置6 = "AB" : ElseIf H = 29 Then : 位置6 = "AC" : ElseIf H = 30 Then : 位置6 = "AD" : ElseIf H = 31 Then : 位置6 = "AE"
                ElseIf H = 32 Then : 位置6 = "AF" : ElseIf H = 33 Then : 位置6 = "AG" : ElseIf H = 34 Then : 位置6 = "AH" : ElseIf H = 35 Then : 位置6 = "AI" : ElseIf H = 36 Then : 位置6 = "AJ"
                ElseIf H = 37 Then : 位置6 = "AK" : ElseIf H = 38 Then : 位置6 = "AL" : ElseIf H = 39 Then : 位置6 = "AM" : ElseIf H = 40 Then : 位置6 = "AN" : ElseIf H = 41 Then : 位置6 = "AO"
                ElseIf H = 42 Then : 位置6 = "AP" : ElseIf H = 43 Then : 位置6 = "AQ" : ElseIf H = 44 Then : 位置6 = "AR" : ElseIf H = 45 Then : 位置6 = "AS" : ElseIf H = 46 Then : 位置6 = "AT"
                ElseIf H = 47 Then : 位置6 = "AU"
                End If
                位置6 = 位置6 & "3" & ":" & 位置6 & "10000"
                xlSheet.Range(位置6).Select()
                myExcel.Selection.NumberFormatLocal = "yyy/mm/dd"
            End If
        End If
        If CheckBox11.Checked = True Then
            If J = 0 Then
            Else
                If J = 2 Then : 位置7 = "B" : ElseIf J = 3 Then : 位置7 = "C" : ElseIf J = 4 Then : 位置7 = "D" : ElseIf J = 5 Then : 位置7 = "E" : ElseIf J = 6 Then : 位置7 = "F"
                ElseIf J = 7 Then : 位置7 = "G" : ElseIf J = 8 Then : 位置7 = "H" : ElseIf J = 9 Then : 位置7 = "I" : ElseIf J = 10 Then : 位置7 = "J" : ElseIf J = 11 Then : 位置7 = "K"
                ElseIf J = 12 Then : 位置7 = "L" : ElseIf J = 13 Then : 位置7 = "M" : ElseIf J = 14 Then : 位置7 = "N" : ElseIf J = 15 Then : 位置7 = "O" : ElseIf J = 16 Then : 位置7 = "P"
                ElseIf J = 17 Then : 位置7 = "Q" : ElseIf J = 18 Then : 位置7 = "R" : ElseIf J = 19 Then : 位置7 = "S" : ElseIf J = 20 Then : 位置7 = "T" : ElseIf J = 21 Then : 位置7 = "U"
                ElseIf J = 22 Then : 位置7 = "V" : ElseIf J = 23 Then : 位置7 = "W" : ElseIf J = 24 Then : 位置7 = "X" : ElseIf J = 25 Then : 位置7 = "Y" : ElseIf J = 26 Then : 位置7 = "Z"
                ElseIf J = 27 Then : 位置7 = "AA" : ElseIf J = 28 Then : 位置7 = "AB" : ElseIf J = 29 Then : 位置7 = "AC" : ElseIf J = 30 Then : 位置7 = "AD" : ElseIf J = 31 Then : 位置7 = "AE"
                ElseIf J = 32 Then : 位置7 = "AF" : ElseIf J = 33 Then : 位置7 = "AG" : ElseIf J = 34 Then : 位置7 = "AH" : ElseIf J = 35 Then : 位置7 = "AI" : ElseIf J = 36 Then : 位置7 = "AJ"
                ElseIf J = 37 Then : 位置7 = "AK" : ElseIf J = 38 Then : 位置7 = "AL" : ElseIf J = 39 Then : 位置7 = "AM" : ElseIf J = 40 Then : 位置7 = "AN" : ElseIf J = 41 Then : 位置7 = "AO"
                ElseIf J = 42 Then : 位置7 = "AP" : ElseIf J = 43 Then : 位置7 = "AQ" : ElseIf J = 44 Then : 位置7 = "AR" : ElseIf J = 45 Then : 位置7 = "AS" : ElseIf J = 46 Then : 位置7 = "AT"
                ElseIf J = 47 Then : 位置7 = "AU"
                End If
                位置7 = 位置7 & "3" & ":" & 位置7 & "10000"
                xlSheet.Range(位置7).Select()
                myExcel.Selection.NumberFormatLocal = "yyy/mm/dd"
            End If
        End If

        If CheckBox12.Checked = True Then
            If R = 2 Then : 位置2 = "B" : ElseIf R = 3 Then : 位置2 = "C" : ElseIf R = 4 Then : 位置2 = "D" : ElseIf R = 5 Then : 位置2 = "E" : ElseIf R = 6 Then : 位置2 = "F"
            ElseIf R = 7 Then : 位置2 = "G" : ElseIf R = 8 Then : 位置2 = "H" : ElseIf R = 9 Then : 位置2 = "I" : ElseIf R = 10 Then : 位置2 = "J" : ElseIf R = 11 Then : 位置2 = "K"
            ElseIf R = 12 Then : 位置2 = "L" : ElseIf R = 13 Then : 位置2 = "M" : ElseIf R = 14 Then : 位置2 = "N" : ElseIf R = 15 Then : 位置2 = "O" : ElseIf R = 16 Then : 位置2 = "P"
            ElseIf R = 17 Then : 位置2 = "Q" : ElseIf R = 18 Then : 位置2 = "R" : ElseIf R = 19 Then : 位置2 = "S" : ElseIf R = 20 Then : 位置2 = "T" : ElseIf R = 21 Then : 位置2 = "U"
            ElseIf R = 22 Then : 位置2 = "V" : ElseIf R = 23 Then : 位置2 = "W" : ElseIf R = 24 Then : 位置2 = "X" : ElseIf R = 25 Then : 位置2 = "Y" : ElseIf R = 26 Then : 位置2 = "Z"
            ElseIf R = 27 Then : 位置2 = "AA" : ElseIf R = 28 Then : 位置2 = "AB" : ElseIf R = 29 Then : 位置2 = "AC" : ElseIf R = 30 Then : 位置2 = "AD" : ElseIf R = 31 Then : 位置2 = "AE"
            ElseIf R = 32 Then : 位置2 = "AF" : ElseIf R = 33 Then : 位置2 = "AG" : ElseIf R = 34 Then : 位置2 = "AH" : ElseIf R = 35 Then : 位置2 = "AI" : ElseIf R = 36 Then : 位置2 = "AJ"
            ElseIf R = 37 Then : 位置2 = "AK" : ElseIf R = 38 Then : 位置2 = "AL" : ElseIf R = 39 Then : 位置2 = "AM" : ElseIf R = 40 Then : 位置2 = "AN" : ElseIf R = 41 Then : 位置2 = "AO"
            ElseIf R = 42 Then : 位置2 = "AP" : ElseIf R = 43 Then : 位置2 = "AQ" : ElseIf R = 44 Then : 位置2 = "AR" : ElseIf R = 45 Then : 位置2 = "AS" : ElseIf R = 46 Then : 位置2 = "AT"
            ElseIf R = 47 Then : 位置2 = "AU"
            End If
            位置2 = 位置2 & "3" & ":" & 位置2 & "10000"
            xlSheet.Range(位置2).Select()
            myExcel.Selection.NumberFormatLocal = "#,##0.00"
        End If

        If CheckBox13.Checked = True Then
            If A = 2 Then : 位置3 = "B" : ElseIf A = 3 Then : 位置3 = "C" : ElseIf A = 4 Then : 位置3 = "D" : ElseIf A = 5 Then : 位置3 = "E" : ElseIf A = 6 Then : 位置3 = "F"
            ElseIf A = 7 Then : 位置3 = "G" : ElseIf A = 8 Then : 位置3 = "H" : ElseIf A = 9 Then : 位置3 = "I" : ElseIf A = 10 Then : 位置3 = "J" : ElseIf A = 11 Then : 位置3 = "K"
            ElseIf A = 12 Then : 位置3 = "L" : ElseIf A = 13 Then : 位置3 = "M" : ElseIf A = 14 Then : 位置3 = "N" : ElseIf A = 15 Then : 位置3 = "O" : ElseIf A = 16 Then : 位置3 = "P"
            ElseIf A = 17 Then : 位置3 = "Q" : ElseIf A = 18 Then : 位置3 = "R" : ElseIf A = 19 Then : 位置3 = "S" : ElseIf A = 20 Then : 位置3 = "T" : ElseIf A = 21 Then : 位置3 = "U"
            ElseIf A = 22 Then : 位置3 = "V" : ElseIf A = 23 Then : 位置3 = "W" : ElseIf A = 24 Then : 位置3 = "X" : ElseIf A = 25 Then : 位置3 = "Y" : ElseIf A = 26 Then : 位置3 = "Z"
            ElseIf A = 27 Then : 位置3 = "AA" : ElseIf A = 28 Then : 位置3 = "AB" : ElseIf A = 29 Then : 位置3 = "AC" : ElseIf A = 30 Then : 位置3 = "AD" : ElseIf A = 31 Then : 位置3 = "AE"
            ElseIf A = 32 Then : 位置3 = "AF" : ElseIf A = 33 Then : 位置3 = "AG" : ElseIf A = 34 Then : 位置3 = "AH" : ElseIf A = 35 Then : 位置3 = "AI" : ElseIf A = 36 Then : 位置3 = "AJ"
            ElseIf A = 37 Then : 位置3 = "AK" : ElseIf A = 38 Then : 位置3 = "AL" : ElseIf A = 39 Then : 位置3 = "AM" : ElseIf A = 40 Then : 位置3 = "AN" : ElseIf A = 41 Then : 位置3 = "AO"
            ElseIf A = 42 Then : 位置3 = "AP" : ElseIf A = 43 Then : 位置3 = "AQ" : ElseIf A = 44 Then : 位置3 = "AR" : ElseIf A = 45 Then : 位置3 = "AS" : ElseIf A = 46 Then : 位置3 = "AT"
            ElseIf A = 47 Then : 位置3 = "AU"
            End If
            位置3 = 位置3 & "3" & ":" & 位置3 & "10000"
            xlSheet.Range(位置3).Select()
            myExcel.Selection.NumberFormatLocal = "#,##0.00"
        End If

        If Q = 2 Then : 位置4 = "B" : ElseIf Q = 3 Then : 位置4 = "C" : ElseIf Q = 4 Then : 位置4 = "D" : ElseIf Q = 5 Then : 位置4 = "E" : ElseIf Q = 6 Then : 位置4 = "F"
        ElseIf Q = 7 Then : 位置4 = "G" : ElseIf Q = 8 Then : 位置4 = "H" : ElseIf Q = 9 Then : 位置4 = "I" : ElseIf Q = 10 Then : 位置4 = "J" : ElseIf Q = 11 Then : 位置4 = "K"
        ElseIf Q = 12 Then : 位置4 = "L" : ElseIf Q = 13 Then : 位置4 = "M" : ElseIf Q = 14 Then : 位置4 = "N" : ElseIf Q = 15 Then : 位置4 = "O" : ElseIf Q = 16 Then : 位置4 = "P"
        ElseIf Q = 17 Then : 位置4 = "Q" : ElseIf Q = 18 Then : 位置4 = "R" : ElseIf Q = 19 Then : 位置4 = "S" : ElseIf Q = 20 Then : 位置4 = "T" : ElseIf Q = 21 Then : 位置4 = "U"
        ElseIf Q = 22 Then : 位置4 = "V" : ElseIf Q = 23 Then : 位置4 = "W" : ElseIf Q = 24 Then : 位置4 = "X" : ElseIf Q = 25 Then : 位置4 = "Y" : ElseIf Q = 26 Then : 位置4 = "Z"
        ElseIf Q = 27 Then : 位置4 = "AA" : ElseIf Q = 28 Then : 位置4 = "AB" : ElseIf Q = 29 Then : 位置4 = "AC" : ElseIf Q = 30 Then : 位置4 = "AD" : ElseIf Q = 31 Then : 位置4 = "AE"
        ElseIf Q = 32 Then : 位置4 = "AF" : ElseIf Q = 33 Then : 位置4 = "AG" : ElseIf Q = 34 Then : 位置4 = "AH" : ElseIf Q = 35 Then : 位置4 = "AI" : ElseIf Q = 36 Then : 位置4 = "AJ"
        ElseIf Q = 37 Then : 位置4 = "AK" : ElseIf Q = 38 Then : 位置4 = "AL" : ElseIf Q = 39 Then : 位置4 = "AM" : ElseIf Q = 40 Then : 位置4 = "AN" : ElseIf Q = 41 Then : 位置4 = "AO"
        ElseIf Q = 42 Then : 位置4 = "AP" : ElseIf Q = 43 Then : 位置4 = "AQ" : ElseIf Q = 44 Then : 位置4 = "AR" : ElseIf Q = 45 Then : 位置4 = "AS" : ElseIf Q = 46 Then : 位置4 = "AT"
        ElseIf Q = 47 Then : 位置4 = "AU"
        End If

        xlSheet.Columns("A:A").ColumnWidth = 1

        xlSheet.Range("B2:E2").Select()
        With myExcel.Selection
            .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : .MergeCells = False
        End With
        myExcel.Selection.Merge

        xlSheet.Cells(2, 6) = "列印日期 : " : xlSheet.Range("F2:G2").Select()
        With myExcel.Selection
            .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : .MergeCells = False
        End With
        myExcel.Selection.Merge

        xlSheet.Range("F2:G2").Select()
        With myExcel.Selection
            .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : .MergeCells = True
        End With

        xlSheet.Cells(2, 8) = String.Format("{0:d}", Now) : xlSheet.Range("H2:I2").Select()
        With myExcel.Selection
            .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : .MergeCells = False
        End With
        myExcel.Selection.Merge

        xlSheet.Range("H2:I2").Select()

        xlSheet.Cells.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 = xlThemeFontNone
        End With

        xlSheet.Range("B2:I2").Select()
        With myExcel.Selection.Font
            .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
        End With

        位置41 = "B:" & 位置4
        xlSheet.Columns(位置41).Select : xlSheet.Columns(位置41).EntireColumn.AutoFit

        myExcel.ActiveWindow.ScrollColumn = 4 : myExcel.ActiveWindow.ScrollColumn = 3 : myExcel.ActiveWindow.ScrollColumn = 2 : myExcel.ActiveWindow.ScrollColumn = 1
        xlSheet.Rows("4:4").Select
        myExcel.ActiveWindow.FreezePanes = True
        xlSheet.Rows("3:3").Select
        myExcel.Selection.AutoFilter
        myExcel.ActiveWindow.ScrollColumn = 3 : myExcel.ActiveWindow.ScrollColumn = 2 : myExcel.ActiveWindow.ScrollColumn = 1

        xlSheet.Rows("3:3").Select
        With myExcel.Selection
            .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlTop : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : .MergeCells = False
        End With

        If 位置4 = "A" Or 位置4 = "B" Or 位置4 = "C" Or 位置4 = "D" Or 位置4 = "E" Or 位置4 = "F" Or 位置4 = "G" Or 位置4 = "H" Or 位置4 = "I" Or 位置4 = "J" Then
        Else
            位置41 = "J2:" & 位置4 & "2"
            xlSheet.Range(位置41).Select()
            With myExcel.Selection
                .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
                .ReadingOrder = xlContext : .MergeCells = False
            End With
            myExcel.Selection.Merge
        End If
        Dim M As Integer = 4
        For M = 4 To DataGridView1.Rows.Count + 2
            M = M + 1
        Next M
        If 位置4 = "A" Or 位置4 = "B" Or 位置4 = "C" Or 位置4 = "D" Or 位置4 = "E" Or 位置4 = "F" Or 位置4 = "G" Or 位置4 = "H" Or 位置4 = "I" Or 位置4 = "J" Then
            位置4 = "J"
            位置41 = "B2:" & 位置4 & M
        Else
            位置41 = "B2:" & 位置4 & M
        End If
        xlSheet.Range(位置41).Select() : myExcel.Selection.RowHeight = 13.5
        xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 5
        xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 25
        xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 30
        xlSheet.Range(位置41).Select() : xlSheet.Range("J2").Activate()
        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
        myExcel.ActiveWindow.ScrollRow = 981 : myExcel.ActiveWindow.ScrollRow = 967 : myExcel.ActiveWindow.ScrollRow = 940 : myExcel.ActiveWindow.ScrollRow = 845
        myExcel.ActiveWindow.ScrollRow = 804 : myExcel.ActiveWindow.ScrollRow = 791 : myExcel.ActiveWindow.ScrollRow = 587 : myExcel.ActiveWindow.ScrollRow = 546
        myExcel.ActiveWindow.ScrollRow = 533 : myExcel.ActiveWindow.ScrollRow = 519 : myExcel.ActiveWindow.ScrollRow = 343 : myExcel.ActiveWindow.ScrollRow = 316
        myExcel.ActiveWindow.ScrollRow = 288 : myExcel.ActiveWindow.ScrollRow = 126 : myExcel.ActiveWindow.ScrollRow = 99 : myExcel.ActiveWindow.ScrollRow = 71
        myExcel.ActiveWindow.ScrollRow = 4

        位置41 = "B3:" & 位置4 & "3"
        xlSheet.Range(位置41).Select()
        With myExcel.Selection.Interior
            .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent5 : .TintAndShade = 0.599993896298105 : .PatternTintAndShade = 0
        End With
        xlSheet.Range("M9").Select()
        myExcel.ActiveWindow.ScrollColumn = 4 : myExcel.ActiveWindow.ScrollColumn = 3 : myExcel.ActiveWindow.ScrollColumn = 2 : myExcel.ActiveWindow.ScrollColumn = 1
        myExcel.ActiveWindow.DisplayGridlines = False
    End Sub
    Private Sub CheckBox40_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox40.Click
        CheckBox40.Checked = True : CheckBox45.Checked = False : CheckBox46.Checked = False
    End Sub
    Private Sub CheckBox45_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox45.Click
        CheckBox40.Checked = False : CheckBox45.Checked = True : CheckBox46.Checked = False
    End Sub
    Private Sub CheckBox46_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox46.Click
        CheckBox40.Checked = False : CheckBox45.Checked = False : CheckBox46.Checked = True
    End Sub
End Class