Option Strict Off
Imports System.Data.SqlClient
Imports System.IO
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 ds1 As New DataSet : Dim ds2 As New DataSet : Dim ds3 As New DataSet
    Dim dr As SqlDataReader
    Dim N1 As Integer : Dim N2 As Integer : Dim N3 As Integer : Dim N4 As Integer : Dim N5 As Integer : Dim N6 As Integer
    Dim N7 As Integer : Dim N8 As Integer : Dim N9 As Integer : Dim N10 As Integer : Dim N11 As Integer
    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 Q1 As Integer : Dim ww1 As Boolean : Dim ww2 As Boolean
    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.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單()
        Set_DGV1載入前設定()
        SQL1 = "SELECT SO, 季節, 客戶, 型體號碼, 型體名稱, 國家, 狀態, ISS_DATE, ETA, 數量, 制單人, LEFT(制單時間, 10) AS 制單時間, 版次, 工廠, REQ FROM 樣品訂單控制表 " &
               "WHERE SO LIKE N'" & 列印用SQL & "' AND 版次 LIKE N'" & 列印用SQL2 & "' ORDER BY SO DESC, 版次 DESC"
        Set_DGV1載入後設定()
    End Sub
    Private Sub Set_DGV2載入前設定()
        DataGridView2.DataSource = Nothing : ds1.Clear()
        DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView2.ColumnHeadersHeight = 25
        DataGridView2.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub Set_DGV2載入後設定()
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單2()
        Set_DGV2載入前設定()
        SQL1 = "SELECT 項次, 顏色, 架號, 數量, SIZE, KEEP, 流水號, 版次, 備註, 借出者 FROM 樣品訂單清單 WHERE (SO LIKE N'" & 列印用SQL & "' AND 版次 LIKE N'" & 列印用SQL2 & "') ORDER BY 項次"
        Set_DGV2載入後設定()
    End Sub
    Private Sub Set_DGV3載入前設定()
        DataGridView3.DataSource = Nothing : ds2.Clear()
        DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView3.ColumnHeadersHeight = 25
        DataGridView3.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub Set_DGV3載入後設定()
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_清單3()
        Set_DGV3載入前設定()
        SQL1 = "SELECT LEFT(樣品訂單部件表.部件, 2) AS 部件, 部件大項分類.部件類別 FROM 樣品訂單部件表 LEFT OUTER JOIN 部件大項分類 ON LEFT(樣品訂單部件表.部件, 2) = LEFT(部件大項分類.部件類別, 2) " &
               "WHERE (樣品訂單部件表.SO LIKE N'" & 列印用SQL & "') AND (樣品訂單部件表.版次 LIKE N'" & 列印用SQL2 & "') GROUP BY LEFT(樣品訂單部件表.部件, 2), 部件大項分類.部件類別 ORDER BY 部件"
        Set_DGV3載入後設定()
    End Sub
    Private Sub Set_DGV4載入前設定()
        DataGridView4.DataSource = Nothing : ds3.Clear()
        DataGridView4.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView4.ColumnHeadersHeight = 25
        DataGridView4.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub Set_DGV4載入後設定()
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds3) : DataGridView4.DataSource = ds3.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_格式設定()
        DataGridView1.Visible = False : DataGridView2.Visible = False : DataGridView3.Visible = False : DataGridView4.Visible = False : PictureBox1.Visible = False
    End Sub
    Private Sub 列印_樣品單_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FormBorderStyle = FormBorderStyle.SizableToolWindow : ControlBox = False
        Set_清單() : Set_清單2() : Set_清單3() : Set_格式設定()
    End Sub
    Private Sub 列印1()
        xlSheet.Cells(1, 1) = "WTL ENTERPRISE CO., LTD." : xlSheet.Cells(1, 21) = "SAMPLE ORDER (樣品單)" : xlSheet.Cells(2, 1) = "11F-9., No.151, Sec. 2, Hankou Rd., Situn Dist., "
        xlSheet.Cells(3, 1) = "Taichung City, Taiwan 40746" : xlSheet.Cells(3, 24) = "PRINT DATE :" : xlSheet.Cells(3, 29) = "=TODAY()" : xlSheet.Cells(5, 1) = "S/O # (單號)"
        xlSheet.Cells(6, 1) = "CUST (客戶)" : xlSheet.Cells(7, 1) = "FACTORY (工廠)" : xlSheet.Cells(8, 1) = "STYLE # (型體號)" : xlSheet.Cells(9, 1) = "STY.NAME (型體名)"
        xlSheet.Cells(10, 1) = "COUNTRY (國家)" : xlSheet.Cells(11, 1) = "PURPOSE (目的)"
        xlSheet.Cells(5, 6) = ":" : xlSheet.Cells(6, 6) = ":" : xlSheet.Cells(7, 6) = ":" : xlSheet.Cells(8, 6) = ":" : xlSheet.Cells(9, 6) = ":" : xlSheet.Cells(10, 6) = ":" : xlSheet.Cells(11, 6) = ":"
        xlSheet.Cells(5, 14) = "EDITION (版次)" : xlSheet.Cells(6, 14) = "SEASON (季節)" : xlSheet.Cells(7, 14) = "ISS. DATE (制單日期)" : xlSheet.Cells(8, 14) = "ETD (預計寄出日期)"
        xlSheet.Cells(9, 14) = "REQ. BY" : xlSheet.Cells(10, 14) = "INVOICE" : xlSheet.Cells(11, 14) = "TOTAL (總數)"
        xlSheet.Cells(5, 19) = ":" : xlSheet.Cells(6, 19) = ":" : xlSheet.Cells(7, 19) = ":" : xlSheet.Cells(8, 19) = ":" : xlSheet.Cells(9, 19) = ":" : xlSheet.Cells(10, 19) = ":"
        xlSheet.Cells(11, 19) = ":"
        xlSheet.Cells(5, 7) = DataGridView1.Rows(0).Cells("SO").Value : xlSheet.Cells(6, 7) = DataGridView1.Rows(0).Cells("客戶").Value
        xlSheet.Cells(7, 7) = DataGridView1.Rows(0).Cells("工廠").Value : xlSheet.Cells(8, 7) = DataGridView1.Rows(0).Cells("型體號碼").Value
        xlSheet.Cells(9, 7) = DataGridView1.Rows(0).Cells("型體名稱").Value : xlSheet.Cells(10, 7) = DataGridView1.Rows(0).Cells("國家").Value
        xlSheet.Cells(11, 7) = DataGridView1.Rows(0).Cells("狀態").Value : xlSheet.Cells(5, 20) = DataGridView1.Rows(0).Cells("版次").Value
        xlSheet.Cells(6, 20) = DataGridView1.Rows(0).Cells("季節").Value : xlSheet.Cells(7, 20) = DataGridView1.Rows(0).Cells("ISS_DATE").Value
        xlSheet.Cells(8, 20) = DataGridView1.Rows(0).Cells("ETA").Value : xlSheet.Cells(9, 20) = DataGridView1.Rows(0).Cells("REQ").Value
        xlSheet.Cells(10, 20) = "" : xlSheet.Cells(11, 20) = DataGridView1.Rows(0).Cells("數量").Value
        AA(xlApp, xlSheet)
        PictureBox1.Image = Nothing : conn.Close()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
                       "WHERE 客戶 LIKE N'" & DataGridView1.Rows(0).Cells("客戶").Value & "' AND 形體號 LIKE N'" & DataGridView1.Rows(0).Cells("型體號碼").Value &
                       "' AND 形體名 LIKE N'" & DataGridView1.Rows(0).Cells("型體名稱").Value & "' AND 類別 LIKE N'設計圖'"
        cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
        If dr.Read() Then
            PictureBox1.Image = Nothing : conn.Close()
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
                           "WHERE 客戶 LIKE N'" & DataGridView1.Rows(0).Cells("客戶").Value & "' AND 形體號 LIKE N'" & DataGridView1.Rows(0).Cells("型體號碼").Value &
                           "' AND 形體名 LIKE N'" & DataGridView1.Rows(0).Cells("型體名稱").Value & "' AND 類別 LIKE N'設計圖'"
            cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
            While dr.Read() = True
                Dim bytes As Byte() = New Byte(-1) {} : bytes = DirectCast(dr.Item("圖片"), Byte()) : Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
            End While
            conn.Close() : GG(xlApp, xlSheet)
        Else
            xlSheet.Cells(5, 28) = "系統中無圖片"
            conn.Close()
        End If : PictureBox1.SizeMode = 4
        N1 = 0 : N2 = 0 : N4 = 0 : N5 = 0 : N6 = -1 : N7 = -1 : N8 = 0
    End Sub
    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        If CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False Then
            MsgBox("沒有選擇顏色分配頁數")
        Else
            xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
            xlBook = xlApp.Workbooks.Add
            xlApp.DisplayAlerts = True
            xlApp.Visible = True
            xlApp.Application.WindowState = xlMaximized

            For i As Integer = 0 To DataGridView2.Rows.Count - 1
                If CheckBox1.Checked = True Then
                    '三色一頁
                    If i = 0 Then
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表2" Then
                            xlApp.Sheets("工作表2").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第一頁"
                        Else
                            xlApp.Sheets("sheet2").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第一頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    ElseIf i = 3 Then
                        FF(xlApp, xlSheet)
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表3" Then
                            xlApp.Sheets("工作表3").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第二頁"
                        Else
                            xlApp.Sheets("sheet3").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第二頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    ElseIf i = 6 Then
                        FF(xlApp, xlSheet)
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表4" Then
                            xlApp.Sheets("工作表4").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第三頁"
                        Else
                            xlApp.Sheets("sheet4").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第三頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    ElseIf i = 9 Then
                        FF(xlApp, xlSheet)
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表5" Then
                            xlApp.Sheets("工作表5").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第四頁"
                        Else
                            xlApp.Sheets("sheet5").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第四頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    End If
                ElseIf CheckBox3.Checked = True Then
                    '四色一頁
                    If i = 0 Then
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表2" Then
                            xlApp.Sheets("工作表2").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第一頁"
                        Else
                            xlApp.Sheets("sheet2").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第一頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    ElseIf i = 4 Then
                        FF(xlApp, xlSheet)
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表3" Then
                            xlApp.Sheets("工作表3").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第二頁"
                        Else
                            xlApp.Sheets("sheet3").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第二頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    ElseIf i = 8 Then
                        FF(xlApp, xlSheet)
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表4" Then
                            xlApp.Sheets("工作表4").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第三頁"
                        Else
                            xlApp.Sheets("sheet4").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第三頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    End If
                ElseIf CheckBox2.Checked = True Then
                    '二色一頁
                    If i = 0 Then
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表2" Then
                            xlApp.Sheets("工作表2").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第一頁"
                        Else
                            xlApp.Sheets("sheet2").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第一頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    ElseIf i = 2 Then
                        FF(xlApp, xlSheet)
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表3" Then
                            xlApp.Sheets("工作表3").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第二頁"
                        Else
                            xlApp.Sheets("sheet3").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第二頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    ElseIf i = 4 Then
                        FF(xlApp, xlSheet)
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表4" Then
                            xlApp.Sheets("工作表4").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第三頁"
                        Else
                            xlApp.Sheets("sheet4").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第三頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    ElseIf i = 6 Then
                        FF(xlApp, xlSheet)
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表5" Then
                            xlApp.Sheets("工作表5").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第四頁"
                        Else
                            xlApp.Sheets("sheet5").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第四頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    ElseIf i = 8 Then
                        FF(xlApp, xlSheet)
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表6" Then
                            xlApp.Sheets("工作表6").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第五頁"
                        Else
                            xlApp.Sheets("sheet6").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第五頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    ElseIf i = 10 Then
                        FF(xlApp, xlSheet)
                        xlSheet = NewMethod(xlBook)
                        If xlApp.Sheets(1).Name = "工作表7" Then
                            xlApp.Sheets("工作表7").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第六頁"
                        Else
                            xlApp.Sheets("sheet7").Name = DataGridView1.Rows(0).Cells("型體名稱").Value & "第六頁"
                        End If
                        xlBook.Activate() : xlSheet.Activate() : 列印1() : Q1 = 0
                    End If
                End If

                N6 = N6 + 1 : N7 = N7 + 1 : N9 = Q1 + N2 + N4 + N5
                xlSheet.Cells(Q1 + N2 + N4 + N5 + 13, 1) = "#" : xlSheet.Cells(Q1 + N2 + N4 + N5 + 13, 2) = "COLOR (顏色)" : xlSheet.Cells(Q1 + N2 + N4 + N5 + 13, 8) = "PRS (雙數)"
                xlSheet.Cells(Q1 + N2 + N4 + N5 + 13, 11) = "SIZE (尺寸)" : xlSheet.Cells(Q1 + N2 + N4 + N5 + 13, 14) = "KEEP (留底)" : xlSheet.Cells(Q1 + N2 + N4 + N5 + 13, 17) = "LOC (位置）"
                xlSheet.Cells(Q1 + N2 + N4 + N5 + 13, 20) = "LEND BY(借出者)"
                xlSheet.Cells(Q1 + N2 + N4 + N5 + 14, 1) = DataGridView2.Rows(i).Cells("項次").Value : xlSheet.Cells(Q1 + N2 + N4 + N5 + 14, 2) = DataGridView2.Rows(i).Cells("顏色").Value
                xlSheet.Cells(Q1 + N2 + N4 + N5 + 14, 8) = DataGridView2.Rows(i).Cells("數量").Value : xlSheet.Cells(Q1 + N2 + N4 + N5 + 14, 11) = DataGridView2.Rows(i).Cells("SIZE").Value
                xlSheet.Cells(Q1 + N2 + N4 + N5 + 14, 14) = DataGridView2.Rows(i).Cells("KEEP").Value : xlSheet.Cells(Q1 + N2 + N4 + N5 + 14, 17) = DataGridView2.Rows(i).Cells("架號").Value
                xlSheet.Cells(Q1 + N2 + N4 + N5 + 14, 20) = DataGridView2.Rows(i).Cells("借出者").Value
                xlSheet.Cells(Q1 + N2 + N4 + N5 + 15, 1) = "#" : xlSheet.Cells(Q1 + N2 + N4 + N5 + 15, 2) = "DESCRIPTION (部件說明)" : xlSheet.Cells(Q1 + N2 + N4 + N5 + 15, 8) = "MATERIALS (材料名稱)"
                xlSheet.Cells(Q1 + N2 + N4 + N5 + 15, 14) = "COLOR (顏色)" : xlSheet.Cells(Q1 + N2 + N4 + N5 + 15, 20) = "SUPPLIER (廠商)" : xlSheet.Cells(Q1 + N2 + N4 + N5 + 15, 24) = "REMARKS (備註)"
                BB(xlApp, xlSheet)
                PictureBox1.Image = Nothing : conn.Close()
                If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
                       "WHERE 客戶 LIKE N'" & DataGridView1.Rows(0).Cells("客戶").Value & "' AND 形體號 LIKE N'" & DataGridView1.Rows(0).Cells("型體號碼").Value &
                               "' AND 形體名 LIKE N'" & DataGridView1.Rows(0).Cells("型體名稱").Value & "' AND 顏色 LIKE N'" & DataGridView2.Rows(i).Cells("顏色").Value & "'"
                cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
                If dr.Read() Then
                    PictureBox1.Image = Nothing : conn.Close()
                    If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
                    SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 " &
                       "WHERE 客戶 LIKE N'" & DataGridView1.Rows(0).Cells("客戶").Value & "' AND 形體號 LIKE N'" & DataGridView1.Rows(0).Cells("型體號碼").Value &
                               "' AND 形體名 LIKE N'" & DataGridView1.Rows(0).Cells("型體名稱").Value & "' AND 顏色 LIKE N'" & DataGridView2.Rows(i).Cells("顏色").Value & "'"
                    cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
                    While dr.Read() = True
                        Dim bytes As Byte() = New Byte(-1) {} : bytes = DirectCast(dr.Item("圖片"), Byte()) : Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
                    End While
                    conn.Close() : HH(xlApp, xlSheet)
                Else
                    xlSheet.Cells(Q1 + N2 + N4 + N5 + 13, 28) = "系統中無圖片"
                    conn.Close()
                End If : PictureBox1.SizeMode = 4
                N3 = 0  ':
                For ii As Integer = 0 To DataGridView3.Rows.Count - 1
                    xlSheet.Cells(ii + N2 + N4 + N5 + 16 + N6, 2) = DataGridView3.Rows(ii).Cells("部件類別").Value
                    N10 = ii + N2 + N4 + N5 + N6 : CC(xlApp, xlSheet)
                    Set_DGV4載入前設定()
                    SQL1 = "SELECT SO, 項次, 部件, 材料名稱, 材料說明, 備註, 廠商, 版次, 流水號 FROM 樣品訂單部件表 " &
                           "WHERE (SO LIKE N'" & 列印用SQL & "') AND (版次 LIKE N'" & 列印用SQL2 & "') AND (流水號 LIKE N'" & DataGridView2.Rows(i).Cells("流水號").Value & "') " &
                           "AND (部件 LIKE N'" & DataGridView3.Rows(ii).Cells("部件").Value & "%') ORDER BY 項次, 部件"
                    Set_DGV4載入後設定()
                    For iii As Integer = 0 To DataGridView4.Rows.Count - 1
                        xlSheet.Cells(iii + N2 + N3 + N8 + N5 + N6 + N7 + 17, 1) = DataGridView2.Rows(i).Cells("項次").Value
                        xlSheet.Cells(iii + N2 + N3 + N8 + N5 + N6 + N7 + 17, 2) = DataGridView4.Rows(iii).Cells("部件").Value
                        xlSheet.Cells(iii + N2 + N3 + N8 + N5 + N6 + N7 + 17, 8) = DataGridView4.Rows(iii).Cells("材料名稱").Value
                        xlSheet.Cells(iii + N2 + N3 + N8 + N5 + N6 + N7 + 17, 14) = DataGridView4.Rows(iii).Cells("材料說明").Value
                        xlSheet.Cells(iii + N2 + N3 + N8 + N5 + N6 + N7 + 17, 20) = DataGridView4.Rows(iii).Cells("廠商").Value
                        xlSheet.Cells(iii + N2 + N3 + N8 + N5 + N6 + N7 + 17, 24) = DataGridView4.Rows(iii).Cells("備註").Value
                        If Len(DataGridView4.Rows(iii).Cells("材料名稱").Value) > 45 Then
                            ww1 = True
                        Else
                            ww1 = False
                        End If
                        If Len(DataGridView4.Rows(iii).Cells("備註").Value) > 25 Then
                            ww2 = True
                        Else
                            ww2 = False
                        End If
                        N1 = iii + 1 : N11 = iii + N2 + N3 + N8 + N5 + N6 + N7 : DD(xlApp, xlSheet)
                    Next iii
                    N2 = N2 + N1 : N3 = ii + 1
                Next ii
                N4 = N4 + N3 + 1 : N8 = N8 + N3
                With xlApp.Selection : .Font.Bold = True : End With
                N5 = N5 + 2 : EE(xlApp, xlSheet) : Q1 = Q1 + 1
            Next i
            FF(xlApp, xlSheet)

            xlSheet.PageSetup.PrintArea = ""
            xlApp.Cells.Select()
            xlSheet.Range("B1").Select()
            xlApp.Application.WindowState = xlMinimized
            MsgBox("列印完成")
            Me.Close()
        End If
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        列印用SQL = "" : 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 AA(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        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.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 3
        xlSheet.Columns("B:G").Select : myExcel.Selection.ColumnWidth = 4
        xlSheet.Columns("H:M").Select : myExcel.Selection.ColumnWidth = 8
        xlSheet.Columns("N:AH").Select : myExcel.Selection.ColumnWidth = 3

        xlSheet.Range("A1").Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 26 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Range("U1").Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 22 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Range("A2").Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 14 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Range("A3").Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 14 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With

        xlSheet.Range("A3:AH3").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.Rows("4:4").Select : myExcel.Selection.RowHeight = 3
        xlSheet.Range("G5:M5").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("G6:M6").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("G7:M7").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("G8:M8").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("G9:M9").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("G10:M10").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("G11:M11").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("T5:Z5").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("T6:Z6").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("T7:Z7").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("T8:Z8").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("T9:Z9").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("T10:Z10").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("T11:Z11").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("AA3:AC3").Select() : myExcel.Selection.Merge

        xlSheet.Range("A11:AH11").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("AB5:AH11").Select() : myExcel.Selection.Merge
        xlSheet.Columns("A:A").Select : myExcel.Selection.NumberFormatLocal = "@"
        myExcel.ActiveWindow.DisplayGridlines = False
    End Sub
    Private Sub BB(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        Dim 位置1 As String
        位置1 = 12 + N9 & ":" & 12 + N9 : xlSheet.Rows(位置1).Select : myExcel.Selection.RowHeight = 3
        位置1 = 13 + N9 & ":" & 13 + N9 : xlSheet.Rows(位置1).Select : myExcel.Selection.RowHeight = 30
        位置1 = 14 + N9 & ":" & 14 + N9 : xlSheet.Rows(位置1).Select : myExcel.Selection.RowHeight = 30
        位置1 = 15 + N9 & ":" & 15 + N9 : xlSheet.Rows(位置1).Select : myExcel.Selection.RowHeight = 15

        位置1 = "A" & 13 + N9 & ":W" & 13 + N9 : xlSheet.Range(位置1).Select()
        With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
        位置1 = "A" & 15 + N9 & ":AH" & 15 + N9 : xlSheet.Range(位置1).Select()
        With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With

        位置1 = "A" & 13 + N9 & ":A" & 15 + N9 : xlSheet.Range(位置1).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

        位置1 = "B" & 13 + N9 & ":G" & 13 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "B" & 14 + N9 & ":G" & 14 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "H" & 13 + N9 & ":J" & 13 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "H" & 14 + N9 & ":J" & 14 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "K" & 13 + N9 & ":M" & 13 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "K" & 14 + N9 & ":M" & 14 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "N" & 13 + N9 & ":P" & 13 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "N" & 14 + N9 & ":P" & 14 + N9 : xlSheet.Range(位置1).Select() : myExcel.Selection.Merge
        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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "Q" & 13 + N9 & ":S" & 13 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "Q" & 14 + N9 & ":S" & 14 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "T" & 13 + N9 & ":W" & 13 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "T" & 14 + N9 & ":W" & 14 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "AB" & 13 + N9 & ":AH" & 14 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "B" & 15 + N9 & ":G" & 15 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "H" & 15 + N9 & ":M" & 15 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "N" & 15 + N9 & ":S" & 15 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "T" & 15 + N9 & ":W" & 15 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "X" & 15 + N9 & ":AH" & 15 + N9 : xlSheet.Range(位置1).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
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone

        位置1 = "AB" & 13 + N9 & ":AH" & 14 + N9 : xlSheet.Range(位置1).Select() : myExcel.Selection.Merge
    End Sub
    Private Sub CC(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        Dim 位置1 As String
        位置1 = 16 + N10 & ":" & 16 + N10 : xlSheet.Rows(位置1).Select : myExcel.Selection.RowHeight = 15
        位置1 = "A" & 16 + N10 & ":AH" & 16 + N10 : xlSheet.Range(位置1).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 = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone

        位置1 = "B" & 16 + N10 & ":G" & 16 + N10 : xlSheet.Range(位置1).Select() : myExcel.Selection.Merge
        With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent6 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
    End Sub
    Private Sub DD(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        Dim 位置1 As String
        位置1 = "A" & 17 + N11 : xlSheet.Range(位置1).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 = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "B" & 17 + N11 & ":G" & 17 + N11 : xlSheet.Range(位置1).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 = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "H" & 17 + N11 & ":M" & 17 + N11 : xlSheet.Range(位置1).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 = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "N" & 17 + N11 & ":S" & 17 + N11 : xlSheet.Range(位置1).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 = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "T" & 17 + N11 & ":W" & 17 + N11 : xlSheet.Range(位置1).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 = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        位置1 = "X" & 17 + N11 & ":AH" & 17 + N11 : xlSheet.Range(位置1).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 = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone

        位置1 = "B" & 17 + N11 & ":G" & 17 + N11 : xlSheet.Range(位置1).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
        位置1 = "H" & 17 + N11 & ":M" & 17 + N11 : xlSheet.Range(位置1).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
        位置1 = "N" & 17 + N11 & ":S" & 17 + N11 : xlSheet.Range(位置1).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
        位置1 = "T" & 17 + N11 & ":W" & 17 + N11 : xlSheet.Range(位置1).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
        位置1 = "X" & 17 + N11 & ":AH" & 17 + N11 : xlSheet.Range(位置1).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
        位置1 = 17 + N11 & ":" & 17 + N11 : xlSheet.Rows(位置1).Select
        With myExcel.Selection : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : End With
        If ww1 = False And ww2 = False Then
            位置1 = 17 + N11 & ":" & 17 + N11 : xlSheet.Rows(位置1).Select : myExcel.Selection.RowHeight = 15
        Else
            位置1 = 17 + N11 & ":" & 17 + N11 : xlSheet.Rows(位置1).Select : myExcel.Selection.RowHeight = 30
        End If
    End Sub
    Private Sub EE(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        Dim 位置1 As String
        位置1 = "A" & 13 + N9 & ":AH" & 17 + N11 : xlSheet.Range(位置1).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
    End Sub
    Private Sub FF(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        xlSheet.Columns("A:AH").Select
        myExcel.ActiveSheet.PageSetup.PrintArea = "$A:$AH"
        myExcel.Application.PrintCommunication = False
        With myExcel.ActiveSheet.PageSetup
            .PrintTitleRows = "$1:$12"
            .PrintTitleColumns = ""
        End With
        myExcel.Application.PrintCommunication = True
        myExcel.ActiveSheet.PageSetup.PrintArea = "$A:$AH"
        myExcel.Application.PrintCommunication = False
        With myExcel.ActiveSheet.PageSetup
            .LeftHeader = ""
            .CenterHeader = ""
            .RightHeader = ""
            .LeftFooter = ""
            .CenterFooter = ""
            .RightFooter = ""
            .LeftMargin = myExcel.Application.InchesToPoints(0.196850393700787)
            .RightMargin = myExcel.Application.InchesToPoints(0.196850393700787)
            .TopMargin = myExcel.Application.InchesToPoints(0.393700787401575)
            .BottomMargin = myExcel.Application.InchesToPoints(0.196850393700787)
            .HeaderMargin = myExcel.Application.InchesToPoints(0)
            .FooterMargin = myExcel.Application.InchesToPoints(0)
            .PrintHeadings = False
            .PrintGridlines = False
            .PrintQuality = 600
            .CenterHorizontally = True
            .CenterVertically = False
            .Draft = False
            .FirstPageNumber = xlAutomatic
            .BlackAndWhite = False
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = 0
            .OddAndEvenPagesHeaderFooter = False
            .DifferentFirstPageHeaderFooter = False
            .ScaleWithDocHeaderFooter = True
            .AlignMarginsHeaderFooter = True
            .EvenPage.LeftHeader.Text = ""
            .EvenPage.CenterHeader.Text = ""
            .EvenPage.RightHeader.Text = ""
            .EvenPage.LeftFooter.Text = ""
            .EvenPage.CenterFooter.Text = ""
            .EvenPage.RightFooter.Text = ""
            .FirstPage.LeftHeader.Text = ""
            .FirstPage.CenterHeader.Text = ""
            .FirstPage.RightHeader.Text = ""
            .FirstPage.LeftFooter.Text = ""
            .FirstPage.CenterFooter.Text = ""
            .FirstPage.RightFooter.Text = ""
        End With
        myExcel.Application.PrintCommunication = True
    End Sub
    Private Sub GG(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        Dim 位置1 As String
        Clipboard.SetDataObject(PictureBox1.Image)
        位置1 = "AB5" : xlSheet.Range(位置1).Select()
        myExcel.ActiveSheet.Pictures.Paste.Select
        myExcel.Selection.ShapeRange.Height = 79
    End Sub
    Private Sub HH(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        Dim 位置1 As String
        Clipboard.SetDataObject(PictureBox1.Image)
        位置1 = "AB" & N9 + 13 : xlSheet.Range(位置1).Select()
        myExcel.ActiveSheet.Pictures.Paste.Select
        myExcel.Selection.ShapeRange.Height = 59
    End Sub
    Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.Click
        CheckBox3.Checked = True : CheckBox1.Checked = False : CheckBox2.Checked = False
    End Sub
    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.Click
        CheckBox3.Checked = False : CheckBox1.Checked = True : CheckBox2.Checked = False
    End Sub
    Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.Click
        CheckBox3.Checked = False : CheckBox1.Checked = False : CheckBox2.Checked = True
    End Sub
End Class