#include <Array.au3>
#include <FileConstants.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>
Local $CSV_Data_Path = FileOpenDialog("選擇檔案", @ScriptDir & "", "(*.CSV)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, $CSV_Data_Path)
Sleep(1000)
Local $sRange = "B:B" ;注意刪除後會遞補所以要邊寫邊測試欄位是否符合
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除SYS
Local $sRange = "F:H"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除報修單位,報修人,維護單位
Local $sRange = "J:M"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除承商處理,派工日期,執行人員,維修人員
Local $sRange = "L:L"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除離場日期
Local $sRange = "N:O"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除里程數,運轉時數
Local $sRange = "Q:Q"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除故障元件
Local $sRange = "Y:Z"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除週轉性商品,轉單日期
Local $sRange = "AB:AB"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除外包總人時
Local $sRange = "AE:AE"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除核準
Local $sRange = "AH:AH"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除RAM
Local $sRange = "AI:AP"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除標註時間,催修時間,斷電時間,斷電人員,是否掛鎖,復電時間,復電人員,斷電副卡已交給承商
Local $sRange = "AJ:AJ"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除轉單理由
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "物料編號", "AJ1") ;增加欄位
_Excel_RangeReplace($oWorkbook, Default, Default, ",", ",") ;查找分隔符號","並替代為","注音豆號
_Excel_RangeReplace($oWorkbook, Default, Default, "'", "-") ;查找分隔符號"'"並替代為"_"底線
_Excel_RangeInsert($oWorkbook.Activesheet, "H:H", $xlShiftToRight )
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "=CLEAN(G1)", "H1") ;寫入清除不可見字元碼
_Excel_RangeCopyPaste($oWorkbook.Activesheet, "H1", "H2:H200", Default, $xlPasteFormats) ; 粘贴格式到目标范围
_Excel_RangeInsert($oWorkbook.Activesheet, "J:J", $xlShiftToRight )
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "=CLEAN(I1)", "J1") ;寫入清除不可見字元碼
_Excel_RangeCopyPaste($oWorkbook.Activesheet, "J1", "J2:J200", Default, $xlPasteFormats) ; 粘贴格式到目标范围
_Excel_RangeInsert($oWorkbook.Activesheet, "M:M", $xlShiftToRight )
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "=CLEAN(L1)", "M1") ;寫入清除不可見字元碼
_Excel_RangeCopyPaste($oWorkbook.Activesheet, "M1", "M2:M200", Default, $xlPasteFormats) ; 粘贴格式到目标范围
Local $sWorkbook = @ScriptDir & "\PIDS-CM-INPUT.CSV"
_Excel_BookSaveAs($oWorkbook, $sWorkbook, $xlCSV, True)
_Excel_BookClose($oWorkbook, True)
Local $CSV_Data_Path = @ScriptDir & "\PIDS-CM-INPUT.CSV"
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, $CSV_Data_Path)
Local $sRange = "G:G"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除舊故障敘述,保留已移除不可見字元欄位
Local $sRange = "H:H"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除舊故障描述補充說明,保留已移除不可見字元欄位
Local $sRange = "J:J"
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftToLeft) ;刪除舊維修處理情形,保留已移除不可見字元欄位