123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826 |
- Option Strict Off
- Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
- Imports Microsoft.Office.Interop.Excel.Constants
- Imports Microsoft.Office.Interop.Excel.XlBordersIndex
- Imports Microsoft.Office.Interop.Excel.XlLineStyle
- Imports Microsoft.Office.Interop.Excel.XlBorderWeight
- Imports Microsoft.Office.Interop.Excel.XlThemeFont
- Imports Microsoft.Office.Interop.Excel.XlThemeColor
- Imports Microsoft.Office.Interop.Excel.XlWindowState
- Public Class 訂單列印選擇
- ReadOnly ds As New DataSet
- ReadOnly OPEXC(2) As Boolean
- Dim selectdate As Date : Dim DTP As Date
- Dim P As Integer = 0 : Dim R As Integer = 0 : Dim A As Integer = 0 : Dim Q As Integer = 0
- Dim Index_PRS As Integer = 0 : Dim Index_FTY_XF As Integer = 0 : Dim Index_月_total As Integer = 0
- Dim 位置1 As String : Dim 位置2 As String : Dim 位置3 As String : Dim 位置4 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
- ReadOnly SQL字串1 As String = "SELECT " & 訂單資料表(1) & ".訂單流水號, " & 訂單資料表(1) & ".年份季度, " & 訂單資料表(1) & ".客戶訂單號, " & 訂單資料表(1) & ".形體號, " & 訂單資料表(1) & ".顏色,
- " & 訂單資料表(1) & ".楦型, " & 訂單資料表(1) & ".訂單數量, " & 訂單資料表(1) & ".客戶交期, " & 訂單資料表(1) & ".單價, " & 訂單資料表(1) & ".總金額,
- " & 訂單資料表(1) & ".備註, " & 訂單資料表(1) & ".生產工廠, " & 訂單資料表(1) & ".訂單種類, " & 訂單資料表(1) & ".工廠回復交期, " & 訂單資料表(1) & ".CFMSPEC,
- " & 訂單資料表(1) & ".CFMSAMPLE, " & 訂單資料表(1) & ".TRIAL1, " & 訂單資料表(1) & ".TRIAL2, " & 訂單資料表(1) & ".TRIAL3, " & 訂單資料表(1) & ".TRIAL4,
- " & 訂單資料表(1) & ".包裝確認時間, " & 訂單資料表(1) & ".貼標時間, " & 訂單資料表(1) & ".裁斷時間, " & 訂單資料表(1) & ".針車時間,
- " & 訂單資料表(1) & ".成型時間, " & 訂單資料表(1) & ".驗貨時間, " & 訂單資料表(1) & ".實際離廠日, " & 訂單資料表(1) & ".資料流水號,
- " & 訂單資料表(1) & ".明細建檔, " & 訂單資料表(1) & ".GOODBOX, " & 訂單資料表(1) & ".LEATHER, " & 訂單資料表(1) & ".LEA_Note, " & 訂單資料表(1) & ".出貨數量,
- " & 訂單資料表(1) & ".PO_S_Date AS 接單日, " & 訂單資料表(1) & ".Requested_XF AS 需求日期, " & 訂單資料表(1) & ".Confirm_XF AS 確認日期,
- " & 訂單資料表(1) & ".Revised_XF AS 修訂日期, " & 訂單資料表(1) & ".工廠回復交期 AS 工廠交期, " & 訂單資料表(1) & ".Special_Packaging,
- " & 訂單資料表(1) & ".Remarks, " & 訂單資料表(1) & ".出貨地, " & 訂單資料表(1) & ".TVW, " & 訂單資料表(1) & ".楦頭號, " & 訂單資料表(1) & ".材質,
- " & 訂單資料表(1) & ".七號模具, " & 訂單資料表(1) & ".TRIAL1 AS T1, " & 訂單資料表(1) & ".TRIAL2 AS T2, " & 訂單資料表(1) & ".長期試穿 AS WEAR_TEST,
- " & 訂單資料表(1) & ".CFMSAMPLE AS CFM, " & 訂單資料表(1) & ".TRIAL3 AS T3, " & 訂單資料表(1) & ".TRIAL4 AS T4, " & 訂單資料表(1) & ".CFMSPEC AS TEST,
- " & 訂單資料表(1) & ".面料, " & 訂單資料表(1) & ".副料, " & 訂單資料表(1) & ".中底, " & 訂單資料表(1) & ".鞋墊, " & 訂單資料表(1) & ".大底,
- " & 訂單資料表(1) & ".跟, " & 訂單資料表(1) & ".包裝確認時間 AS 包裝, " & 訂單資料表(1) & ".裁斷時間 AS 裁斷, " & 訂單資料表(1) & ".針車時間 AS 針車,
- " & 訂單資料表(1) & ".成型時間 AS 成型, " & 訂單資料表(1) & ".驗貨時間 AS 驗貨, " & 訂單資料表(1) & ".工廠進度表備註1, " & 訂單資料表(1) & ".工廠進度表備註2,
- " & 訂單資料表(1) & ".客戶包裝確認, " & 訂單資料表(1) & ".東莞業務備註, " & 訂單資料表(1) & ".工廠確認, " & 訂單資料表(1) & ".利威確認,
- " & 訂單資料表(1) & ".結關日, " & 訂單資料表(1) & ".SMS簽回, " & 訂單資料表(1) & ".FRS簽回, " & 訂單資料表(1) & ".MASTER_SWATCH, " & 訂單資料表(1) & ".力威訂單號,
- " & 訂單資料表(1) & ".ProductID, " & 訂單資料表(1) & ".UoM, " & 訂單資料表(2) & ".HS, " & 訂單資料表(0) & ".CustomerName
- FROM " & 訂單資料表(1) & " LEFT OUTER JOIN " & 訂單資料表(0) & " ON " & 訂單資料表(1) & ".訂單流水號 = " & 訂單資料表(0) & ".天盾流水號 LEFT OUTER JOIN
- " & 訂單資料表(2) & " ON " & 訂單資料表(1) & ".顏色 = " & 訂單資料表(2) & ".Colorway AND
- " & 訂單資料表(1) & ".ProductID = " & 訂單資料表(2) & ".ProductID AND " & 訂單資料表(1) & ".訂單流水號 = " & 訂單資料表(2) & ".天盾流水號 AND
- " & 訂單資料表(1) & ".客戶訂單號 = " & 訂單資料表(2) & ".客戶訂單號"
-
- ReadOnly SQL字串2 As String = " GROUP BY " & 訂單資料表(1) & ".訂單流水號, " & 訂單資料表(1) & ".年份季度, " & 訂單資料表(1) & ".客戶訂單號, " & 訂單資料表(1) & ".形體號, " & 訂單資料表(1) & ".顏色,
- " & 訂單資料表(1) & ".楦型, " & 訂單資料表(1) & ".訂單數量, " & 訂單資料表(1) & ".客戶交期, " & 訂單資料表(1) & ".單價, " & 訂單資料表(1) & ".總金額,
- " & 訂單資料表(1) & ".備註, " & 訂單資料表(1) & ".生產工廠, " & 訂單資料表(1) & ".訂單種類, " & 訂單資料表(1) & ".工廠回復交期, " & 訂單資料表(1) & ".CFMSPEC,
- " & 訂單資料表(1) & ".CFMSAMPLE, " & 訂單資料表(1) & ".TRIAL1, " & 訂單資料表(1) & ".TRIAL2, " & 訂單資料表(1) & ".TRIAL3, " & 訂單資料表(1) & ".TRIAL4,
- " & 訂單資料表(1) & ".包裝確認時間, " & 訂單資料表(1) & ".貼標時間, " & 訂單資料表(1) & ".裁斷時間, " & 訂單資料表(1) & ".針車時間,
- " & 訂單資料表(1) & ".成型時間, " & 訂單資料表(1) & ".驗貨時間, " & 訂單資料表(1) & ".實際離廠日, " & 訂單資料表(1) & ".資料流水號,
- " & 訂單資料表(1) & ".明細建檔, " & 訂單資料表(1) & ".GOODBOX, " & 訂單資料表(1) & ".LEATHER, " & 訂單資料表(1) & ".LEA_Note, " & 訂單資料表(1) & ".出貨數量,
- " & 訂單資料表(1) & ".PO_S_Date, " & 訂單資料表(1) & ".Requested_XF, " & 訂單資料表(1) & ".Confirm_XF, " & 訂單資料表(1) & ".Revised_XF,
- " & 訂單資料表(1) & ".工廠回復交期, " & 訂單資料表(1) & ".Special_Packaging, " & 訂單資料表(1) & ".Remarks, " & 訂單資料表(1) & ".出貨地,
- " & 訂單資料表(1) & ".TVW, " & 訂單資料表(1) & ".楦頭號, " & 訂單資料表(1) & ".材質, " & 訂單資料表(1) & ".七號模具, " & 訂單資料表(1) & ".TRIAL1,
- " & 訂單資料表(1) & ".TRIAL2, " & 訂單資料表(1) & ".長期試穿, " & 訂單資料表(1) & ".CFMSAMPLE, " & 訂單資料表(1) & ".TRIAL3, " & 訂單資料表(1) & ".TRIAL4,
- " & 訂單資料表(1) & ".CFMSPEC, " & 訂單資料表(1) & ".面料, " & 訂單資料表(1) & ".副料, " & 訂單資料表(1) & ".中底, " & 訂單資料表(1) & ".鞋墊,
- " & 訂單資料表(1) & ".大底, " & 訂單資料表(1) & ".跟, " & 訂單資料表(1) & ".包裝確認時間, " & 訂單資料表(1) & ".裁斷時間, " & 訂單資料表(1) & ".針車時間,
- " & 訂單資料表(1) & ".成型時間, " & 訂單資料表(1) & ".驗貨時間, " & 訂單資料表(1) & ".工廠進度表備註1, " & 訂單資料表(1) & ".工廠進度表備註2,
- " & 訂單資料表(1) & ".客戶包裝確認, " & 訂單資料表(1) & ".東莞業務備註, " & 訂單資料表(1) & ".工廠確認, " & 訂單資料表(1) & ".利威確認,
- " & 訂單資料表(1) & ".結關日, " & 訂單資料表(1) & ".SMS簽回, " & 訂單資料表(1) & ".FRS簽回, " & 訂單資料表(1) & ".MASTER_SWATCH,
- " & 訂單資料表(1) & ".力威訂單號, " & 訂單資料表(1) & ".ProductID, " & 訂單資料表(1) & ".UoM, " & 訂單資料表(2) & ".HS,
- " & 訂單資料表(0) & ".CustomerName
- ORDER BY SUBSTRING(" & 訂單資料表(1) & ".訂單流水號, 4, 6) DESC"
- Private Sub Set_DGV1載入前設定()
- DataGridView1.DataSource = Nothing : ds.Clear()
- DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
- DataGridView1.ColumnHeadersHeight = 25
- DataGridView1.AllowUserToAddRows = False
- ConnOpen()
- End Sub
- Private Sub Set_DGV1載入後設定()
- CmdSet_For_DGV() : 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 & "AND (" & 訂單資料表(1) & ".生產工廠 LIKE 'JH')" & SQL字串2
- ElseIf OPEXC(1) = True Then
- SQL1 = SQL字串1 & 列印用SQL & "AND (" & 訂單資料表(1) & ".生產工廠 LIKE 'SK')" & SQL字串2
- ElseIf OPEXC(2) = True Then
- SQL1 = SQL字串1 & 列印用SQL & "AND (" & 訂單資料表(1) & ".生產工廠 LIKE 'NJ')" & SQL字串2
- End If
- Set_DGV1載入後設定()
- End Sub
- Private Sub Set_格式設定()
- DataGridView1.Visible = True
- If CC(7) = False Then
- CheckBox9.Visible = False : Label9.Visible = False : CheckBox10.Visible = False : Label10.Visible = False
- End If
- End Sub
- Private Sub Set_循環列印()
- Dim W As Integer = 2
- If CheckBox1.Checked = True Then : xlSheet.Cells(3, W) = "TENDENZA PO#" : Q = W : W += 1 : End If
- If CheckBox2.Checked = True Then : xlSheet.Cells(3, W) = "SEASON" : Q = W : W += 1 : End If
- If CheckBox3.Checked = True Then : xlSheet.Cells(3, W) = "VIONIC PO#" : Q = W : W += 1 : End If
- If CheckBox4.Checked = True Then : xlSheet.Cells(3, W) = "STYLE" : Q = W : W += 1 : End If
- If CheckBox5.Checked = True Then : xlSheet.Cells(3, W) = "COLOR" : Q = W : W += 1 : End If
- If CheckBox6.Checked = True Then : xlSheet.Cells(3, W) = "DM" : Q = W : W += 1 : End If
- If CheckBox7.Checked = True Then : xlSheet.Cells(3, W) = "PRS" : Q = W : W += 1 : Index_PRS = Q : End If
- If CheckBox8.Checked = True Then : xlSheet.Cells(3, W) = "CUST X/F" : Q = W : W += 1 : End If
- If CheckBox9.Checked = True Then : xlSheet.Cells(3, W) = "PRICE" : Q = W : W += 1 : End If
- If CheckBox10.Checked = True Then : xlSheet.Cells(3, W) = "AMOUNT" : Q = W : W += 1 : End If
- If CheckBox11.Checked = True Then : xlSheet.Cells(3, W) = "REMARK" : Q = W : W += 1 : End If
- If CheckBox12.Checked = True Then : xlSheet.Cells(3, W) = "FTY" : Q = W : W += 1 : End If
- If CheckBox13.Checked = True Then : xlSheet.Cells(3, W) = "DIV" : Q = W : W += 1 : End If
- If CheckBox14.Checked = True Then : xlSheet.Cells(3, W) = "GOODBOX" : Q = W : W += 1 : End If
- If CheckBox15.Checked = True Then : xlSheet.Cells(3, W) = "LEATHER" : Q = W : W += 1 : End If
- If CheckBox16.Checked = True Then : xlSheet.Cells(3, W) = "LEA_Note" : Q = W : W += 1 : End If
- If CheckBox17.Checked = True Then : xlSheet.Cells(3, W) = "PO_S_Date" : Q = W : W += 1 : End If
- If CheckBox18.Checked = True Then : xlSheet.Cells(3, W) = "Requested_XF" : Q = W : W += 1 : End If
- If CheckBox19.Checked = True Then : xlSheet.Cells(3, W) = "Confirm_XF" : Q = W : W += 1 : End If
- If CheckBox20.Checked = True Then : xlSheet.Cells(3, W) = "Revised_XF" : Q = W : W += 1 : End If
- If CheckBox21.Checked = True Then : xlSheet.Cells(3, W) = "FTY X/F" : Q = W : W += 1 : Index_FTY_XF = Q : End If
- If CheckBox22.Checked = True Then : xlSheet.Cells(3, W) = "Special_Packaging" : Q = W : W += 1 : End If
- If CheckBox23.Checked = True Then : xlSheet.Cells(3, W) = "Remarks" : Q = W : W += 1 : End If
- If CheckBox24.Checked = True Then : xlSheet.Cells(3, W) = "TVW" : Q = W : W += 1 : End If
- If CheckBox25.Checked = True Then : xlSheet.Cells(3, W) = "楦頭號" : Q = W : W += 1 : End If
- If CheckBox26.Checked = True Then : xlSheet.Cells(3, W) = "材質" : Q = W : W += 1 : End If
- If CheckBox27.Checked = True Then : xlSheet.Cells(3, W) = "七號模具" : Q = W : W += 1 : End If
- If CheckBox28.Checked = True Then : xlSheet.Cells(3, W) = "T1" : Q = W : W += 1 : End If
- If CheckBox29.Checked = True Then : xlSheet.Cells(3, W) = "T2" : Q = W : W += 1 : End If
- If CheckBox30.Checked = True Then : xlSheet.Cells(3, W) = "WEAR_TEST" : Q = W : W += 1 : End If
- If CheckBox31.Checked = True Then : xlSheet.Cells(3, W) = "CFM" : Q = W : W += 1 : End If
- If CheckBox32.Checked = True Then : xlSheet.Cells(3, W) = "T3" : Q = W : W += 1 : End If
- If CheckBox33.Checked = True Then : xlSheet.Cells(3, W) = "T4" : Q = W : W += 1 : End If
- If CheckBox34.Checked = True Then : xlSheet.Cells(3, W) = "TEST" : Q = W : W += 1 : End If
- If CheckBox35.Checked = True Then : xlSheet.Cells(3, W) = "面料" : Q = W : W += 1 : End If
- If CheckBox36.Checked = True Then : xlSheet.Cells(3, W) = "副料" : Q = W : W += 1 : End If
- If CheckBox37.Checked = True Then : xlSheet.Cells(3, W) = "中底" : Q = W : W += 1 : End If
- If CheckBox38.Checked = True Then : xlSheet.Cells(3, W) = "鞋墊" : Q = W : W += 1 : End If
- If CheckBox39.Checked = True Then : xlSheet.Cells(3, W) = "大底" : Q = W : W += 1 : End If
- If CheckBox40.Checked = True Then : xlSheet.Cells(3, W) = "跟" : Q = W : W += 1 : End If
- If CheckBox41.Checked = True Then : xlSheet.Cells(3, W) = "包裝" : Q = W : W += 1 : End If
- If CheckBox42.Checked = True Then : xlSheet.Cells(3, W) = "裁斷" : Q = W : W += 1 : End If
- If CheckBox43.Checked = True Then : xlSheet.Cells(3, W) = "針車" : Q = W : W += 1 : End If
- If CheckBox44.Checked = True Then : xlSheet.Cells(3, W) = "成型" : Q = W : W += 1 : End If
- If CheckBox45.Checked = True Then : xlSheet.Cells(3, W) = "驗貨" : Q = W : W += 1 : End If
- If CheckBox46.Checked = True Then : xlSheet.Cells(3, W) = "工廠進度表備註1" : Q = W : W += 1 : End If
- If CheckBox47.Checked = True Then : xlSheet.Cells(3, W) = "工廠進度表備註2" : Q = W : W += 1 : End If
- If CheckBox48.Checked = True Then : xlSheet.Cells(3, W) = "客戶包裝確認" : Q = W : W += 1 : End If
- If CheckBox50.Checked = True Then : xlSheet.Cells(3, W) = "工廠包裝確認" : Q = W : W += 1 : End If
- If CheckBox51.Checked = True Then : xlSheet.Cells(3, W) = "利威驗貨確認" : Q = W : W += 1 : End If
- If CheckBox52.Checked = True Then : xlSheet.Cells(3, W) = "結關日" : Q = W : W += 1 : End If
- If CheckBox53.Checked = True Then : xlSheet.Cells(3, W) = "SMS簽回" : Q = W : W += 1 : End If
- If CheckBox54.Checked = True Then : xlSheet.Cells(3, W) = "FRS簽回" : Q = W : W += 1 : End If
- If CheckBox55.Checked = True Then : xlSheet.Cells(3, W) = "MASTER SWATCH" : Q = W : W += 1 : End If
- If CheckBox56.Checked = True Then : xlSheet.Cells(3, W) = "力威訂單號" : Q = W : W += 1 : End If
- If CheckBox57.Checked = True Then : xlSheet.Cells(3, W) = "ProductID" : Q = W : W += 1 : End If
- If CheckBox58.Checked = True Then : xlSheet.Cells(3, W) = "UoM" : Q = W : W += 1 : End If
- If CheckBox59.Checked = True Then : xlSheet.Cells(3, W) = "HS#" : Q = W : W += 1 : End If
- If CheckBox60.Checked = True Then : xlSheet.Cells(3, W) = "Company Code" : Q = W : W += 1 : End If
- If CheckBox49.Checked = True Then : xlSheet.Cells(3, W) = "東莞業務備註" : Q = 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 += 1 : End If
- If CheckBox2.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("年份季度").Value : W += 1 : End If
- If CheckBox3.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("客戶訂單號").Value : W += 1 : End If
- If CheckBox4.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("形體號").Value : W += 1 : End If
- If CheckBox5.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("顏色").Value : W += 1 : End If
- If CheckBox6.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("楦型").Value : W += 1 : End If
- If CheckBox7.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("訂單數量").Value : P = W : W += 1 : End If
- If CheckBox8.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("客戶交期").Value : W += 1 : End If
- If CheckBox9.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("單價").Value : R = W : W += 1 : End If
- If CheckBox10.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("總金額").Value : A = W : W += 1 : End If
- If CheckBox11.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("備註").Value : W += 1 : End If
- If CheckBox12.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("生產工廠").Value : W += 1 : End If
- If CheckBox13.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("訂單種類").Value : W += 1 : End If
- If CheckBox14.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("GOODBOX").Value : W += 1 : End If
- If CheckBox15.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("LEATHER").Value : W += 1 : End If
- If CheckBox16.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("LEA_Note").Value : W += 1 : End If
- If CheckBox17.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("接單日").Value : W += 1 : End If
- If CheckBox18.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("需求日期").Value : W += 1 : End If
- If CheckBox19.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("確認日期").Value : W += 1 : End If
- If CheckBox20.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("修訂日期").Value : W += 1 : End If
- If CheckBox21.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("工廠交期").Value : W += 1 : End If
- If CheckBox22.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("Special_Packaging").Value : W += 1 : End If
- If CheckBox23.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("Remarks").Value : W += 1 : End If
- If CheckBox24.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("TVW").Value : W += 1 : End If
- If CheckBox25.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("楦頭號").Value : W += 1 : End If
- If CheckBox26.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("材質").Value : W += 1 : End If
- If CheckBox27.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("七號模具").Value : W += 1 : End If
- If CheckBox28.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("T1").Value : W += 1 : End If
- If CheckBox29.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("T2").Value : W += 1 : End If
- If CheckBox30.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("WEAR_TEST").Value : W += 1 : End If
- If CheckBox31.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("CFM").Value : W += 1 : End If
- If CheckBox32.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("T3").Value : W += 1 : End If
- If CheckBox33.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("T4").Value : W += 1 : End If
- If CheckBox34.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("TEST").Value : W += 1 : End If
- If CheckBox35.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("面料").Value : W += 1 : End If
- If CheckBox36.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("副料").Value : W += 1 : End If
- If CheckBox37.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("中底").Value : W += 1 : End If
- If CheckBox38.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("鞋墊").Value : W += 1 : End If
- If CheckBox39.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("大底").Value : W += 1 : End If
- If CheckBox40.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("跟").Value : W += 1 : End If
- If CheckBox41.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("包裝").Value : W += 1 : End If
- If CheckBox42.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("裁斷").Value : W += 1 : End If
- If CheckBox43.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("針車").Value : W += 1 : End If
- If CheckBox44.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("成型").Value : W += 1 : End If
- If CheckBox45.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("驗貨").Value : W += 1 : End If
- If CheckBox46.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("工廠進度表備註1").Value : W += 1 : End If
- If CheckBox47.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("工廠進度表備註2").Value : W += 1 : End If
- If CheckBox48.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("客戶包裝確認").Value : W += 1 : End If
- If CheckBox50.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("工廠確認").Value : W += 1 : End If
- If CheckBox51.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("利威確認").Value : W += 1 : End If
- If CheckBox52.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("結關日").Value : W += 1 : End If
- If CheckBox53.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("SMS簽回").Value : W += 1 : End If
- If CheckBox54.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("FRS簽回").Value : W += 1 : End If
- If CheckBox55.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("MASTER_SWATCH").Value : W += 1 : End If
- If CheckBox56.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("力威訂單號").Value : W += 1 : End If
- If CheckBox57.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("ProductID").Value : W += 1 : End If
- If CheckBox58.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("UoM").Value : W += 1 : End If
- If CheckBox59.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("HS").Value : W += 1 : End If
- If CheckBox59.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("CustomerName").Value : W += 1 : End If
- If CheckBox49.Checked = True Then : xlSheet.Cells(i + 4, W) = DataGridView1.Rows(i).Cells("東莞業務備註").Value : 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
- 月選_起始_dtp.Value = Today() : 月選_結束_dtp.Value = Today()
- 週選_日期_CB.Text = DateAndTime.Day(Today)
- 週選_月份_CB.Text = DateAndTime.Month(Today)
- 週選_年份_CB.Text = DateAndTime.Year(Today)
- 週選_週數_cb.Text = "7"
- 月選_起始月_cb.Text = DateAndTime.Month(Today)
- 月選_結束月_cb.Text = DateAndTime.Month(Today)
- 月選_年_cb.Text = DateAndTime.Year(Today)
- 月選_結束年_cb.Text = DateAndTime.Year(Today)
- Set_格式設定()
- End Sub
- Private Sub 週選_年份_CB_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 週選_年份_CB.SelectedIndexChanged
- selectdate = CDate((週選_月份_CB.Text) & "/" & (週選_日期_CB.Text) & "/" & (週選_年份_CB.Text))
- 週選_DTP.Value = selectdate
- 週選_起日_tb.Text = Strings.Left(Strings.Format(週選_DTP.Value, "yyyy/MM/dd"), 10)
- End Sub
- Private Sub 週選_月份_CB_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 週選_月份_CB.SelectedIndexChanged
- If 週選_年份_CB.Text = "" Then
- Exit Sub
- Else
- selectdate = CDate((週選_月份_CB.Text) & "/" & (週選_日期_CB.Text) & "/" & (週選_年份_CB.Text))
- 週選_DTP.Value = selectdate
- 週選_起日_tb.Text = Strings.Left(Strings.Format(週選_DTP.Value, "yyyy/MM/dd"), 10)
- End If
- End Sub
- Private Sub 週選_日期_CB_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 週選_日期_CB.SelectedIndexChanged
- If 週選_年份_CB.Text = "" Then
- Exit Sub
- ElseIf 週選_月份_CB.Text = "" Then
- Exit Sub
- Else
- selectdate = CDate((週選_月份_CB.Text) & "/" & (週選_日期_CB.Text) & "/" & (週選_年份_CB.Text))
- 週選_DTP.Value = selectdate
- 週選_起日_tb.Text = Strings.Left(Strings.Format(週選_DTP.Value, "yyyy/MM/dd"), 10)
- End If
- End Sub
- Private Sub 月選_年_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 月選_年_cb.SelectedIndexChanged
- DTP = (月選_年_cb.Text) & "/" & (月選_起始月_cb.Text) & "/01"
- 月選_起始_dtp.Value = DTP
- 月選_起始_tb.Text = Strings.Left(Strings.Format(月選_起始_dtp.Value, "yyyy/MM/dd"), 10)
- 判斷月差()
- End Sub
- Private Sub 月選_起始月_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 月選_起始月_cb.SelectedIndexChanged
- If 月選_年_cb.Text = "" Then
- Exit Sub
- Else
- DTP = (月選_年_cb.Text) & "/" & (月選_起始月_cb.Text) & "/01"
- 月選_起始_dtp.Value = DTP
- 月選_起始_tb.Text = Strings.Left(Strings.Format(月選_起始_dtp.Value, "yyyy/MM/dd"), 10)
- End If
- 判斷月差()
- End Sub
- Private Sub 月選_結束年_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 月選_結束年_cb.SelectedIndexChanged
- DTP = (月選_結束年_cb.Text) & "/" & (月選_結束月_cb.Text) & "/01"
- 月選_結束_dtp.Value = DTP
- 月選_結束_dtp.Value = 月選_結束_dtp.Value.AddMonths(1)
- 月選_結束_dtp.Value = 月選_結束_dtp.Value.AddDays(-1)
- 月選_結束_tb.Text = Strings.Left(Strings.Format(月選_結束_dtp.Value, "yyyy/MM/dd"), 10)
- End Sub
- Private Sub 月選_結束月_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 月選_結束月_cb.SelectedIndexChanged
- If 月選_年_cb.Text = "" Then
- Exit Sub
- Else
- DTP = (月選_結束年_cb.Text) & "/" & (月選_結束月_cb.Text) & "/01"
- 月選_結束_dtp.Value = DTP
- 月選_結束_dtp.Value = 月選_結束_dtp.Value.AddMonths(1)
- 月選_結束_dtp.Value = 月選_結束_dtp.Value.AddDays(-1)
- 月選_結束_tb.Text = Strings.Left(Strings.Format(月選_結束_dtp.Value, "yyyy/MM/dd"), 10)
- End If
- End Sub
- Private Sub 減一個月_bt_Click(sender As Object, e As EventArgs) Handles 減一個月_bt.Click
- If 月選_結束月_cb.Text <> "1" Then
- 月選_結束月_cb.Text = Val(月選_結束月_cb.Text) - 1
- ElseIf 月選_結束月_cb.Text = "1" Then
- 月選_結束月_cb.Text = 12
- 月選_結束年_cb.Text = Val(月選_結束年_cb.Text) - 1
- End If
- 判斷月差()
- End Sub
- Private Sub 加一個月_bt_Click(sender As Object, e As EventArgs) Handles 加一個月_bt.Click
- If 月選_結束月_cb.Text <> "12" Then
- 月選_結束月_cb.Text = Val(月選_結束月_cb.Text) + 1
- ElseIf 月選_結束月_cb.Text = "12" Then
- 月選_結束月_cb.Text = 1
- 月選_結束年_cb.Text = Val(月選_結束年_cb.Text) + 1
- End If
- 判斷月差()
- End Sub
- Private Sub 判斷月差()
- If DateDiff(DateInterval.Month, 月選_起始_dtp.Value, 月選_結束_dtp.Value) > 11 Then
- 月選_起始月_cb.Text = DateAndTime.Month(Today)
- 月選_結束月_cb.Text = DateAndTime.Month(Today)
- 月選_年_cb.Text = DateAndTime.Year(Today)
- 月選_結束年_cb.Text = DateAndTime.Year(Today)
- MsgBox("選擇範圍超過1年", MsgBoxStyle.Information, "提示")
- ElseIf DateDiff(DateInterval.Month, 月選_起始_dtp.Value, 月選_結束_dtp.Value) < 0 Then
- 月選_起始月_cb.Text = DateAndTime.Month(Today)
- 月選_結束月_cb.Text = DateAndTime.Month(Today)
- 月選_年_cb.Text = DateAndTime.Year(Today)
- 月選_結束年_cb.Text = DateAndTime.Year(Today)
- MsgBox("選擇範圍年分順序顛倒", MsgBoxStyle.Information, "提示")
- End If
- End Sub
- Private Sub 彙總表_cb_CheckedChanged(sender As Object, e As EventArgs) Handles 彙總表_cb.CheckedChanged
- If 彙總表_cb.Checked = True Then
- If CheckBox21.Checked = False Then
- MsgBox("列印彙總表需要工廠交期,請勾選 FTY X/F", MsgBoxStyle.Information, "提示")
- 彙總表_cb.Checked = False
- ElseIf CheckBox7.Checked = False Then
- MsgBox("列印彙總表需要PRS,請勾選 PRS", MsgBoxStyle.Information, "提示")
- 彙總表_cb.Checked = False
- Else
- 彙總表_cb.Checked = True : 月份選擇_gb.Enabled = True : 週數選擇_gb.Enabled = True
- End If
- Else
- 月份選擇_gb.Enabled = False : 週數選擇_gb.Enabled = False
- Exit Sub
- End If
- End Sub
- Private Function 行指標轉換(ByVal index01 As Integer) As String
- Dim index_return As String = ""
- Select Case index01
- Case 1 : index_return = "A" : Case 2 : index_return = "B" : Case 3 : index_return = "C" : Case 4 : index_return = "D"
- Case 5 : index_return = "E" : Case 6 : index_return = "F" : Case 7 : index_return = "G" : Case 8 : index_return = "H"
- Case 9 : index_return = "I" : Case 10 : index_return = "J" : Case 11 : index_return = "K" : Case 12 : index_return = "L"
- Case 13 : index_return = "M" : Case 14 : index_return = "N" : Case 15 : index_return = "O" : Case 16 : index_return = "P"
- Case 17 : index_return = "Q" : Case 18 : index_return = "R" : Case 19 : index_return = "S" : Case 20 : index_return = "T"
- Case 21 : index_return = "U" : Case 22 : index_return = "V" : Case 23 : index_return = "W" : Case 24 : index_return = "X"
- Case 25 : index_return = "Y" : Case 26 : index_return = "Z" : Case 27 : index_return = "AA" : Case 28 : index_return = "AB"
- Case 29 : index_return = "AC" : Case 30 : index_return = "AD" : Case 31 : index_return = "AE" : Case 32 : index_return = "AF"
- Case 33 : index_return = "AG" : Case 34 : index_return = "AH" : Case 35 : index_return = "AI" : Case 36 : index_return = "AJ"
- Case 37 : index_return = "AK" : Case 38 : index_return = "AL" : Case 39 : index_return = "AM" : Case 40 : index_return = "AN"
- End Select
- Return index_return
- End Function
- Private Sub 週選_週數_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 週選_週數_cb.SelectedIndexChanged
- 週選_週數_tb.Text = 週選_週數_cb.Text
- End Sub
- Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
- Dim j As Integer = 1
- xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
- xlApp.Visible = True
- xlApp.DisplayAlerts = True
- xlApp.Application.WindowState = xlMaximized
- xlBook = xlApp.Workbooks.Add
- '----------------------------------------------------------------------------------------------------------------------
- xlSheet = NewMethod(xlBook)
- xlApp.Sheets(1).Name = "JH"
- xlApp.Sheets("JH").Select
- xlBook.Activate()
- xlSheet.Activate()
- OPEXC(0) = True : OPEXC(1) = False : OPEXC(2) = False
- xlSheet.Range("A1").Select()
- xlSheet.Cells(2, 2) = "天盾國際有限公司-訂單控制表(玖宏)"
- Set_循環列印()
- j += 1
- '----------------------------------------------------------------------------------------------------------------------
- xlSheet = NewMethod(xlBook)
- xlApp.Sheets(1).Name = "SK"
- xlApp.Sheets("SK").Select
- xlBook.Activate()
- xlSheet.Activate()
- OPEXC(0) = False : OPEXC(1) = True : OPEXC(2) = False
- xlSheet.Range("A1").Select()
- xlSheet.Cells(2, 2) = "天盾國際有限公司-訂單控制表(森康)"
- Set_循環列印()
- j += 1
- '----------------------------------------------------------------------------------------------------------------------
- xlSheet = NewMethod(xlBook)
- xlApp.Sheets(1).Name = "NJ"
- xlApp.Sheets("NJ").Select
- xlBook.Activate()
- xlSheet.Activate()
- OPEXC(0) = False : OPEXC(1) = False : OPEXC(2) = True
- xlSheet.Range("A1").Select()
- xlSheet.Cells(2, 2) = "天盾國際有限公司-訂單控制表(楠晉)"
- Set_循環列印()
- j += 1
- '---------------------------------------------------cover--------------------------------------------------------------
- If 彙總表_cb.Checked = True Then
- xlSheet = NewMethod(xlBook)
- xlApp.Sheets(1).Name = "cover"
- xlApp.Sheets("cover").Select
- xlBook.Activate()
- xlSheet.Activate()
- xlSheet.Range("A1").Select()
- Dim Str_FTY_XF As String = 行指標轉換(Index_FTY_XF)
- Dim Str_PRS As String = 行指標轉換(Index_PRS)
- 'xlSheet.Cells(2, 2) = "天盾國際有限公司-訂單彙總表"
- xlSheet.Cells(3, 2) = "Year " & 月選_年_cb.Text : xlSheet.Cells(3, 9) = "Year " & 週選_年份_CB.Text
- xlSheet.Cells(3, 4) = "NJ" : xlSheet.Cells(3, 5) = "SK" : xlSheet.Cells(3, 6) = "JH" : xlSheet.Cells(3, 7) = "total"
- xlSheet.Cells(3, 11) = "NJ" : xlSheet.Cells(3, 12) = "SK" : xlSheet.Cells(3, 13) = "JH" : xlSheet.Cells(3, 14) = "total"
- xlSheet.Cells(4, 2) = 月選_起始_tb.Text
- xlSheet.Cells(4, 3) = "unship" : xlSheet.Cells(4, 9) = "unship"
- ' --------- 月次選表 ---------
- xlSheet.Cells(4, 4) = "=SUMIF(NJ!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & "<" & """" & "&$B$4,NJ!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(4, 5) = "=SUMIF(SK!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & "<" & """" & "&$B$4,SK!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(4, 6) = "=SUMIF(JH!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & "<" & """" & "&$B$4,JH!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(4, 7) = "=SUM(D4:F4)"
- Dim count_month, count_year, Br As Integer
- Dim DTP2, DTP3 As Date
- DTP2 = 月選_起始_dtp.Value
- DTP3 = 月選_結束_dtp.Value
- Br = DateDiff(DateInterval.Month, DTP2, DTP3)
- count_month = 月選_起始_dtp.Value.Month
- count_year = 月選_起始_dtp.Value.Year
- For k = 1 To (Br + 1)
- xlSheet.Cells(k + 4, 3) = count_month
- xlSheet.Cells(k + 4, 2) = count_year
- xlSheet.Cells(k + 4, 4) = "=SUMPRODUCT((YEAR(NJ!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)=$B" & k + 4 & ")*(MONTH(NJ!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)=$C" & k + 4 & ")*NJ!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(k + 4, 5) = "=SUMPRODUCT((YEAR(SK!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)=$B" & k + 4 & ")*(MONTH(SK!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)=$C" & k + 4 & ")*SK!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(k + 4, 6) = "=SUMPRODUCT((YEAR(JH!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)=$B" & k + 4 & ")*(MONTH(JH!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)=$C" & k + 4 & ")*JH!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(k + 4, 7) = "=SUM(D" & k + 4 & ":F" & k + 4 & ")"
- DTP2 = DTP2.AddMonths(1)
- count_month = DTP2.Month
- count_year = DTP2.Year
- If k = (Br + 1) Then
- xlSheet.Cells(k + 5, 2) = Strings.Left(Strings.Format(DTP3, "yyyy/MM/dd"), 10)
- xlSheet.Cells(k + 5, 3) = "later"
- xlSheet.Cells(k + 5, 4) = "=SUMIF(NJ!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & ">" & """" & "&$B$" & k + 5 & ",NJ!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(k + 5, 5) = "=SUMIF(SK!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & ">" & """" & "&$B$" & k + 5 & ",SK!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(k + 5, 6) = "=SUMIF(JH!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & ">" & """" & "&$B$" & k + 5 & ",JH!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(k + 5, 7) = "=SUM(D" & k + 5 & ":F" & k + 5 & ")"
- xlSheet.Cells(k + 6, 2) = "total"
- xlSheet.Cells(k + 6, 4) = "=SUM(D4:D" & k + 5 & ")"
- xlSheet.Cells(k + 6, 5) = "=SUM(E4:E" & k + 5 & ")"
- xlSheet.Cells(k + 6, 6) = "=SUM(F4:F" & k + 5 & ")"
- xlSheet.Cells(k + 6, 7) = "=SUM(D" & k + 6 & ":F" & k + 6 & ")"
- End If
- Index_月_total = k + 6
- Next
-
- ' --------- 週次選表 ---------
- xlSheet.Cells(4, 11) = "=SUMIF(NJ!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & "<" & """" & "&$I$5,NJ!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(4, 12) = "=SUMIF(SK!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & "<" & """" & "&$I$5,SK!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(4, 13) = "=SUMIF(JH!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & "<" & """" & "&$I$5,JH!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(4, 14) = "=SUM(K4:M4)"
- xlSheet.Cells(5, 9) = 週選_起日_tb.Text
- For kk = 1 To CInt(週選_週數_tb.Text)
- xlSheet.Cells(kk + 4, 10) = "=I" & (kk + 4) & "+6"
- xlSheet.Cells(kk + 4, 11) = "=SUMPRODUCT(((NJ!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)>=$I" & kk + 4 & ")*((NJ!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)<=$J" & kk + 4 & ")*NJ!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(kk + 4, 12) = "=SUMPRODUCT(((SK!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)>=$I" & kk + 4 & ")*((SK!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)<=$J" & kk + 4 & ")*SK!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(kk + 4, 13) = "=SUMPRODUCT(((JH!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)>=$I" & kk + 4 & ")*((JH!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999)<=$J" & kk + 4 & ")*JH!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(kk + 4, 14) = "=SUM(K" & kk + 4 & ":M" & kk + 4 & ")"
- If kk > 1 Then
- xlSheet.Cells(kk + 4, 9) = "=J" & (kk + 3) & "+1"
- End If
- If kk = CInt(週選_週數_tb.Text) Then
- xlSheet.Cells(kk + 5, 9) = "later"
- xlSheet.Cells(kk + 5, 11) = "=SUMIF(NJ!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & ">" & """" & "&$J$" & kk + 4 & ",NJ!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(kk + 5, 12) = "=SUMIF(SK!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & ">" & """" & "&$J$" & kk + 4 & ",SK!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(kk + 5, 13) = "=SUMIF(JH!$" & Str_FTY_XF & "$4:$" & Str_FTY_XF & "$9999," & """" & ">" & """" & "&$J$" & kk + 4 & ",JH!$" & Str_PRS & "$4:$" & Str_PRS & "$9999)"
- xlSheet.Cells(kk + 5, 14) = "=SUM(K" & kk + 5 & ":M" & kk + 5 & ")"
- xlSheet.Cells(kk + 6, 9) = "total"
- xlSheet.Cells(kk + 6, 11) = "=SUM(K4:K" & kk + 5 & ")"
- xlSheet.Cells(kk + 6, 12) = "=SUM(L4:L" & kk + 5 & ")"
- xlSheet.Cells(kk + 6, 13) = "=SUM(M4:M" & kk + 5 & ")"
- xlSheet.Cells(kk + 6, 14) = "=SUM(K" & kk + 6 & ":M" & kk + 6 & ")"
- End If
- Next
- Excel巨集_C(xlApp, xlSheet)
- j += 1
- End If
- '----------------------------------------------------------------------------------------------------------------------
- xlApp.Sheets(j).Delete
- 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 CheckBox7.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 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 CheckBox10.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 += 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 Excel巨集_C(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 = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
- .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
- End With
-
- ' 改變行寬 Columns("A") & Columns("H")
- xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 1
- xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 1
-
- ' 改變行寬
- xlSheet.Columns("B:C").Select : myExcel.Selection.ColumnWidth = 10
- xlSheet.Columns("I:J").Select : myExcel.Selection.ColumnWidth = 10
- xlSheet.Columns("D:G").Select : myExcel.Selection.ColumnWidth = 15
- xlSheet.Columns("K:N").Select : myExcel.Selection.ColumnWidth = 15
-
- '全選改變列高
- xlSheet.Cells.Select() '全選
- myExcel.Selection.RowHeight = 25 '改變列高
- xlSheet.Range("A1").Select()
-
- ' 改變列高Rows("1")
- xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 5
- ' 改變列高Rows("2")
- xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 35
-
- ' ("B2到N2")跨欄至中
- xlSheet.Range("B2:N2").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
-
- ' ("B3到C3")跨欄至中
- xlSheet.Range("B3:C3").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
-
- ' ("I3到J3")跨欄至中
- xlSheet.Range("I3:J3").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
-
- ' ("I4到J4")跨欄至中
- xlSheet.Range("I4:J4").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
- myExcel.Selection.Merge
-
- '月total 跨欄至中
- xlSheet.Range("B" & Index_月_total.ToString & ":C" & Index_月_total.ToString).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
-
- '跨欄至中 週 later
- xlSheet.Range("I" & (CInt(週選_週數_tb.Text) + 5).ToString & ":J" & (CInt(週選_週數_tb.Text) + 5).ToString).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
-
- '跨欄至中 週 total
- xlSheet.Range("I" & (CInt(週選_週數_tb.Text) + 6).ToString & ":J" & (CInt(週選_週數_tb.Text) + 6).ToString).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("I5:J" & (CInt(週選_週數_tb.Text) + 4).ToString).Select()
- myExcel.Selection.NumberFormatLocal = "mm/dd/yy;@" '設置格式
- xlSheet.Range("B4").Select()
- myExcel.Selection.NumberFormatLocal = "mm/dd/yy;@"
- xlSheet.Range("B" & (Index_月_total - 1).ToString).Select()
- myExcel.Selection.NumberFormatLocal = "mm/dd/yy;@"
-
- ' 改變字體大小
- xlSheet.Range("B2:N2").Select()
- myExcel.Selection.Font.Size = 14
-
- ' 儲存格設置格式 (數值 千分位符號)
- xlSheet.Range("D4:G1000").Select() : myExcel.Selection.NumberFormatLocal = "#,##0_ "
- xlSheet.Range("K4:N1000").Select() : myExcel.Selection.NumberFormatLocal = "#,##0_ "
-
- ' 儲存格顏色設定
- xlSheet.Range("B3:G3").Select()
- With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .Color = 16247773 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
-
- ' 儲存格顏色設定
- xlSheet.Range("I3:N3").Select()
- With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .Color = 16247773 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
-
- ' 儲存格顏色設定
- 'xlSheet.Range("B2:N2").Select()
- 'With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.399975585192419 : .PatternTintAndShade = 0 : End With
-
- ' 儲存格顏色設定 月total
- xlSheet.Range("G4:G" & Index_月_total.ToString).Select()
- With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent2 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
-
- ' 儲存格顏色設定 月total
- xlSheet.Range("B" & Index_月_total.ToString & ":G" & Index_月_total.ToString).Select()
- With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent2 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
-
- ' 儲存格顏色設定 週total
- xlSheet.Range("N4:N" & (CInt(週選_週數_tb.Text) + 6).ToString).Select()
- With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent2 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
-
- ' 儲存格顏色設定 週total
- xlSheet.Range("I" & (CInt(週選_週數_tb.Text) + 6).ToString & ":N" & (CInt(週選_週數_tb.Text) + 6).ToString).Select()
- With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent2 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
-
-
- ' 儲存格 格線設定 月
- xlSheet.Range("B3:G" & Index_月_total.ToString).Select()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
-
- ' 儲存格 格線設定 週
- xlSheet.Range("I3:N" & (CInt(週選_週數_tb.Text) + 6).ToString).Select()
- myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
-
- ' 儲存格 格線設定 標頭
- 'xlSheet.Range("B2:N2").Select()
- 'myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- 'myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- 'With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- 'With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- 'With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- 'With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- 'With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
- 'With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
-
- '全選後資料至中
- xlSheet.Cells.Select()
- With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
- .ShrinkToFit = False : .ReadingOrder = xlContext
- End With
-
- ' 隱藏格線
- myExcel.ActiveWindow.DisplayGridlines = False
- End Sub
- End Class
|