2023年4月10日 星期一

V120502 - Grid 的欄位允許編輯 - grid -欄位編輯

目的 : V120502 Grid的欄位允許編輯 

PS:  ExtJs 的Grid介紹與常用功能  - 

網址 :  https://wadehuanglearning.blogspot.com/2017/01/ext.html

處理說明: 1>Ext.Grid 必須透過官方套件才可以編輯內容,可以在 plugins 屬性載入                                                 Ext.grid.plugin.CellEditing 或 Ext.grid.plugin.RowEditing 便可對 Grid 資料進行編輯。   

                 2>columns 中,允許編輯的欄位,加入
             { header: "件號", dataIndex: "PN", width: 150, TMType: "string",editor: 'textfield',},
             { header: "數量", dataIndex: "QTY", width: 50, TMType: "string",
                editor: {   xtype: 'textfield',  
                                 allowBlank: false //不允許空白},
              },]




1>*.js  - grid 欄位允許編輯

  //包籤列印 sub_Grid
    var sub_Grid = Ext.create('TMGrid', {
        grid_id: 'sub_Grid',
        columns: sub_Columns,
        autoScroll: true,
        flex: 1,        
        store: Ext.create('gridstore', { model: sub_Fields }),
        plugins: [
            Ext.create('Ext.grid.plugin.RowEditing', {   // 加入官方 CellEditing 差件
                clicksToEdit: 1                           // 按一下進行編輯,預設為按兩下
            })
        ],
    });

var sub_Columns = [
        { header: "工號", dataIndex: "SAPNO", width: 150, TMType: "string" },
        { header: "件號", dataIndex: "PN", width: 150, TMType: "string",//editor: 'textfield',},
        {
            header: "數量", dataIndex: "QTY", width: 50, TMType: "string",            
            editor: {
                xtype: 'textfield',
                allowBlank: false   //不允許空白
            },
        },
        { header: "EO", dataIndex: "EOCND", width: 150, TMType: "string" },
        { header: "備註", dataIndex: "RMK", width: 200, TMType: "string", },
    ]







ExtJs 的Grid介紹與常用功能 - store -proxy() - reader - V120502 - Grid欄位修改

 目的: ExtJs 的Grid介紹與常用功能  

-   網址 :  https://wadehuanglearning.blogspot.com/2017/01/ext.html

處理說明: 1>Grid 主要分成兩部份:
                      1>>一個顯示欄位標題的Columns。
                     2>>一個儲存資料的Store 元件。
                 2>Columns 欄位定義:
                     1>>Columns用來Grid 的定義表格欄位,具有header與dataIndex屬性的物件陣列。 
                      2>>利用header 屬性來決定Grid 的欄位名稱。
                      3>>利用dataIndex 屬性來與Store 的資料相配對。
                      4>>Grid 的欄位顯示順序完全由此Columns 加入的順序決定。
                 3>Store 介紹: 用來存取表格的原始資料,
                      1>>可以是近端的二維陣列(Array ),或是遠端的JSON 或XML 資料。
                      2>>利用fields 屬性來與columns 欄位相配對。

                      3>>reader 用來解析原始資料,如原始資料格式為json,reader的type 就填json
                                     ,type 可以是 array, json, xml
                      5>>proxy : 資料來源 , type: 'memory',   //store.data  
                                                             type: 'ajax'       ,   //遠端資料庫 url ,np

一.簡單範例 - store資料來源: data(local)  , proxy.type:'memory'



var store = Ext.create('Ext.data.Store', {
    fields: ['name', 'email', 'phone'],  //利用fields 與Columns 的dataIndex 做配對。
    data: {'items': [             //原始資料
            {'name': 'Lisa', "email": "lisa@simpsons.com", "phone": "555-111-1224"},
            {'name': 'Bart', "email": "bart@simpsons.com", "phone": "555-222-1234"},
            {'name': 'Homer', "email": "home@simpsons.com", "phone": "555-222-1244"},
            {'name': 'Marge', "email": "marge@simpsons.com", "phone": "555-222-1254"}
        ]},
    proxy: {
        type: 'memory',    //若 store 資料來源為遠端,則proxy.type:'ajax' , url:'xx/xx/', getMethod: function () { return 'POST'; },
                           //若 store 資料來源為Data,則proxy.type:'memory' 
        reader: {
            type: 'json',  //reader用來解析原始資料,如原始資料格式為json,reader 的type 就填json 。 #可以是 array, json, xml
            root: 'items'  //告訴reader 要選擇data 中哪一個含有raw Data 的Array 的物件。
        }
    }
});

var columnModel = [     ////建立ColumnMode
    {text: '名稱', dataIndex: 'name'},
    {text: '電子信箱', dataIndex: 'email', flex: 1},
    {text: '電話', dataIndex: 'phone'}
];

Ext.create('Ext.grid.Panel', {    // 新增Grid
    title: 'Grid 範例',
    store: store,                 //將預先寫好的store 填入grid
    columns: columnModel,         //將預先寫好的columns 填入grid
    height: 200,
    width: 400,
    renderTo: Ext.getBody()
});




二. 產生子視窗 - 含Grid  - 利用 Template , 遠端資料庫


1>*.js
//產生子視窗 - 含 Grid
function PrnPackBtn_click() {
    var sub_Columns = [
        { header: "工號", dataIndex: "SAPNO", width: 150, TMType: "string" },
        { header: "件號", dataIndex: "PN", width: 150, TMType: "string",//editor: 'textfield',},
        {
            header: "數量", dataIndex: "QTY", width: 50, TMType: "string",            
            editor: {
                xtype: 'textfield',
                allowBlank: false   //不允許空白
            },
        },
        { header: "EO", dataIndex: "EOCND", width: 150, TMType: "string" },
        { header: "備註", dataIndex: "RMK", width: 200, TMType: "string", },
    ]

    var sub_Fields = [
        { name: "SAPNO" },
        { name: "PN" },
        { name: "QTY" },
        { name: "EOCND" },
        { name: "RMK" },
    ];
    //包籤列印 sub_Grid
    var sub_Grid = Ext.create('TMGrid', {
        grid_id: 'sub_Grid',
        columns: sub_Columns,
        autoScroll: true,
        flex: 1,        
        store: Ext.create('gridstore', { model: sub_Fields }),
        plugins: [
            Ext.create('Ext.grid.plugin.RowEditing', {   // 加入官方 CellEditing 差件
                clicksToEdit: 1                           // 按一下進行編輯,預設為按兩下
            })
        ],
    });

    //將子視窗 store 不分頁,  PageToolBar.Visible 設為 false , 不分頁
    Ext.getCmp('sub_Grid_ptb').setVisible(false);

2>TMGrid.js  : 定義 TMGrid   &  gridstore
Ext.define('gridstore', {
    extend: 'Ext.data.Store',
    pageSize: 30,
    //model: gridmodel,
    autoLoad: false,
    remoteFilter: true,
    //remoteSort: true,
    proxy: {
        type: "ajax",
        url: '',
        getMethod: function () { return 'POST'; },
        reader: {
            type: "json",
            root: 'T1',
            totalProperty: 'T1C[0].TOTAL'
        }
    },
    sorters: [],
    constructor: function (config) {
        Ext.apply(this, config); //將gridstore本身的屬性與input config結合
        if (typeof config.model != "undefined") {
            J_gridmodel = config.model;
        }
        Ext.define('gridmodel', {
            extend: 'Ext.data.Model',
            fields: J_gridmodel
        });
        this.model = gridmodel;
        this.callParent(config);
        this.getProxy().setModel(gridmodel, true);
    }
});





2023年4月5日 星期三

V80204B - 按鈕 icon - 圖示的設定 - 左移,右移

 目的: V80204B - 按鈕 icon - 圖示的設定

處理說明:  1>設定Button的 iconCls 屬性,     iconCls: 'icon-right',
                 2>實際讀取: ext-patch.css 的對應 icon設定(icon-right)
                 3>.icon-right {
                                         background-image: url('../images/icons/right.png');
                                       }  



2023年3月28日 星期二

AMM系統無法自動更新至最新版本 - 控制台移除應用程式,重新安裝即可

 目的: AMM系統無法自動更新至最新版本的處理說明

處理說明: 1>於控制台,刪除應用程式[AMM系統]

                  2>重新安裝[AMM系統]即可  - 於 TLS入口網站下載 [AMM系統],重新安裝即可






V20301 - [編輯]時, 顯示欄位挑選按鈕 - 按鈕顯示 , 顯示按鈕

 目的: 按[編輯]鈕時, 顯示欄位[挑選]按鈕

處理說明: 1>showFormButton('myform'); //20230329

                   2>showFormButton('myform', ['btn_DEPID']);  //顯示部份欄位按鈕


1>*.js
 //修改
    Ext.getCmp('btn_edit').on("click", function () {
        setFieldsCls('myform', [], ['TMCPCTRLNO', 'EFF'], ['DEPID', 'FILENO', 'GROP', 'CUSTODIAN', 'ENGINEER', 'DUEDT']);
        showFormButton('myform'); //20230329
        //showFormButton('myform', ['btn_DEPID']);
      });



V80204D - 日期區間 – 預設值: 一年前

目的: 畫面的日期預設為去年的今日(=今日-365)

處理說明:  1>*.js  以 ms 記錄日期(1天 = 1000*60*60*24)
                   2> var Tmp_DATA_DATE2 = DatetoStr(now, "Y/m/d");
                         var Tmp_DATA_DATE1 = DatetoStr((now - 365*1000 * 60 * 60 * 24), "Y/m/d");
                         Ext.getCmp("sub4_DATA_DATE1").setValue(Tmp_DATA_DATE1);
                         Ext.getCmp("sub4_DATA_DATE2").setValue(Tmp_DATA_DATE2);


1>*.js

    var Tmp_DATA_DATE2 = DatetoStr(now, "Y/m/d");
    var Tmp_DATA_DATE1 = DatetoStr((now - 365*1000 * 60 * 60 * 24), "Y/m/d");
    console.log("Tmp_DATA_DATE1:", Tmp_DATA_DATE1);
    Ext.getCmp("sub4_DATA_DATE1").setValue(Tmp_DATA_DATE1);
    Ext.getCmp("sub4_DATA_DATE2").setValue(Tmp_DATA_DATE2);



2023年3月14日 星期二

V80204C - XLS2XLS – 依讀取的 XLS 檔案,匯出相關XLS檔案

 目的:  V80204C – [確定匯入]- 依讀取 XLS 檔案,匯出相關XLS檔案

處理說明: 1>後端.[讀取檔案] -   Request.Files  
                                                     - foreach (string cur_FName in Request.Files)
                                                        Stream Tmp_in_Stream = Request.Files[cur_FName].InputStream;
                                                        wk.LoadFromStream(Tmp_in_Stream);
                  2>後端.[匯出檔案] 
                                    -  wk2.SaveToStream(Tmp_out_Stream, FileFormat.Version2010);
                                       HttpContext.Current.Response.BinaryWrite(Tmp_out_Stream.ToArray());

                  1>[匯出檔案]至前端 Browser, 必需使用 Cookie 顯示訊息,
                      --> 不可使用 response.Content
                      --> *.cs.匯出函式 傳回 voild , 非 HttpResponseMessage, 不可使用 successful/failure ,

                2>若同時[匯入檔案] &[匯出檔案], 不可使用 f_downloadFile(若只匯出檔案才可用之)
                          -->  因 f_downloadFile 會自行產生 Form & submit , 非使用者自定的畫面.submit(包含[檔案]欄位)



1>*.js  - V80204C.js
   {
            xtype: 'button', text: '確定匯入', id: 'OkBtn_Sub3',
            listeners: {
                click: function (me, e, eOpts) {                    
                    var Tmp_Str = "";
                    if (checkisnull(Ext.getCmp("sub3_FName").getValue())) {
                        Tmp_Str = "[檔案來源]欄位不可空白<br>"
                            + " 敬請檢核 !!";
                        mywarnalert(Tmp_Str);
                        return;
                    }              
                    Ok_process(me, e, eOpts);       
                } // end of click
            }  // end of listener
        },

//[確認匯入]鈕 , 處理
function Ok_process(me, e, eOpts) {
    console.log(" 1 inside Ok_process");
    console.log(" me: ", me);
    //取得 [檔案上傳].檔名
    var Tmp_FileObj = Ext.getCmp('sub3_FName');
    np["in_FName"] = Ext.getDom(Tmp_FileObj.inputId).value    
    console.log("Tmp_FileObj :", Tmp_FileObj);
    var Tmp_Str = "";
    var np = {};
    np["sub3_PROJID"] = Ext.getCmp("sub3_PROJID").getValue();
    np["out_FName"] = "V80204_件號報工統計.xlsx";
    np["headers"] = { 'Content-type': 'multipart/form-data' },

    me.up("form").submit({
        url: '../api/V80204CAPI/XLSIN2XLSOUT',
        method: 'POST',
        headers: { 'Content-type': 'multipart/form-data' },
        params: np,        
    });  // end of  me.up("form").submit({

    //隔兩秒才顯示完成訊息
    var timer = setInterval(function () {
        var cookie_token = Ext.util.Cookies.get("EX_DFile");
        if (cookie_token != null) {
            clearInterval(timer);
            timer = null;
            //mask.hide();            
            var rtn_msg=r_cookies('EX_DFile');
            mysuccessalert(rtn_msg);
            me.up("window").close();
            me.up("window").destroy();
        }
    }, 2000);  //等待 2000ms =1sec    
};  // end of Ok_process() {  //批次新增

     
2>*.cs   V80204C*.cs  XLSIN2XLSOUT
 // [件號報工統計] - [確定匯入] 鈕 , 匯入 件號XLS 檔案後,產出該[件號報工資料]
        [HttpPost]
        public void XLSIN2XLSOUT()
        {

            HttpContext c = HttpContext.Current;
            NameValueCollection nvc = c.Request.Form;
            //OracleConnection conn = new OracleConnection(DBService.ConnectionString(("AMMEU"));//
            OracleConnection conn = new OracleConnection(DBService.ConnectionString((DBLINK)));//
            OracleCommand cmd = new OracleCommand();
            OracleDataReader reader;
            DataSet ds = null;

            //取得匯入檔案名稱   of   filefield            
            string Tmp_in_FName = nvc["in_FName"];
            //取得匯出檔案名稱   of   filefield
            string Tmp_out_FName = nvc["out_FName"];
            string Tmp_sub3_PROJID = nvc["sub3_PROJID"];
            Workbook wk = null;
            Workbook wk2 = null;
            MemoryStream Tmp_out_Stream = new MemoryStream();

            HttpRequest Request = HttpContext.Current.Request;
            var response = this.Request.CreateResponse();
            //string file_Name = Tmp_in_FName;
            string FILEDT = DateTime.Now.ToString("yyyy/MM/dd");
            string Tmp_RtnMsg = "";
            string Tmp_RtnMsg1 = "";
            string Tmp_Sql = "", Tmp_Str = "";
            int Tmp_cnt = 0;
            //HttpCookie MyCookie = new HttpCookie("Rtn_Msg");
            HttpCookie MyCookie = new HttpCookie("EX_DFile", HttpUtility.UrlEncode(Tmp_Str));
            int row2 = 0;
            conn.Open();
            cmd.Connection = conn;
            try
            {
                foreach (string cur_FName in Request.Files)
                {
                    string fileType = Request.Files[cur_FName].ContentType;
                    Stream Tmp_in_Stream = Request.Files[cur_FName].InputStream;
                    Tmp_in_FName = Path.GetFileName(Request.Files[cur_FName].FileName);
                    int fileSize = Request.Files[cur_FName].ContentLength;
                    byte[] fileRcrd = new byte[fileSize];
                    //更新資料庫欄位值                                                
                    //匯入的 xls
                    wk = new Workbook();
                    wk.LoadFromStream(Tmp_in_Stream);
                    Worksheet sheet1 = wk.Worksheets[0];

                    //匯出的 xls
                    wk2 = new Workbook();
                    Worksheet sheet2 = wk2.Worksheets[0];//獲取第一個工作表
                    string[] outFieldArray = { "AMM單號", "工號", "版本", "件號", "件號名稱",
                                                           "製程", "製程資料內容", "WBS", "工單類型",  "數量", "單位",
                                                          "EOECN", "專案","機號","起始值(STARTVAL)", "情況處理碼",
                                                           "工單報工統計(小時)", "工作中心", "工作中心報工統計(小時)"
                                                                };
                    for (int i = 0; i < outFieldArray.Length; i++)
                    {
                        sheet2.Range[myfunc.GetExcelPos(i, 0)].Text = outFieldArray[i];
                    }

                    int RowsCount = sheet1.LastRow;
                    string Tmp_AMMNO, Tmp_SAPNO, Tmp_ED, Tmp_PN, Tmp_PNNAME;
                string Tmp_MKNO, Tmp_MKDESCPT, Tmp_WBS, Tmp_SROTP, Tmp_QTY, Tmp_UNIT;
              string Tmp_ECNO, Tmp_PROJID, Tmp_ACNO, Tmp_STARTVAL, Tmp_CNDPROCCODE;
                    string Tmp_ALS_HR_, Tmp_WC_, Tmp_WCHR_;

                    //STEP1 檢核  XLS 欄位名稱資料是否正確  -取得 標題 of  件號                                          
                    Tmp_PN = sheet1.Range[myfunc.GetExcelPos(0, 0)].Value;

                    //xls 欄位名稱有問題
                    if ((Tmp_PN != "件號"))
                    {
                        Tmp_RtnMsg = "匯入檔案欄位名稱必需如下:<br>";
                        //(Tmp_DTSOR != "資料來源") || (Tmp_OGONOAF != "拆檢提領編號") || (Tmp_NGONOAF != "維修提領編號") || (Tmp_RPNOAF != "拆檢交修單號") || (Tmp_MRPNOAF != "維修約交修單號") ||
                        if (Tmp_PN != "件號")
                            Tmp_RtnMsg = Tmp_RtnMsg + "第1欄欄位名稱:  [件號];";
                        //Tmp_RtnMsg = "匯入檔案欄位名稱必需如下:<br>"
                        //                         + "\件號"
                        //                         + " 敬請檢核";
                        //Tmp_Str = "{success: false,FName:" + myfunc.AA(FName) + ",Rtn_Msg:" + myfunc.AA(Tmp_RtnMsg) + "}";
                        //response.Content = new StringContent(Tmp_Str);    // 回應內容
                        //return response;
                        //以 Cookie 方式傳回訊息 , 因為要下載[匯出檔案],無傳回值 所以利用 Cookie 傳回訊息 -,f_downloadFile('EX_DFile', '../api/V80C03API/DB2XLS', np, 'POST', function () {
                        MyCookie.Value = HttpUtility.UrlEncode(Tmp_RtnMsg);
                        HttpContext.Current.Response.Cookies.Add(MyCookie);
                        HttpContext.Current.Response.End();
                    };
                    //STEP2 取得xls.[目前件號].報工資料                    
                    for (int i = 0; i < RowsCount; i++)
                    {
                        Tmp_PN = sheet1.Range[myfunc.GetExcelPos(0, i + 1)].Value;
                        if (myfunc.checkisnull(Tmp_PN))
                        { break; }
                        Tmp_Sql = "SELECT   AMMNO,SAPNO, "
                                                      + " ( SELECT  ED  "
                                                      + "   FROM  AMM_EDLST b "
                                     + "   WHERE  (AMMNO, ITM) in (   select AMMNO, max(to_number(ITM)) "
                                                                                          + " from AMM_EDLST group by AMMNO)  "
                                     + "  AND        a.AMMNO = b.AMMNO) ED,  "
                                    + "  PN,PNNAME,MKNO,MKDESCPT,WBS,SROTP,QTY,UNIT ,ECNO,PROJID,ACNO,STARTVAL,CNDPROCCODE  "
                                       + "   FROM    AMM_SRO a  "
                                       + "   WHERE  LENGTH(SAPNO)> 7  ";
                        if (!myfunc.checkisnull(Tmp_sub3_PROJID))
                            Tmp_Sql = Tmp_Sql + "    AND       PROJID = " + myfunc.AA(Tmp_sub3_PROJID);
                        Tmp_Sql = Tmp_Sql + "     AND       PN = " + myfunc.AA(Tmp_PN)
                                                         + "     ORDER   BY   ACNO,PN  ";
                        cmd.CommandText = Tmp_Sql;
                        reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            Tmp_AMMNO = reader["AMMNO"].ToString();
                            Tmp_SAPNO = reader["SAPNO"].ToString();
                            Tmp_ED = reader["ED"].ToString();
                            Tmp_PN = reader["PN"].ToString();
                            Tmp_PNNAME = reader["PNNAME"].ToString();
                            Tmp_MKNO = reader["MKNO"].ToString();
                            Tmp_MKDESCPT = reader["MKDESCPT"].ToString();
                            Tmp_WBS = reader["WBS"].ToString();
                            Tmp_SROTP = reader["SROTP"].ToString();
                            Tmp_QTY = reader["QTY"].ToString();
                            Tmp_UNIT = reader["UNIT"].ToString();
                            Tmp_ECNO = reader["ECNO"].ToString();
                            Tmp_PROJID = reader["PROJID"].ToString();
                            Tmp_ACNO = reader["ACNO"].ToString();
                            Tmp_STARTVAL = reader["STARTVAL"].ToString();
                            Tmp_CNDPROCCODE = reader["CNDPROCCODE"].ToString();
                            //取得[工單報工工時]
                            Tmp_Sql = " SELECT   round((sum(HOUR_WORK)+sum(HOUR_OT))/60,2)  HR  "
                                            + "  FROM  "
                                            + "    (  "
                            + " SELECT  JCN, ACT, WC, HOUR_WORK, work_ID, HOUR_OT from HOUR.ALS_HOUR_COMP @ALS_HOUR where JCN = '0000' || " + myfunc.AA(Tmp_SAPNO)
                                            + " union all  "
                                            + "  select JCN, ACT, WC, HOUR_WORK, work_ID, HOUR_OT from HOUR.ALS_HOUR_COMP_HISTORY @ALS_HOUR where JCN = '0000' || " + myfunc.AA(Tmp_SAPNO)
                                            + "   )  "
                                            + "   group by JCN ";
                            Tmp_ALS_HR_ = myfunc.SqlValue(Tmp_Sql);
              Tmp_Sql = "   SELECT  WC,round((sum(HOUR_WORK)+sum(HOUR_OT))/60,2)  WCHR  "
                                           + "   FROM  "
                                           + "  (  "
                                           + "   select JCN, ACT, WC, HOUR_WORK, work_ID, HOUR_OT from HOUR.ALS_HOUR_COMP @ALS_HOUR where JCN = '0000' || " + myfunc.AA(Tmp_SAPNO)
                                           + "   union all  "
                                           + "   select JCN, ACT, WC, HOUR_WORK, work_ID, HOUR_OT from HOUR.ALS_HOUR_COMP_HISTORY @ALS_HOUR where JCN = '0000' || " + myfunc.AA(Tmp_SAPNO)
                                           + "  )  "
                                           + "  group by JCN,WC  ";
                            Tmp_Str = myfunc.SqlValue(Tmp_Sql);
                            Tmp_WC_ = myfunc.StrExtract(Tmp_Str, 1);
                            Tmp_WCHR_ = myfunc.StrExtract(Tmp_Str, 2);
                            //匯出至  wk2.Sheet2
                            /*
                             { AMM單號, 工號, 版本, 件號, 件號名稱,
                                                                製程, 製程資料內容, WBS, 工單類型,  數量, 單位,
                                                                EOECN, 專案,機號,起始值(STARTVAL), 情況處理碼,
                                                                工單報工統計(小時), 工作中心, 工作中心報工統計(小時)
                                                               ];
                            */
                            //- 匯出  { AMM單號, 工號, 版本, 件號, 件號名稱,
                            row2 = row2 + 1;
                            sheet2.Range[myfunc.GetExcelPos(0, row2)].Text = Tmp_AMMNO;
                            sheet2.Range[myfunc.GetExcelPos(1, row2)].Text = Tmp_SAPNO;
                            sheet2.Range[myfunc.GetExcelPos(2, row2)].Text = Tmp_ED;
                            sheet2.Range[myfunc.GetExcelPos(3, row2)].Text = Tmp_PN;
                            sheet2.Range[myfunc.GetExcelPos(4, row2)].Text = Tmp_PNNAME;
                            //製程, 製程資料內容, WBS, 工單類型,  數量, 單位,
                            sheet2.Range[myfunc.GetExcelPos(5, row2)].Text = Tmp_MKNO;
                            sheet2.Range[myfunc.GetExcelPos(6, row2)].Text = Tmp_MKDESCPT;
                            sheet2.Range[myfunc.GetExcelPos(7, row2)].Text = Tmp_WBS;
                            sheet2.Range[myfunc.GetExcelPos(8, row2)].Text = Tmp_SROTP;
                            sheet2.Range[myfunc.GetExcelPos(9, row2)].Text = Tmp_QTY;
                            sheet2.Range[myfunc.GetExcelPos(10, row2)].Text = Tmp_UNIT;
                            //EOECN, 專案,機號,起始值(STARTVAL), 情況處理碼,
                            sheet2.Range[myfunc.GetExcelPos(11, row2)].Text = Tmp_ECNO;
                            sheet2.Range[myfunc.GetExcelPos(12, row2)].Text = Tmp_PROJID;
                            sheet2.Range[myfunc.GetExcelPos(13, row2)].Text = Tmp_ACNO;
                            sheet2.Range[myfunc.GetExcelPos(14, row2)].Text = Tmp_STARTVAL;
                            sheet2.Range[myfunc.GetExcelPos(15, row2)].Text = Tmp_CNDPROCCODE;
                            // 工單報工統計(小時), 工作中心, 工作中心報工統計(小時)
                            sheet2.Range[myfunc.GetExcelPos(16, row2)].Text = Tmp_ALS_HR_;
                            sheet2.Range[myfunc.GetExcelPos(17, row2)].Text = Tmp_WC_;
                            sheet2.Range[myfunc.GetExcelPos(18, row2)].Text = Tmp_WCHR_;
                        } // end of while reader.read()
                    }  // end of for (int i = 0; i < RowsCount; i++)
                    sheet2.AllocatedRange.AutoFitColumns();
                    wk2.SaveToStream(Tmp_out_Stream, FileFormat.Version2010);
                }  //end of foreach (string cur_FName in Request.Files)
            } // end fo try{             
            catch (Exception e)
            {
                //Console.WriteLine(e);
                Tmp_RtnMsg = "錯誤訊息如下:"
                                         + e.Message;
                MyCookie.Value = HttpUtility.UrlEncode(Tmp_RtnMsg);
                HttpContext.Current.Response.Cookies.Add(MyCookie);
                HttpContext.Current.Response.End();
                //throw;
            }
            finally
            {
                wk.Dispose();
                wk2.Dispose();
                conn.Close();
            }
            //return response;
            //Tmp_Cnt = 6;
            Tmp_Str = "已匯出完成!!  (" + row2.ToString() + "筆) <br>"
                            + "檔案名稱(" + Tmp_out_FName + ")";
            //MyCookie = new HttpCookie("EX_DFile", HttpUtility.UrlEncode(Tmp_Str));
            MyCookie.Value = HttpUtility.UrlEncode(Tmp_Str);
            HttpContext.Current.Response.Cookies.Add(MyCookie);
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + HttpUtility.UrlEncode(Tmp_out_FName, System.Text.Encoding.UTF8) + "\"");
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            HttpContext.Current.Response.BinaryWrite(Tmp_out_Stream.ToArray());
            HttpContext.Current.Response.End();
        }  //  end of  XLSIN2XLSOUT()