Esempio n. 1
0
 void gridViewOperation_AfterAdd(PJ_24 e)
 {
     DSOFramerControl dsoFramerControl1 = new DSOFramerControl();
     Microsoft.Office.Interop.Excel.Workbook wb;dsoFramerControl1.FileData = e.BigData;
     wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook;
     ExcelAccess ea = new ExcelAccess();
     ea.MyWorkBook = wb;
     ea.MyExcel = wb.Application;
     ea.SetCellValue(ParentObj.OrgName , 4, 9);
     dsoFramerControl1.FileSave();
     e.BigData = dsoFramerControl1.FileData;
     dsoFramerControl1.FileClose();
     dsoFramerControl1.Dispose();
     dsoFramerControl1 = null;
 }
Esempio n. 2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (rowData.BigData.Length == 0)
     {
         mOrg org = MainHelper.PlatformSqlMap.GetOneByKey<mOrg>(rowData.ParentID);
         string fname = Application.StartupPath + "\\00记录模板\\23配电线路产权维护范围协议书.xls";
         string bhname = org.OrgName.Replace("供电所", "");
         DSOFramerControl dsoFramerControl1 = new DSOFramerControl();
         dsoFramerControl1.FileOpen(fname);
         Microsoft.Office.Interop.Excel.Workbook wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook;
         //PJ_23 obj = (PJ_23)MainHelper.PlatformSqlMap.GetObject("SelectPJ_23List", "where ParentID='" + rowData.ParentID + "' and xybh like '" + SelectorHelper.GetPysm(org.OrgName.Replace("供电所", ""), true) + "" + DateTime.Now.Year.ToString() + "%' order by xybh ASC");
         //int icount = 1;
         //if (obj != null && obj.xybh !="")
         //{
         //    icount = Convert.ToInt32(obj.xybh.Split('-')[2])+1;
         //}
         //string strname = SelectorHelper.GetPysm(bhname, true);
         ExcelAccess ea = new ExcelAccess();
         ea.MyWorkBook = wb;
         ea.MyExcel = wb.Application;
         ea.SetCellValue(rowData.xybh.ToUpper(), 4, 8);
         //strname = DateTime.Now.Year.ToString();
         //ea.SetCellValue(strname, 4, 9);
         //strname = string.Format("{0:D3}", icount);
         //ea.SetCellValue(strname, 4, 10);
         ea.SetCellValue(rowData.linename, 10, 7);
         ea.SetCellValue(rowData.fzlinename, 10, 10);
         ea.SetCellValue("'" + rowData.gh, 10, 16);
         ea.SetCellValue(rowData.cqfw, 11, 4);
         ea.SetCellValue(rowData.cqdw, 13, 4);
         ea.SetCellValue(rowData.qdrq.Year.ToString(), 21, 7);
         ea.SetCellValue(rowData.qdrq.Month.ToString(), 21, 9);
         ea.SetCellValue(rowData.qdrq.Day.ToString(), 21, 11);
         dsoFramerControl1.FileSave();
         rowData.BigData = dsoFramerControl1.FileData;
         dsoFramerControl1.FileClose();
         dsoFramerControl1.Dispose();
         dsoFramerControl1 = null;
         //rowData.xybh = SelectorHelper.GetPysm(bhname, true).ToUpper() + "-" + DateTime.Now.Year.ToString() + "-" + string.Format("{0:D3}", icount);
     }
     DSOFramerControl dsoFramerControl2 = new DSOFramerControl();
     dsoFramerControl2.FileData = rowData.BigData;
     Microsoft.Office.Interop.Excel.Workbook wb2 = dsoFramerControl2.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook;
     ExcelAccess ea2 = new ExcelAccess();
     ea2.MyWorkBook = wb2;
     ea2.MyExcel = wb2.Application;
     ea2.SetCellValue(comboBoxEdit1.Text, 11, 4);
     dsoFramerControl2.FileSave();
     rowData.BigData = dsoFramerControl2.FileData;
     dsoFramerControl2.FileClose();
     dsoFramerControl2.Dispose();
     dsoFramerControl2 = null;
 }
Esempio n. 3
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     //if (comboBoxEdit1.Text == "")
     //{
     //    MsgBox.ShowTipMessageBox("变动地点不能为空。");
     //    comboBoxEdit1.Focus();
     //    return;
     //}
    
     ////if (rowData.BigData == null)
     ////{
     ////    rowData.BigData = new byte[0];
     ////}
     //this.DialogResult = DialogResult.OK;
     //this.Close();
     IList<PJ_24> list = Client.ClientHelper.PlatformSqlMap.GetList<PJ_24>("where ParentID='" + rowData.ParentID + "'");
     string bh = (list.Count + 1).ToString("000");
     DSOFramerControl dsoFramerControl1 = new DSOFramerControl();
     Microsoft.Office.Interop.Excel.Workbook wb;
     if (rowData.BigData == null || rowData.BigData.Length == 0)
     {
         string fname = Application.StartupPath + "\\00记录模板\\24设备变更通知书.xls";
         dsoFramerControl1.FileOpen(fname);
     }
     else
         dsoFramerControl1.FileData = rowData.BigData;
     wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook;
     ExcelAccess ea = new ExcelAccess();
     ea.MyWorkBook = wb;
     ea.MyExcel = wb.Application;
     DateTime dt = Convert.ToDateTime(dateEdit1.EditValue);
     ea.SetCellValue(dt.Year.ToString(), 4, 7);
     ea.SetCellValue(bh, 4, 10);
     ea.SetCellValue(dt.Year.ToString(), 9, 1);
     ea.SetCellValue(dt.Month.ToString(), 9, 3);
     ea.SetCellValue(dt.Day.ToString(), 9, 5);
     ea.SetCellValue(comboBoxEdit1.Text, 6, 7);
     ea.SetCellValue(memoEdit1.Text, 6, 8);
     ea.SetCellValue(memoEdit2.Text, 6, 11);
     dsoFramerControl1.FileSave();
     rowData.BigData = dsoFramerControl1.FileData;
     dsoFramerControl1.FileClose();
     dsoFramerControl1.Dispose();
     dsoFramerControl1 = null;
 }
Esempio n. 4
0
        private void btView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (gridView1.FocusedRowHandle > -1)
            {
                PJ_ryda OBJECT = gridView1.GetRow(gridView1.FocusedRowHandle) as PJ_ryda;
                if (OBJECT.BigData != null)
                {
                    if (OBJECT.BigData.Length != 0)
                    {
                        SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                        string fname = "";
                        saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls";
                        if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                            fname = saveFileDialog1.FileName;
                            //WriteDoc(OBJECT.BigData, fname );
                            DSOFramerControl ds1 = new DSOFramerControl();
                            ds1.FileDataGzip = OBJECT.BigData;
                            //ds1.FileSave();
                            //ds1.FileClose();
                            ds1.FileSave(fname, true);
                            //ExcelAccess ex = new ExcelAccess();

                            
                            //ex.Open(fname);
                            //此处写填充内容代码
                            //ds1.FileSave(fname,true);
                            ds1.FileClose();
                            ds1.Dispose();
                            //ex.ShowExcel();
                            if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK)
                                return;

                            System.Diagnostics.Process.Start(fname);
                        }
                    }
                   

                }
                
            }
        }
Esempio n. 5
0
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "请选择文件路径";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
            ///循环判断当前目录下的文件和目录
            DSOFramerControl ds1 = new DSOFramerControl();

                string filepath = dialog.SelectedPath;
                GetFileList(ds1, filepath);
                //ds1.FileSave();
                //ds1.FileClose();
                ds1.Dispose();
                if (parentObj!=null)
                RefreshData( "where OrgCode ='" + parentObj.OrgCode    + "'");
            }
        }
Esempio n. 6
0
        private void btnOK_Click(object sender, EventArgs e)
        {

            string strname = "";
            string fname = "";
            string bhname = "";
            int icount = 1;


            DSOFramerControl dsoFramerControl1 = new DSOFramerControl();
            Microsoft.Office.Interop.Excel.Workbook wb;
            ExcelAccess ea = new ExcelAccess();
            if (rowData.BigData == null || rowData.BigData.Length == 0)
            {
                fname = Application.StartupPath + "\\00记录模板\\26防护通知书.xls";
                dsoFramerControl1.FileOpen(fname);
            }
            else
                dsoFramerControl1.FileData = rowData.BigData;
            wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook;
            ea.MyWorkBook = wb;
            ea.MyExcel = wb.Application;
            if (rowData.BigData == null || rowData.BigData.Length == 0)
            {
                fname = Application.StartupPath + "\\00记录模板\\26防护通知书.xls";



                mOrg org = MainHelper.PlatformSqlMap.GetOneByKey<mOrg>(rowData.ParentID);
                bhname = org.OrgName.Replace("供电所", "");
                PJ_26 objtemp = (PJ_26)MainHelper.PlatformSqlMap.GetObject("SelectPJ_26List", "where ParentID='" + rowData.ParentID + "' and xybh like '" + SelectorHelper.GetPysm(org.OrgName.Replace("供电所", ""), true) + "-" + DateTime.Now.Year.ToString() + "-%' order by xybh ASC");

                if (objtemp != null && objtemp.xybh != "")
                {
                    icount = Convert.ToInt32(objtemp.xybh.Split('-')[2]) + 1;
                }
                rowData.xybh = SelectorHelper.GetPysm(bhname, true).ToUpper() + "-" + DateTime.Now.Year.ToString() + "-" + string.Format("{0:D3}", icount);
                strname = SelectorHelper.GetPysm(bhname, true);
                ea.SetCellValue(strname.ToUpper(), 4, 9);
                strname = DateTime.Now.Year.ToString();
                ea.SetCellValue(strname, 4, 11);
                strname = string.Format("{0:D3}", icount);
                ea.SetCellValue(strname, 4, 13);

            }
            ea.SetCellValue(comboBoxEdit1.Text + ":", 5, 2);
            ea.SetCellValue(comboBoxEdit3.Text, 6, 11);
            if (memoEdit2.Text.Length > 25)
            {
                ea.SetCellValue(memoEdit2.Text.Substring(0, 25), 7, 3);
                ea.SetCellValue(memoEdit2.Text.Substring(26), 8, 2);
            }
            else
            {
                ea.SetCellValue(memoEdit2.Text, 7, 3);
            }
            if (memoEdit3.Text.Length > 23)
            {
                ea.SetCellValue(memoEdit3.Text.Substring(0, 23), 13, 4);
                ea.SetCellValue(memoEdit3.Text.Substring(24), 14, 2);
            }
            else
            {
                ea.SetCellValue(memoEdit3.Text, 13, 4);
            }
            dsoFramerControl1.FileSave();
            rowData.BigData = dsoFramerControl1.FileData;
            dsoFramerControl1.FileClose();
            dsoFramerControl1.Dispose();
            dsoFramerControl1 = null;
            PJ_26 sbxs = RowData as PJ_26;
            string strmes = "";
            object obj = MainHelper.PlatformSqlMap.GetOneByKey<PJ_26>(sbxs.ID);
            if (obj == null)
            {
                MainHelper.PlatformSqlMap.Create<PJ_26>(sbxs);

                WF_ModleRecordWorkTaskIns mrwt = new WF_ModleRecordWorkTaskIns();
                mrwt.ModleRecordID = sbxs.ID;
                mrwt.RecordID = currRecord.ID;
                mrwt.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
                mrwt.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
                mrwt.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
                mrwt.ModleTableName = sbxs.GetType().ToString();
                mrwt.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                mrwt.CreatTime = DateTime.Now;
                MainHelper.PlatformSqlMap.Create<WF_ModleRecordWorkTaskIns>(mrwt);
            }

            else
            {
                MainHelper.PlatformSqlMap.Update<PJ_26>(sbxs);

            }

            currRecord.LastChangeTime = DateTime.Now.ToString();
            if (RecordWorkTask.CheckOnRiZhi(WorkFlowData))
            {

                RecordWorkTask.CreatRiZhi(WorkFlowData, null, currRecord.ID, new object[] { rowData, currRecord });

            }
            WF_WorkTaskCommands wt;

            if (RecordWorkTask.CheckOnRiZhi(WorkFlowData))
            {

                RecordWorkTask.CreatRiZhi(WorkFlowData, null, currRecord.ID, new object[] { sbxs, currRecord });

            }
            //string[] strtemp = RecordWorkTask.RunNewGZPRecord(currRecord.ID, kind, MainHelper.User.UserID);
            wt = (WF_WorkTaskCommands)MainHelper.PlatformSqlMap.GetObject("SelectWF_WorkTaskCommandsList", " where WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "' and WorkTaskId='" + WorkFlowData.Rows[0]["WorkTaskId"].ToString() + "'");
            if (wt != null)
            {
                strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), wt.CommandName);
            }
            else
            {
                strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), "提交");
            }
            if (strmes.IndexOf("未提交至任何人") > -1)
            {
                MsgBox.ShowTipMessageBox("未提交至任何人,创建失败,请检查流程模板和组织机构配置是否正确!");
                return;
            }
            else
                MsgBox.ShowTipMessageBox(strmes);
            strmes = RecordWorkTask.GetWorkFlowTaskCaption(WorkFlowData.Rows[0]["WorkTaskInsId"].ToString());
            if (strmes == "结束节点1")
            {
                currRecord.Status = "存档";
            }
            else
            {
                currRecord.Status = strmes;
            }
            if (currRecord.ImageAttachment == null)
            {
                currRecord.ImageAttachment = new byte[0];
            }
            if (currRecord.DocContent == null)
            {
                currRecord.DocContent = new byte[0];
            }
            if (currRecord.SignImg == null)
            {
                currRecord.SignImg = new byte[0];
            }

            currRecord.LastChangeTime = DateTime.Now.ToString();
            if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0];
            if (currRecord.SignImg == null) currRecord.SignImg = new byte[0];
            MainHelper.PlatformSqlMap.Update("UpdateLP_Record", currRecord);
        }
Esempio n. 7
0
        public static int ExportToExcel(string title, string dw, sdjls_sbpjb pj17) {
            string fname = Application.StartupPath + "\\00记录模板\\送管22送电线路设备评级表.xls";
            DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl();
            string outfname = Path.GetTempFileName() + ".xls";
            File.Copy(fname, outfname);
            dsoFramerWordControl1.FileOpen(outfname);
            Microsoft.Office.Interop.Excel.Worksheet xx;
            Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;        
            ExcelAccess ex = new ExcelAccess();
            ex.MyWorkBook = wb;
            ex.MyExcel = wb.Application;
            sd_xl xl = MainHelper.PlatformSqlMap.GetOne<sd_xl>(" where LineCode='" + pj17.LineCode + "'");
            try {
                if (xl == null) {
                    MsgBox.ShowWarningMessageBox("数据出错,没找到线路");
                    return -1;
                }
                string strLinexh = xl.WireType;//导线型号
                
                //IList<sd_gt> gtlis = Client.ClientHelper.PlatformSqlMap.GetList<sd_gt>(" Where LineCode='" + xl.LineCode + "' order by gtcode");
                int gtcount = Client.ClientHelper.PlatformSqlMap.GetRowCount<sd_gt>(" Where LineCode='" + xl.LineCode + "'");
                ex.ActiveSheet(1);
                //设置线路值
                ex.SetCellValue(xl.LineName, 3, 3);
                ex.SetCellValue(xl.LineVol, 3, 8);
                ex.SetCellValue(xl.WireLength.ToString(), 3, 11);
                ex.SetCellValue(xl.InDate.Year + "年" + xl.InDate.Month + "月", 3, 13);
                //ex.SetCellValue(xl.InDate.Year.ToString(), 4, 9);
                //ex.SetCellValue(xl.InDate.Month.ToString(), 4, 11);
                //评级日期
                ex.SetCellValue(DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日", 4, 3);

                //杆塔
                ex.SetCellValue(gtcount.ToString(), 5, 3);//合计
                ex.SetCellValue(gtcount.ToString(), 6, 3);//一类
                //导地线
                ex.SetCellValue(xl.WireLength.ToString(), 9, 3);//合计
                ex.SetCellValue(xl.WireLength.ToString(), 10, 3);//一类
                //绝缘子
                string sql = "in (";
                //foreach (sd_gt gt in gtlis)
                //{ 
                //    sql+="'"+gt.gtID+"',";
                //}
                //sql = sql.Substring(0, sql.Length - 1) + ")";
                sql = "in (select gtid from sd_gt Where LineCode='" + xl.LineCode + "' )";
                string strSQL = "select  sbid from sd_gtsb Where  gtID " + sql;
                
                IList jdzzList = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", strSQL);
               
                   
                strSQL += "  and ("+getNamesql()+")";
                

                IList jyuzlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", strSQL);

                ex.SetCellValue(jyuzlist.Count.ToString(), 13, 3);
                ex.SetCellValue(jyuzlist.Count.ToString(), 14, 3);
                //接地装置
                ex.SetCellValue(jdzzList.Count.ToString(), 17, 3);
                ex.SetCellValue(jdzzList.Count.ToString(), 18, 3);

                //其它
                
                //评定等级
                ex.SetCellValue("一级", 24, 3);
                //评级负责人
                if (MainHelper.User != null)
                {
                    ex.SetCellValue(MainHelper.User.UserName, 25, 3);
                }
            } catch (Exception exmess) {
                MsgBox.ShowTipMessageBox(exmess.Message.ToString());
            }
            dsoFramerWordControl1.FileSave();
            pj17.BigData = dsoFramerWordControl1.FileDataGzip;
            dsoFramerWordControl1.FileClose();
            dsoFramerWordControl1.Dispose();
            //#endregion
            //System.Diagnostics.Process.Start(outfname);
            return 1;
        }
Esempio n. 8
0
        private void barReExport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (gridView1.FocusedRowHandle < 0) return;

            DataRow dr = gridView1.GetDataRow(gridView1.FocusedRowHandle);
            
            LP_Record currRecord = new LP_Record();
            foreach (DataColumn dc in gridtable.Columns)
            {
                if (dc.ColumnName != "Image")
                {
                    if (dc.DataType.FullName.IndexOf("Byte[]") < 0)
                        currRecord.GetType().GetProperty(dc.ColumnName).SetValue(currRecord, dr[dc.ColumnName], null);
                    else if (dc.DataType.FullName.IndexOf("Byte[]") > -1 && DBNull.Value != dr[dc.ColumnName] && dr[dc.ColumnName].ToString() != "")
                        currRecord.GetType().GetProperty(dc.ColumnName).SetValue(currRecord, dr[dc.ColumnName], null);

                }
            }
            if (currRecord.ID.IndexOf("N") > -1)
            {
                MsgBox.ShowTipMessageBox("此记录由新模块创建,请使用新模块操作!");
                return;
            }
            if (currRecord.Status != "存档")
            {
                MsgBox.ShowTipMessageBox("安监未审核,不能导出!");
                return;
            }
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = "";
            saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                fname = saveFileDialog1.FileName;
                try
                {
                    DSOFramerControl ds1 = new DSOFramerControl();
                    ds1.FileDataGzip = currRecord.DocContent ;
                    //ds1.FileOpen(ds1.FileName);
                    ds1.FileSave(fname,true);
                    ds1.FileClose();
                    ExcelAccess ea = new ExcelAccess();
                    ea.Open(fname);
                    char pchar = '|';
                    Excel.Workbook wb = ds1.AxFramerControl.ActiveDocument as Excel.Workbook;
                    Excel.Worksheet xx = wb.Application.Sheets[1] as Excel.Worksheet;
                    IList<LP_Temple> templeList = MainHelper.PlatformSqlMap.GetList<LP_Temple>("SelectLP_TempleList", "where ParentID ='" + ParentObj.LPID + "' and isExplorer='1' Order by SortID");
                    LockExcel(ea);
                    unLockExcel(ea);

                    foreach (LP_Temple lp in templeList)
                    {
                        string[] arrCellpos = lp.CellPos.Split(pchar);
                        for (int i = 0; i < arrCellpos.Length && arrCellpos[i] != ""; i++)
                        {
                            ea.SetCellValue("", GetCellPos(arrCellpos[i])[0], GetCellPos(arrCellpos[i])[1]);

                        }

                    }
                    ea.ShowExcel();
                    ds1.FileClose();
                    ds1.Dispose ();
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.Message ); 
                    MsgBox.ShowWarningMessageBox ("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。");
                    return;
                }
            }


        }
Esempio n. 9
0
        public static int ExportToExcel(string title, string dw, sdjl_21 pj17) {
            string fname = Application.StartupPath + "\\00记录模板\\送电21线路条图.xls";
            float fxstart = 0, fystart = 0, fwidth = 0, fheight = 0;
            DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl();
            string outfname = Path.GetTempFileName() + ".xls";
            File.Copy(fname, outfname);
            dsoFramerWordControl1.FileOpen(outfname);
            Microsoft.Office.Interop.Excel.Worksheet xx;
            Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;        
            ExcelAccess ex = new ExcelAccess();
            ex.MyWorkBook = wb;
            ex.MyExcel = wb.Application;
            sd_xl xl = MainHelper.PlatformSqlMap.GetOne<sd_xl>(" where LineCode='" + pj17.LineCode + "'");
            Dictionary<int, NZLength> Dic = new Dictionary<int, NZLength>();
            try {
                if (xl == null) {
                    MsgBox.ShowWarningMessageBox("数据出错,没找到线路");
                    return -1;
                }
                string strLinexh = xl.WireType;//导线型号
                sd_gt gtformer = null;
                IList<sd_gt> gtlis = Client.ClientHelper.PlatformSqlMap.GetList<sd_gt>(" Where LineCode='" + xl.LineCode + "' order by gtcode");
                int h = 1;
                int start = -1;
                int end = -1;
                bool notStart=true;
                decimal sums = 0;
                foreach (sd_gt gt in gtlis)
                {
                    if (gt.gtModle != "直线杆")
                    {
                        if (notStart)
                        {
                            start = h;
                            notStart = false;
                        }
                        sums += gt.gtSpan;
                    }
                    else
                    {
                        notStart = true;
                        end = h - 1;
                        if (start > 0)
                        {
                            Dic.Add(h, new NZLength{Start = start,End = end,Sum = sums});
                        }
                        start = -1;
                        end = -1;
                        sums = 0;
                        
                    }
                    h++;
                }

                gtformer = Client.ClientHelper.PlatformSqlMap.GetOne<sd_gt>(" Where gtID='" + xl.ParentGT + "'");
                gtlis.Insert(0, gtformer);
                //计算页码
                int pagecount = 1, jmax = 15, m = 0, j = 0;
                pagecount = gtlis.Count / 15 + 1;
                int ihang = 8, jlie = 2;
                int i = 0;
                //复制空模板
                for (m = 1; m < pagecount; m++) {
                    ex.CopySheet(1, m);
                    ex.ReNameWorkSheet(m + 1, "Sheet" + (m + 1));
                }
                string[] strname = new string[3];
                strname[0] = "";
                strname[1] = "";
                strname[2] = "";

                if (xl.LineType == "1") {
                    strname[0] = xl.LineName.Split('线')[0] + "线";
                    strname[1] = xl.LineName.Replace(strname[0], "");


                } else
                    if (xl.LineType == "2") {
                        sd_xl xltemp = MainHelper.PlatformSqlMap.GetOne<sd_xl>(" where LineID='" + xl.ParentID + "'");
                        if (xltemp != null)
                            strname[0] = xltemp.LineName;
                        strname[1] = xl.LineName.Replace(xltemp.LineName,"");
                    } else if (xl.LineType == "3") {
                        strname[2] = xl.LineName;
                        sd_xl xltemp = MainHelper.PlatformSqlMap.GetOne<sd_xl>(" where LineID='" + xl.ParentID + "'");
                        if (xltemp != null) {
                            strname[1] = xltemp.LineName;
                            xltemp = MainHelper.PlatformSqlMap.GetOne<sd_xl>(" where LineID='" + xltemp.ParentID + "'");
                            if (xltemp != null) strname[0] = xltemp.LineName;
                        }
                        strname[2].Replace(strname[1], "");
                        strname[1].Replace(strname[0], "");
                    }
                //填写公共项
                for (m = 1; m <= pagecount; m++) {
                    ex.ActiveSheet("Sheet" + m);
                    if(!string.IsNullOrEmpty(strname[0]))
                    ex.SetCellValue(strname[0], 3, 3);
                    if (!string.IsNullOrEmpty(strname[1]))
                    ex.SetCellValue(strname[1], 3, 5);
                    if (!string.IsNullOrEmpty(strname[2]))
                    ex.SetCellValue(strname[2], 3, 11);
                    ex.SetCellValue(xl.LineVol.ToString(), 3, 20);

                }
                ihang = 8;
                jlie = 3;
                int hdRowCount = 1;
                int jyzRowCount = 1;
                int dxRowCount = 1;
                
                int lxRowCount = 1;
                int jstart = 3;
                double dc = 0;
                string strfx = "";
                Excel.Range range;
                for (i = 1; i < gtlis.Count; i++) {
                    if ((i + 0.0) % (jmax) == 1) {

                        jlie = 3;
                        ihang = 8;
                        hdRowCount = 1;
                        jyzRowCount = 1;
                        dxRowCount = 1;
                        
                        lxRowCount = 1;

                    }
                    if (Math.Ceiling((i + 0.0) / (jmax)) > 1) {
                        ex.ActiveSheet("Sheet" + Math.Ceiling((i + 0.0) / (jmax)));
                        xx = wb.Application.Sheets["Sheet" + Math.Ceiling((i + 0.0) / (jmax))] as Microsoft.Office.Interop.Excel.Worksheet;


                    } else {
                        ex.ActiveSheet("Sheet1");
                        xx = wb.Application.Sheets["Sheet1"] as Microsoft.Office.Interop.Excel.Worksheet;
                    }

                    //ex.SetCellValue(i.ToString(), ihang, jlie);

                    ////杆塔数
                    sd_gt gtobj = gtlis[i];
                    
                    //绝缘子
                    //string strSQL = "select distinct sbModle from sd_gtsb Where  gtID='" + gtobj.gtID + "' ";
                    //if (xl.LineVol != "" && Convert.ToDouble(xl.LineVol) >= 10) {
                    //    strSQL += "  and (sbName like '高压%立瓶%' or sbName like '高压%悬垂%' or sbName like '高压%茶台%' )";
                    //} else
                    //    if (xl.LineVol != "" && 0.4 >= Convert.ToDouble(xl.LineVol)) {
                    //        strSQL += "  and (sbName like '低压%立瓶%'  or sbName like '低压%茶台%' )";
                    //    }
                    string strSQL = "select distinct sbModle from sd_gtsb Where  gtID='" + gtobj.gtID + "' ";
                    if (xl.LineVol != "" && Convert.ToDouble(xl.LineVol) >= 10)
                    {
                        strSQL += "  and (sbName like '%绝缘子%' or sbName like '高压%立瓶%' or sbName like '高压%悬垂%' or sbName like '高压%茶台%' )";
                    }
                    else
                        if (xl.LineVol != "" && 0.4 >= Convert.ToDouble(xl.LineVol))
                        {
                            strSQL += "  and (sbName like '低压%立瓶%' or sbName like  '%绝缘子%'  or sbName like '低压%茶台%' )";
                        }
                    IList jyuzlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", strSQL);

                    //导线型号
                    IList dxlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct sbModle from sd_gtsb  Where sbName like '%导线%' and gtID='" + gtobj.gtID + "'");
                    //导线排列方式
                    IList dxpllist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct C1 from sd_gtsb  Where sbName like '%导线%' and gtID='" + gtobj.gtID + "'");

                    //耐张规格
                    IList hdobj = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from sd_gtsb Where sbName like '%耐张%' and gtID='" + gtobj.gtID + "'");

                    //拉线规格
                    //IList lxlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from sd_gtsb  Where sbName like '%拉线%' and gtID='" + gtobj.gtID + "'");
                    IList lxlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneInt", " select sum(sbnumber) from sd_gtsb where sbName like '%拉线%' and gtID='" + gtobj.gtID + "'");
                   
                    

                    ihang = 8;
                    ////杆号
                    ex.SetCellValue((i).ToString(), ihang, jlie);
                    ihang++;

                    //转角方向
                    if (gtobj.gtModle.IndexOf("转角") > -1) {
                        if (i != 1 && i < gtlis.Count - 1) {


                            decimal[,] a1 = new decimal[1, 2];
                            decimal[,] a2 = new decimal[1, 2];
                            a1[0, 0] = gtlis[i].gtLat - gtlis[i - 1].gtLat;
                            a1[0, 1] = gtlis[i].gtLon - gtlis[i - 1].gtLon;

                            a2[0, 0] = gtlis[i + 1].gtLat - gtlis[i].gtLat;
                            a2[0, 1] = gtlis[i + 1].gtLon - gtlis[i].gtLon;
                            decimal di = a1[0, 0] * a2[0, 0] + a1[0, 1] * a2[0, 1];
                            double dl = Math.Sqrt(Convert.ToDouble(a1[0, 0] * a1[0, 0] + a1[0, 1] * a1[0, 1]) * Math.Sqrt(Convert.ToDouble(
                                a2[0, 0] * a2[0, 0] + a2[0, 1] * a2[0, 1])));
                            dc = Math.Round(180 * Math.Acos(Convert.ToDouble(di) / Convert.ToDouble(dl)) / 3.1415926, 0);
                            if (gtlis[i].gtLon > gtlis[i - 1].gtLon) {
                                strfx = "右转";
                            } else {
                                strfx = "左转";
                            }
                            if (dc.ToString() != "NaN" && dc.ToString() != "非数字")
                                ex.SetCellValue(strfx + dc + "度", ihang, jlie);
                            else {

                            }
                        }

                    }
                    ihang++;

                    //杆高(m)
                    if (gtobj != null) {

                        ex.SetCellValue(gtobj.gtHeight.ToString(), ihang, jlie);

                    }
                    ihang++;

                    //电杆种类/杆型
                    if (gtobj != null) {
                        string strtype = "", strzj = "";
                        if (gtobj.gtType.IndexOf("混凝土拔梢杆") > -1) {
                            strtype = "砼";
                        }
                        if (gtobj.gtModle.IndexOf("直线杆") > -1) {
                            strzj = "直";
                        } else if (gtobj.gtModle.IndexOf("分支杆") > -1) {
                            strzj = "分";
                        } else if (gtobj.gtModle.IndexOf("转角杆") > -1) {
                            strzj = "转";
                        } else if (gtobj.gtModle.IndexOf("耐张杆") > -1) {
                            strzj = "耐";
                        } else if (gtobj.gtModle.IndexOf("终端杆") > -1) {
                            strzj = "终";
                        }
                       
                        if (strtype != "" && strzj != "") {
                            ex.SetCellValue(strtype + "/" + strzj, ihang, jlie);
                        } else {
                            ex.SetCellValue(gtobj.gtType + "/" + gtobj.gtModle, ihang, jlie);
                        }
                    }
                    ihang++;
                    //导线排列方式

                    //if (hdobj.Count>0 && hdobj[0].ToString().Contains("三角")) {

                    //    ex.SetCellValue("三角排列", ihang, jlie);
                    //} else {
                    //    ex.SetCellValue("水平排列", ihang, jlie);
                    //}
                    ex.SetCellValue(xl.c1, ihang, jlie);
                   
                    ihang++;
                    //导线型号规格(mm2)
                    if (dxlist != null && dxlist.Count > 0) {
                        if (dxlist.Count > dxRowCount) {
                            for (j = dxRowCount; j < dxlist.Count; j++) {
                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + dxRowCount, "A"], xx.Cells[ihang + dxRowCount, "A"]);
                                range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing);

                            }
                            for (int jtem = 1; jtem < dxlist.Count; jtem++) {
                                for (int item = 0; item < 29; item += 2) {
                                    range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + 1 + item]);
                                    range.Merge(Type.Missing);
                                }
                            }
                            dxRowCount = dxlist.Count;
                            range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + dxRowCount - 1, 1]);
                            range.Merge(Type.Missing);
                        }
                        if (dxlist.Count > 0) {

                            for (j = 0; j < dxlist.Count; j++)
                                ex.SetCellValue(dxlist[j].ToString(), ihang + j, jlie);
                        }

                    } else {
                        ex.SetCellValue(strLinexh, ihang, jlie);
                    }

                    ihang += dxRowCount;
                    if (i == 15) {
                        int nn = 0;
                    }
                    //档        距(m)
                    if (gtobj != null && gtobj.gtSpan>0) {
                        if (jlie > 3)
                            ex.SetCellValue(gtobj.gtSpan.ToString(), ihang, jlie - 1);
                        else
                            ex.SetCellValue(gtobj.gtSpan.ToString(), ihang, jlie);
                    }
                    ihang++;

                    //耐张段长度
                    

                    ihang += hdRowCount;

                    //累计长度


                    if (((i + 0.0) % (jmax) == 0 && i > 1) || i == gtlis.Count - 1) {
                        //累计长度
                        double sum = 0;
                        int ista = i, item = i;
                        for (item = i; item > 0; item--) {
                            sd_gt gttemp = gtlis[item];
                            if (gttemp != null) {
                                sum += Convert.ToDouble(gttemp.gtSpan);
                            }
                            if (i < gtlis.Count - 1) {
                                if (item % jmax == 1 && ista != item) {
                                    break;
                                }
                            } else {
                                if (item % jmax == 1) {
                                    break;
                                }
                            }
                        }
                        sum = 0;
                        for (int m1 = 0; m1 < gtlis.Count;m1++ )
                        {
                            sd_gt gttemp = gtlis[m1];
                            if (gttemp != null)
                            {
                                sum += Convert.ToDouble(gttemp.gtSpan);
                            }
                        }
                        ex.SetCellValue(sum.ToString(), ihang, jstart);

                        float gwidth = 13.50F, gheifht = 13.50F;
                        //float gwidth = 10F, gheifht = 10F;
                        Microsoft.Office.Interop.Excel.Shape activShape, oldShape = null, kywShape = null;
                        int icolor = (int)(((uint)Color.White.B << 16) | (ushort)(((ushort)Color.White.G << 8) | Color.White.R));
                        range = (Excel.Range)xx.get_Range(xx.Cells[6, 1], xx.Cells[6, 1]);
                        fxstart = (float)Convert.ToDouble(range.Cells.Width);
                        range = (Excel.Range)xx.get_Range(xx.Cells[6, 2], xx.Cells[6, 2]);
                        fxstart += (float)Convert.ToDouble(range.Cells.Width);
                        range = (Excel.Range)xx.get_Range(xx.Cells[1, 1], xx.Cells[5, 1]);
                        fystart = (float)Convert.ToDouble(range.Cells.Height);
                        range = (Excel.Range)xx.get_Range(xx.Cells[6, 1], xx.Cells[6, 1]);
                        fystart = fystart + (float)(Convert.ToDouble(range.Cells.Height) / 2);
                        activShape = null;
                        for (int itemp = 0; itemp <= ista - item; itemp++) {

                            range = (Excel.Range)xx.get_Range(xx.Cells[6, itemp * 2 + jstart], xx.Cells[6, itemp * 2 + jstart + 1]);
                            float width = (float)Convert.ToDouble(range.Cells.Width);

                            sd_xl xl2 = Client.ClientHelper.PlatformSqlMap.GetOne<sd_xl>("where ParentGT='" + gtlis[item + itemp].gtID + "'");
                            if (xl2 == null) {
                                if (gtlis[item + itemp].gtModle.IndexOf("转角") == -1) {
                                    activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart + width / 2, fystart, gwidth, gheifht);
                                } else {
                                    PJ_tbsj tb2 = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '直角'");
                                    if (tb2 != null) {

                                        string tempPath = Path.GetTempPath();
                                        string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb2.S1;
                                        FileStream fs;
                                        fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write);
                                        BinaryWriter bw = new BinaryWriter(fs);
                                        bw.Write(tb2.picImage);
                                        bw.Flush();
                                        bw.Close();
                                        fs.Close();
                                        Image im = Bitmap.FromFile(tempfile);
                                        Bitmap bt = new Bitmap(im);
                                        decimal[,] a1 = new decimal[1, 2];
                                        decimal[,] a2 = new decimal[1, 2];
                                        if (item + itemp < gtlis.Count) {
                                            a1[0, 0] = gtlis[item + itemp].gtLat - gtlis[item + itemp - 1].gtLat;
                                            a1[0, 1] = gtlis[item + itemp].gtLon - gtlis[item + itemp - 1].gtLon;

                                            a2[0, 0] = gtlis[item + itemp + 1].gtLat - gtlis[item + itemp].gtLat;
                                            a2[0, 1] = gtlis[item + itemp + 1].gtLon - gtlis[item + itemp].gtLon;
                                        }
                                        decimal di = a1[0, 0] * a2[0, 0] + a1[0, 1] * a2[0, 1];
                                        double dl = Math.Sqrt(Convert.ToDouble(a1[0, 0] * a1[0, 0] + a1[0, 1] * a1[0, 1]) * Math.Sqrt(Convert.ToDouble(
                                            a2[0, 0] * a2[0, 0] + a2[0, 1] * a2[0, 1])));
                                        dc = Math.Round(180 * Math.Acos(Convert.ToDouble(di) / Convert.ToDouble(dl)) / 3.1415926, 0);
                                        if (gtlis[item + itemp].gtLon > gtlis[item + itemp - 1].gtLon) {
                                            strfx = "右转";
                                        } else {
                                            strfx = "左转";
                                        }
                                        int btw = (int)(bt.Width / 1.33f);
                                        int bth = (int)(bt.Height / 1.33f);
                                        if (btw < width / 2) {
                                            
                                            activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 2 - btw / 2, fystart + gheifht / 2 - bth / 2, btw, bth);
                                            if (strfx == "左转") {
                                                if (dc.ToString() != "NaN" && dc.ToString() != "非数字")
                                                    activShape.Rotation = (float)(90 - Convert.ToDouble(dc));
                                            } else {
                                                if (dc.ToString() != "NaN" && dc.ToString() != "非数字")
                                                    activShape.Rotation = (float)(90 + Convert.ToDouble(dc));
                                            }

                                        } else {
                                            activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 5, fystart + gheifht / 2 - bt.Height / 2,bt.Width, bt.Height);
                                            if (strfx == "左转") {
                                                if (dc.ToString() != "NaN" && dc.ToString() != "非数字")
                                                    activShape.Rotation = (float)(90 - Convert.ToDouble(dc));
                                            } else {
                                                if (dc.ToString() != "NaN" && dc.ToString() != "非数字")
                                                    activShape.Rotation = (float)(90 + Convert.ToDouble(dc));
                                            }

                                        }
                                    }
                                }
                            } else {
                                ex.SetCellValue(xl2.LineName, 5, itemp * 2 + 4);//分支线路
                                PJ_tbsj tb2 = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '分支'");
                                if (tb2 != null) {

                                    string tempPath = Path.GetTempPath();
                                    string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb2.S1;
                                    FileStream fs;
                                    fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write);
                                    BinaryWriter bw = new BinaryWriter(fs);
                                    bw.Write(tb2.picImage);
                                    bw.Flush();
                                    bw.Close();
                                    fs.Close();
                                    Image im = Bitmap.FromFile(tempfile);
                                    Bitmap bt = new Bitmap(im);
                                    int btw = (int)(bt.Width / 1.33f);
                                    int bth = (int)(bt.Height / 1.33f);
                                    if (btw < width / 2) {
                                        activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 2 - btw / 2, fystart + gheifht / 2 - bth / 2, btw, bth);
                                    } else {
                                        activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 5, fystart + gheifht / 2 - bth / 2, btw, bth);
                                    }

                                } else {
                                    activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart + width / 2, fystart, gwidth, gheifht);
                                }


                            }
                            //activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart, fystart, gwidth, gheifht);
                            activShape.Fill.ForeColor.RGB = icolor;
                            if (itemp > 0) { 
                                //IList<sdjl_05jcky> kyxli = MainHelper.PlatformSqlMap.GetList<sdjl_05jcky>(" where gtID='" + gtlis[item + itemp].gtID + "'");
                                IList<PJ_05jcky> kyxli = MainHelper.PlatformSqlMap.GetList<PJ_05jcky>(" where gtID='" + gtlis[item + itemp].gtID + "'");
                               
                                if (kyxli.Count == 0) {
                                   
                                    {
                                        xx.Shapes.AddLine(
                                              oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2,
                                              activShape.Left, activShape.Top + activShape.Height / 2);
                                    }
                                } else {
                                    PJ_tbsj tb = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '" + kyxli[0].kymc + "'");
                                    if (tb != null) {
                                        string tempPath = Path.GetTempPath();
                                        string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb.S1;
                                        FileStream fs;
                                        fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write);
                                        BinaryWriter bw = new BinaryWriter(fs);
                                        bw.Write(tb.picImage);
                                        bw.Flush();
                                        bw.Close();
                                        fs.Close();
                                        Image im = Bitmap.FromFile(tempfile);
                                        Bitmap bt = new Bitmap(im);
                                        int btw = (int)(bt.Width / 1.33f);
                                        int bth = (int)(bt.Height / 1.33f);
                                        if (btw < width / 2) {
                                            kywShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, oldShape.Left + oldShape.Width + width / 2 - btw / 2, oldShape.Top + oldShape.Height / 2 - bth / 2, btw, bth);
                                          
                                            xx.Shapes.AddLine(
                                          oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2,
                                          kywShape.Left, oldShape.Top + oldShape.Height / 2);

                                            xx.Shapes.AddLine(
                                          kywShape.Left + (float)(kywShape.Width - 2), kywShape.Top + kywShape.Height / 2,
                                          activShape.Left + 2, kywShape.Top + kywShape.Height / 2);
                                        } else {
                                          

                                            xx.Shapes.AddLine(
                                           oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2,
                                           kywShape.Left, oldShape.Top + oldShape.Height / 2);

                                            xx.Shapes.AddLine(
                                          kywShape.Left + (float)(kywShape.Width - 1), kywShape.Top + kywShape.Height / 2,
                                          activShape.Left + 1, kywShape.Top + kywShape.Height / 2);
                                        }
                                    }
                                }
                            }
                            //fxstart += gtwidth[itemp];
                            fxstart += width;
                            oldShape = activShape;
                        }
                    }
                    ihang++;

                  
                    //拉线规格/条数
                    if (lxlist != null && lxlist.Count > 0) {

                        //if (lxlist.Count > lxRowCount) {
                        //    for (j = lxRowCount; j < lxlist.Count; j++) {
                        //        range = (Excel.Range)xx.get_Range(xx.Cells[ihang + lxRowCount, "A"], xx.Cells[ihang + lxRowCount, "A"]);
                        //        range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing);
                                
                        //    }
                        //    for (int jtem = lxRowCount; jtem < lxlist.Count; jtem++) {
                        //        for (int item = 0; item < 29; item += 2) {
                        //            range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + item + 1]);
                        //            range.Merge(Type.Missing);
                        //        }
                        //    }
                        //    lxRowCount = lxlist.Count;
                        //    range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + lxRowCount - 1, 1]);
                        //    range.Merge(Type.Missing);
                        //}
                        //for (j = 0; j < lxlist.Count; j++) {
                        //    int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select   sum(sbNumber) from sd_gtsb where sbModle = '" + lxlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"));
                        //    //int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<sd_gtsb>(" Where sbModle = '" + lxlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'");
                        //    ex.SetCellValue(lxlist[j].ToString()/* + "/" + icount*/, ihang + j, jlie);

                        //}
                        if (lxlist[0] != null)
                        {
                            ex.SetCellValue(lxlist[0].ToString(), ihang, jlie);
                        }
                    }
                    ihang += lxRowCount;

                    //绝缘子型号/数量
                    if (jyuzlist != null) {

                        if (jyuzlist.Count > jyzRowCount) {
                            for (j = jyzRowCount + 1; j < jyuzlist.Count; j = j+2) {

                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jyzRowCount, "A"], xx.Cells[ihang + jyzRowCount, "A"]);
                                range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing);

                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j, 2], xx.Cells[ihang + j - 1, 2]);
                                range.Merge(Type.Missing);
                            }
                            jyzRowCount = jyuzlist.Count/2 + jyuzlist.Count%2 == 0?0:1;
                            range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + jyzRowCount - 1, 1]);
                            range.Merge(Type.Missing);
                        }
                        for (j = 0; j < jyuzlist.Count; j++) {
                            int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select   sum(sbNumber) from sd_gtsb where sbModle = '" + jyuzlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"));
                            //int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<sd_gtsb>(" Where sbModle = '" + jyuzlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'");
                            ex.SetCellValue(jyuzlist[j].ToString() /*+ "/" + icount*/, ihang + j/2, jlie + j%2);
                            ex.SetCellValue(icount.ToString(), ihang + j / 2 + 1, jlie + j % 2);

                        }
                    }
                    ihang += jyzRowCount*2 ;
                    jlie += 2;
                }
                
                foreach (int key in Dic.Keys)
                {
                    int page = 1;
                    int page1 = 1;
                    NZLength nzlength = Dic[key];

                    int startcolumn = (nzlength.Start + 1) * 2 - 1;
                    if (startcolumn % 32 == 0)
                    {
                        page = startcolumn / 32;
                    }
                    else
                    {
                        page = startcolumn / 32 + 1;
                    }

                    ex.ActiveSheet(page);
                    
                    int endcolumn = (nzlength.End + 1) * 2 - 1;
                    if (nzlength.End % 32 == 0)
                    {
                        page1 = endcolumn / 32;
                    }
                    else
                    {
                        page1 = endcolumn / 32 + 1;
                    }
                    if (page == page1)
                    {
                        ex.ActiveSheet(page);
                        ex.UnitCells(15, startcolumn % 32, 15, endcolumn % 32);
                        ex.SetCellValue(Math.Round(nzlength.Sum/1000,3).ToString(), 15, startcolumn % 32);
                    }
                    else
                    {
                        ex.ActiveSheet(page);
                        ex.UnitCells(15, startcolumn % 32, 15, 31);
                        ex.SetCellValue(nzlength.Start + "到" + nzlength.End + "杆塔:" + Math.Round(nzlength.Sum/1000,3), 15, startcolumn % 32);
                        for (int tmp = 1; tmp <= page1 - page; tmp++)
                        {
                            ex.ActiveSheet(page + tmp);
                            if (tmp < page1 - page)
                            {
                                ex.UnitCells(15, 3,15, 31);
                                
                            }
                            ex.UnitCells(15, 3, 15, (endcolumn+2) % 32);
                            ex.SetCellValue(nzlength.Start + "到" + nzlength.End + "杆塔:" + Math.Round(nzlength.Sum/1000,3), 15, 3);
                        }
                    }


                }
                ex.ActiveSheet(1);

            } catch (Exception exmess) {
                MsgBox.ShowTipMessageBox(exmess.Message.ToString());
            }
            dsoFramerWordControl1.FileSave();
            pj17.BigData = dsoFramerWordControl1.FileDataGzip;
            dsoFramerWordControl1.FileClose();
            dsoFramerWordControl1.Dispose();
            //#endregion
            //System.Diagnostics.Process.Start(outfname);
            return 1;
        }
Esempio n. 10
0
        //public static int ExportToExcel(string title, string dw,PJ_17 pj17)
        //{
        //    string fname = Application.StartupPath + "\\00记录模板\\17线路条图.xls";
        //    string outfname = Application.StartupPath + "\\17线路条图.xls";
        //    float fxstart = 0,fystart = 0, fwidth = 0,fheight=0;
        //    FpSpread fps = new FpSpread();
        //    FarPoint.Win.Spread.Model.CellRange cr = new FarPoint.Win.Spread.Model.CellRange(2, 2, 12, 12);
        //    FarPoint.Win.LineBorder b = new FarPoint.Win.LineBorder(Color.Black, 1);
        //    FarPoint.Win.LineBorder b2 = new FarPoint.Win.LineBorder(Color.Black, 2);
        //    fps.OpenExcel(fname);
            
        //    SheetView sv = fps.Sheets[0];

        //    PS_xl xl = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineCode='" + pj17.LineCode + "'");
        //    if (xl == null)
        //    {
        //        MsgBox.ShowWarningMessageBox("数据出错,没找到线路");
        //        return -1;
        //    }
        //    int ColumnCount = sv.NonEmptyColumnCount;
        //    int RowCount = sv.NonEmptyRowCount;
        //    int ihang = 0,jlie=0;
        //    int i = 0;
        //    sv.ClearRange(0, 0, RowCount, ColumnCount, false);


        //    //cr = new FarPoint.Win.Spread.Model.CellRange(4, 0, 23, 11);
        //    //sv.SetOutlineBorder(cr, b);


        //    sv.Cells[ihang, jlie].Text = title;
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 22F, System.Drawing.FontStyle.Regular | FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height =40;
        //    sv.Cells[ihang, jlie].ColumnSpan = ColumnCount;

        //    ihang = 1;
        //    sv.Cells[ihang, jlie].Row.Height = 15;
        //    #region 线路名称
        //    ihang = 2;
        //    sv.Cells[ihang, jlie].Text = "线路名称:";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Right;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 1;
        //    sv.Cells[ihang, jlie].Row.Height = 50;

            
            
        //    string str ="";
           
          
        //    string[] strname=new  string[3];
        //    strname[0] = "";
        //    strname[1] = "";
        //    strname[2] = "";
        //    //if (xl.LineName.IndexOf("线") > 0)
        //    //{
        //    //    strname[0] = xl.LineName.Split('线')[0];
        //    //    strname[1] = xl.LineName.Replace(strname[0]+"线","");
                
               
        //    //}
        //    //else
        //    //    strname[1] = xl.LineName;
        //    //if (strname[1].IndexOf("支") > 0)
        //    //{
        //    //    str = strname[1];
        //    //    strname[1] = strname[1].Split('支')[0];
        //    //    strname[2] = str.Replace(strname[1] + "支", "");

        //    //}
        //    //else
        //    //{

        //    //    strname[2] = strname[1];
        //    //    strname[1] = "";
        //    //}
        //    //if (strname[2].IndexOf("分") < 0)
        //    //{
        //    //    if (strname[1] != "")
                
        //    //        strname[1] = strname[1] + "支" + strname[2];
                
        //    //    else
        //    //        strname[0] = strname[0] + "线" + strname[2];
        //    //    strname[2] = "";
        //    //}
        //    //else
        //    //{
        //    //    strname[2] = strname[2].Split('分')[0];

        //    //}
        //    if (xl.LineName.IndexOf("线") > 0)
        //    {
        //        strname[0] = xl.LineName.Split('线')[0];
        //        strname[1] = xl.LineName.Replace(strname[0] + "线", "");


        //    }
        //    else
        //        if (xl.LineName.IndexOf("支") > 0)
        //    {
        //        PS_xl xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineCode='" + xl.ParentID + "'");
        //        strname[0]=xltemp.LineName;
        //        strname[1] = xl.LineName;
        //    }
        //        else if (xl.LineName.IndexOf("分") > 0)
        //    {
        //        PS_xl xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineCode='" + xl.ParentID + "'");
        //        if (xltemp != null)
        //        {
        //            strname[1] = xltemp.LineName;
        //            xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineCode='" + xltemp.ParentID + "'");
        //            if (xltemp != null) strname[0] = xltemp.LineName;
        //        }
        //    }
        //    //if (strname[2].IndexOf("分") < 0)
        //    //{
        //    //    if (strname[1] != "")

        //    //        strname[1] = strname[1] + "支" + strname[2];

        //    //    else
        //    //        strname[0] = strname[0] + "线" + strname[2];
        //    //    strname[2] = "";
        //    //}
        //    //else
        //    //{
        //    //    strname[2] = strname[2].Split('分')[0];

        //    //}
        //    jlie = 1;
        //    sv.Cells[ihang, jlie].Text = strname[0];
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    //sv.Cells[ihang, jlie].ColumnSpan = 3;

        //    jlie ++;
        //    sv.Cells[ihang, jlie].Text = "线";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Column.Width = 60f;

            
        //    jlie++;
        //    sv.Cells[ihang, jlie].Text = strname[1];
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    //sv.Cells[ihang, jlie].ColumnSpan = 3;

        //    jlie++;
        //    sv.Cells[ihang, jlie].Text = "支";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Column.Width = 30f;

        //    jlie++;
        //    sv.Cells[ihang, jlie].Text = strname[2];
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    //sv.Cells[ihang, jlie].ColumnSpan = 3;

        //    jlie++;
        //    sv.Cells[ihang, jlie].Text = "分";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Column.Width = 30f;

        //    jlie ++;
        //    sv.Cells[ihang, jlie].Text = "电压:";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Right;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    //sv.Cells[ihang, jlie].ColumnSpan = 3;
        //    sv.Cells[ihang, jlie].Column.Width = 30f;

        //    jlie++;
        //    sv.Cells[ihang, jlie].Text = xl.LineVol;
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Right;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Column.Width = 30f;

        //    jlie ++;
        //    sv.Cells[ihang, jlie].Text = "kV";
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Right;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Column.Width = 30f;
        //    #endregion

        //    #region 表格外框
        //    ihang =4;
        //    jlie = 0;
        //    sv.Cells[ihang, jlie].Text = "平";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    sv.Cells[ihang, jlie].Row.Height = 80;
        //    fheight += sv.Cells[ihang, jlie].Row.Height;
        //    //fxstart += sv.Cells[ihang, jlie].Column.Width; 

        //    jlie = 2;
        //    sv.Cells[ihang, jlie].Text = "A 相";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;

        //    ihang++;
        //    jlie = 0;
        //    sv.Cells[ihang, jlie].Text = "面";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    sv.Cells[ihang, jlie].Row.Height = 80;
        //    fheight += sv.Cells[ihang, jlie].Row.Height;
            

        //    jlie = 2;
        //    sv.Cells[ihang, jlie].Text = "B 相";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;

        //    ihang++;
        //    jlie = 0;
        //    sv.Cells[ihang, jlie].Text = "图";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    sv.Cells[ihang, jlie].Row.Height = 80;
        //    fheight += sv.Cells[ihang, jlie].Row.Height;
           

        //    jlie = 2;
        //    sv.Cells[ihang, jlie].Text = "C 相";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Left;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(4, 0, 3, 2);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    jlie =0;
        //    sv.Cells[ihang, jlie].Text = "杆号";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2);
        //    sv.SetOutlineBorder(cr, b);


        //    ihang++;

        //    sv.Cells[ihang, jlie].Text = "转角方向";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "杆高(m)";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2);
        //    sv.SetOutlineBorder(cr, b);
           

        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "电杆种类及杆型";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "导线排列方式";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "导线规格";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "档距(m)";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "累计长度(m)";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "横担规格(mm)";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "拉线规格";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].ColumnSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, 0, 1, 2);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    jlie = 0;
        //    sv.Cells[ihang, jlie].Text = "绝缘子";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40; 
        //    sv.Cells[ihang, jlie].RowSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 2, 1);
        //    sv.SetOutlineBorder(cr, b);

        //    jlie = 1;
        //    sv.Cells[ihang, jlie].Text = "规格";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1);
        //    sv.SetOutlineBorder(cr, b);


        //    ihang++;
        //    jlie =1;
        //    sv.Cells[ihang, jlie].Text = "数量";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1,1);
        //    sv.SetOutlineBorder(cr, b);


        //    ihang++;
        //    jlie = 0;
        //    sv.Cells[ihang, jlie].Text = "变台";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].RowSpan = 4;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 4, 1);
        //    sv.SetOutlineBorder(cr, b);

        //    jlie = 1;
        //    sv.Cells[ihang, jlie].Text = "型式";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1);
        //    sv.SetOutlineBorder(cr, b);


        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "配变型号";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1);
        //    sv.SetOutlineBorder(cr, b);


        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "台数";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1);
        //    sv.SetOutlineBorder(cr, b);


        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "容量";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    jlie = 0;
        //    sv.Cells[ihang, jlie].Text = "避雷器";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].RowSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 2,1);
        //    sv.SetOutlineBorder(cr, b);

        //    jlie = 1;
        //    sv.Cells[ihang, jlie].Text = "规格";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1);
        //    sv.SetOutlineBorder(cr, b);


        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "数量";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1);
        //    sv.SetOutlineBorder(cr, b);

        //    ihang++;
        //    jlie = 0;
        //    sv.Cells[ihang, jlie].Text = "开关";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].RowSpan = 2;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 2, 1);
        //    sv.SetOutlineBorder(cr, b);
            

        //    jlie = 1;
        //    sv.Cells[ihang, jlie].Text = "规格";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1);
        //    sv.SetOutlineBorder(cr, b);


        //    ihang++;
        //    sv.Cells[ihang, jlie].Text = "数量";
        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[ihang, jlie].Row.Height = 40;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, 1);
        //    sv.SetOutlineBorder(cr, b);
        //    #endregion 
        //    #region 填充数据
        //    int istart = 1, iend = 1;
        //    if (xl.LineGtend!="")
        //        istart =Convert.ToInt32(xl.LineGtbegin);
        //    else
        //        istart = 0;
        //    if (xl.LineGtbegin  != "")
        //        iend = Convert.ToInt32(xl.LineGtend);
        //    else
        //        iend = 0;
            
        //    int liespan = 1,lieindex=0,itemp=0,spantemp=0 ;
        //    ihang = 7;
        //    IList<PS_gt> gtlis = Client.ClientHelper.PlatformSqlMap.GetList<PS_gt>( " Where LineCode='"+xl.LineCode +"'");
        //    iend = gtlis.Count;
        //    int[] gtwidth = new int[iend];
        //    Hashtable hs = new Hashtable();
            
        //    for (i = 1; i <= iend; i++)
        //    {
        //        //杆塔数
        //        PS_gt gtobj = gtlis[i - 1];
        //        //if (gtobj == null) break ;
                
        //        //绝缘子
        //        IList<PS_gtsb> jyuzlist = Client.ClientHelper.PlatformSqlMap.GetList<PS_gtsb>(" Where sbName='绝缘子' and gtID='" + gtobj.gtID + "'");

        //        //变台
        //        IList<PS_gtsb> btlist = Client.ClientHelper.PlatformSqlMap.GetList<PS_gtsb>(" Where sbName='变台' and gtID='" + gtobj.gtID + "'");

        //        //避雷器
        //        IList<PS_gtsb> blqlist = Client.ClientHelper.PlatformSqlMap.GetList<PS_gtsb>(" Where sbName='避雷器' and gtID='" + gtobj.gtID + "'");

        //        //开关
        //        IList<PS_gtsb> kglist = Client.ClientHelper.PlatformSqlMap.GetList<PS_gtsb>(" Where sbName='开关' and gtID='" + gtobj.gtID + "'");

        //        //导线排列方式
        //        PS_gtsb dxobj = Client.ClientHelper.PlatformSqlMap.GetOne<PS_gtsb>(" Where sbName='导线' and gtID='" + gtobj.gtID + "'");

        //        //横担拉线规格
        //        PS_gtsb hdobj = Client.ClientHelper.PlatformSqlMap.GetOne<PS_gtsb>(" Where sbName='横担' and gtID='" + gtobj.gtID + "'");

        //        //拉线规格
        //        PS_gtsb lxobj = Client.ClientHelper.PlatformSqlMap.GetOne<PS_gtsb>(" Where sbName='拉线' and gtID='" + gtobj.gtID + "'");
        //        liespan = 1;
        //        if (jyuzlist.Count > liespan) liespan = jyuzlist.Count;
        //        if (btlist.Count > liespan) liespan = btlist.Count;
        //        if (blqlist.Count > liespan) liespan = blqlist.Count;
        //        if (kglist.Count > liespan) liespan = kglist.Count;

        //        //杆号
        //        ihang = 7;
        //        jlie = lieindex+2;
        //        sv.Cells[ihang, jlie].Text = i.ToString();
        //        sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //        sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //        sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //        sv.Cells[ihang, jlie].ColumnSpan = liespan;
        //        cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan);
        //        sv.SetOutlineBorder(cr, b);

        //        //转角方向
        //        ihang++;
        //        sv.Cells[ihang, jlie].Text = "";
        //        sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //        sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //        sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //        sv.Cells[ihang, jlie].ColumnSpan = liespan;
        //        cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan);
        //        sv.SetOutlineBorder(cr, b);

        //        //杆高(m)
        //        ihang++;
        //        if (gtobj != null)
        //        {
        //            sv.Cells[ihang, jlie].Text = gtobj.gtHeight.ToString();
        //            sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //        }
        //        sv.Cells[ihang, jlie].ColumnSpan = liespan;
        //        cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan);
        //        sv.SetOutlineBorder(cr, b);
                

        //        //电杆种类及杆型
        //        ihang++;
        //        if (gtobj != null)
        //        {
        //            if (gtobj.gtType != "" && gtobj.gtModle != "")
        //                sv.Cells[ihang, jlie].Text = gtobj.gtType + "/" + gtobj.gtModle;
        //            else if (gtobj.gtType == "" && gtobj.gtModle != "")
        //                sv.Cells[ihang, jlie].Text = gtobj.gtModle;
        //            else if (gtobj.gtType != "" && gtobj.gtModle == "")
        //                sv.Cells[ihang, jlie].Text = gtobj.gtType;
        //            if (sv.Cells[ihang, jlie].Text == "混凝土拔梢杆/直线杆")
        //            {
        //                sv.Cells[ihang, jlie].Text = "砼/直线杆";
        //            }
        //            else
        //                if (sv.Cells[ihang, jlie].Text.IndexOf( "混凝土")>-1)
        //                {
        //                    sv.Cells[ihang, jlie].Text = "砼";
        //                }

        //        }
        //        sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //        sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //        sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //        sv.Cells[ihang, jlie].ColumnSpan = liespan;
               
        //        cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan);
        //        sv.SetOutlineBorder(cr, b);

        //        //导线排列方式
        //        ihang++;

        //        if (dxobj != null)
        //        {
        //            sv.Cells[ihang, jlie].Text = dxobj.C1;
        //            sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //        }
        //        sv.Cells[ihang, jlie].ColumnSpan = liespan;
        //        cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan);
        //        sv.SetOutlineBorder(cr, b);

        //        //导线规格
        //        ihang++; 
        //        if (dxobj != null)
        //        {
        //            sv.Cells[ihang, jlie].Text = dxobj.sbModle;
        //            sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //        }
        //        sv.Cells[ihang, jlie].ColumnSpan = liespan;
        //        cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan);
        //        sv.SetOutlineBorder(cr, b);

        //        //档距(m)
        //        ihang++;
        //        if (gtobj != null)
        //        {
        //            sv.Cells[ihang, jlie].Text = gtobj.gtSpan.ToString();
        //            sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //        }
        //        sv.Cells[ihang, jlie].ColumnSpan = liespan;
        //        cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan);
        //        sv.SetOutlineBorder(cr, b);

        //        //累计长度(m)
        //        ihang++;

        //        //if (xl != null)
        //        //{
        //        //    sv.Cells[ihang, jlie].Text = xl.TotalLength.ToString();
        //        //    sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //        //    sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //        //    sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //        //}
        //        //sv.Cells[ihang, jlie].ColumnSpan = liespan;
        //        //cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan);
        //        //sv.SetOutlineBorder(cr, b);

        //        //横担
        //        ihang++;
        //        if (hdobj != null)
        //        {
        //            sv.Cells[ihang, jlie].Text = hdobj.sbModle;
        //            sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //        }
        //        sv.Cells[ihang, jlie].ColumnSpan = liespan;
        //        cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan);
        //        sv.SetOutlineBorder(cr, b);

        //        //拉线规格
        //        ihang++;
        //        if (lxobj != null)
        //        {
        //            sv.Cells[ihang, jlie].Text = lxobj.sbModle;
        //            sv.Cells[ihang, jlie].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang, jlie].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang, jlie].VerticalAlignment = CellVerticalAlignment.Center;
        //        }
        //        sv.Cells[ihang, jlie].ColumnSpan = liespan;
        //        cr = new FarPoint.Win.Spread.Model.CellRange(ihang, jlie, 1, liespan);
        //        sv.SetOutlineBorder(cr, b);

                
        //        //绝缘子
        //        ihang++;
        //        spantemp = 0;
        //        for (itemp = 0; itemp < jyuzlist.Count; itemp++)
        //        {
        //            sv.Cells[ihang, jlie + itemp].Text = jyuzlist[itemp ].sbModle;
        //            sv.Cells[ihang, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center;

                   

        //            sv.Cells[ihang, jlie + itemp].ColumnSpan = 1;
                   
                    

        //            sv.Cells[ihang + 1, jlie + itemp].Text = jyuzlist[itemp].sbNumber.ToString();
        //            sv.Cells[ihang + 1, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang + 1, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang + 1, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center;
        //            sv.Cells[ihang + 1, jlie + itemp].ColumnSpan = sv.Cells[ihang, jlie + itemp].ColumnSpan;
        //            ////自动行宽30f;
        //            //fps.ActiveSheet.Columns[jlie + itemp].Width = fps.ActiveSheet.Columns[jlie + itemp].GetPreferredWidth();
        //            fps.ActiveSheet.Columns[jlie + itemp].Width = 30f;
        //        }

        //        for (itemp = 0; itemp < sv.Cells[ihang, 0].RowSpan; itemp++)
        //        {
        //            cr = new FarPoint.Win.Spread.Model.CellRange(ihang + itemp, jlie, 1, liespan);
        //            sv.SetOutlineBorder(cr, b);
        //        }
        //        if (!hs.ContainsKey(gtobj.gtID))
        //            hs.Add(gtobj.gtID, 0);
        //        else
        //            hs[gtobj.gtID] = 0;
                
        //        //变台
        //        ihang += sv.Cells[ihang, 0].RowSpan;
        //        for (itemp = 0; itemp < btlist.Count; itemp++)
        //        {
        //            sv.Cells[ihang, jlie + itemp].Text = btlist[itemp].sbType ;
        //            sv.Cells[ihang, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center;
        //            sv.Cells[ihang, jlie + itemp].ColumnSpan = 1;
        //            if (btlist[itemp].sbType == "H台")
        //            {
        //                sv.Cells[4, jlie + itemp].Text = gtobj.gtCode;  
        //                if (!hs.ContainsKey(gtobj.gtID))
        //                    hs.Add(gtobj.gtID, 1);
        //                else
        //                    hs[gtobj.gtID] = 1;
        //            }
                    


        //            sv.Cells[ihang + 1, jlie + itemp].Text = btlist[itemp].sbModle;
        //            sv.Cells[ihang + 1, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang + 1, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang + 1, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center;
        //            sv.Cells[ihang + 1, jlie + itemp].ColumnSpan = sv.Cells[ihang+1, jlie + itemp].ColumnSpan;

        //            sv.Cells[ihang + 2, jlie + itemp].Text = btlist[itemp].sbNumber.ToString () ;
        //            sv.Cells[ihang + 2, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang + 2, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang + 2, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center;
        //            sv.Cells[ihang + 2, jlie + itemp].ColumnSpan = sv.Cells[ihang+2, jlie + itemp].ColumnSpan;

        //            sv.Cells[ihang + 3, jlie + itemp].Text = btlist[itemp].C1 ;
        //            sv.Cells[ihang + 3, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang + 3, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang + 3, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center;
        //            sv.Cells[ihang + 3, jlie + itemp].ColumnSpan = sv.Cells[ihang+3, jlie + itemp].ColumnSpan;
        //            ////自动行宽
        //            //fps.ActiveSheet.Columns[jlie + itemp].Width = fps.ActiveSheet.Columns[jlie + itemp].GetPreferredWidth();
        //            fps.ActiveSheet.Columns[jlie + itemp].Width = 30f;
                   
        //        }
        //        for (itemp = 0; itemp < sv.Cells[ihang, 0].RowSpan; itemp++)
        //        {
                    
        //            cr = new FarPoint.Win.Spread.Model.CellRange(ihang + itemp, jlie, 1, liespan);
        //            sv.SetOutlineBorder(cr, b);
        //        }
                

        //        //避雷器
        //        ihang += sv.Cells[ihang, 0].RowSpan;
        //        for (itemp = 0; itemp < blqlist.Count; itemp++)
        //        {
        //            sv.Cells[ihang, jlie + itemp].Text = blqlist[itemp].sbModle;
        //            sv.Cells[ihang, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center;

        //            sv.Cells[ihang, jlie + itemp].ColumnSpan = 1;

                   


        //            sv.Cells[ihang + 1, jlie + itemp].Text = blqlist[itemp].sbNumber.ToString();
        //            sv.Cells[ihang + 1, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang + 1, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang + 1, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center;
        //            //sv.Cells[ihang + 1, jlie + itemp].Column.Width = 80;
        //            sv.Cells[ihang + 1, jlie + itemp].ColumnSpan = sv.Cells[ihang, jlie + itemp].ColumnSpan;
        //            ////自动行宽
        //            //fps.ActiveSheet.Columns[jlie + itemp].Width = fps.ActiveSheet.Columns[i].GetPreferredWidth();
        //            fps.ActiveSheet.Columns[jlie + itemp].Width = 30f;
        //        }

        //        for (itemp = 0; itemp < sv.Cells[ihang, 0].RowSpan; itemp++)
        //        {
        //            cr = new FarPoint.Win.Spread.Model.CellRange(ihang + itemp, jlie, 1, liespan);
        //            sv.SetOutlineBorder(cr, b);
        //        }

        //        //开关
        //        ihang += sv.Cells[ihang, 0].RowSpan;
        //        for (itemp = 0; itemp < kglist.Count; itemp++)
        //        {
        //            sv.Cells[ihang, jlie + itemp].Text = kglist[itemp].sbModle;
        //            sv.Cells[ihang, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center;

        //            sv.Cells[ihang, jlie + itemp].ColumnSpan = 1;

                    


        //            sv.Cells[ihang + 1, jlie + itemp].Text = kglist[itemp].sbNumber.ToString();
        //            sv.Cells[ihang + 1, jlie + itemp].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //            sv.Cells[ihang + 1, jlie + itemp].HorizontalAlignment = CellHorizontalAlignment.Center;
        //            sv.Cells[ihang + 1, jlie + itemp].VerticalAlignment = CellVerticalAlignment.Center;
        //            //sv.Cells[ihang + 1, jlie + itemp].Column.Width = 80;
        //            sv.Cells[ihang + 1, jlie + itemp].ColumnSpan = sv.Cells[ihang+1, jlie + itemp].ColumnSpan;
        //            ////自动行宽
        //            //fps.ActiveSheet.Columns[jlie + itemp].Width = fps.ActiveSheet.Columns[i].GetPreferredWidth();
        //            fps.ActiveSheet.Columns[jlie + itemp].Width = 30f;
        //        }

        //        for (itemp = 0; itemp < sv.Cells[ihang, 0].RowSpan; itemp++)
        //        {
        //            cr = new FarPoint.Win.Spread.Model.CellRange(ihang + itemp, jlie, 1, liespan);
        //            sv.SetOutlineBorder(cr, b);
        //        }


        //        ////自动行宽
        //        //fps.ActiveSheet.Columns[jlie].Width = fps.ActiveSheet.Columns[jlie].GetPreferredWidth();
        //        fps.ActiveSheet.Columns[jlie + itemp].Width = 30f;
        //        lieindex += liespan;
        //        fwidth += fps.ActiveSheet.Columns[jlie].Width;
        //        //for (itemp = 0; itemp < sv.Cells[8, jlie].ColumnSpan; itemp++)
        //        //    gtwidth[i - 1] += sv.Cells[ihang, jlie + itemp].Column.Width;
        //        gtwidth[i - 1] = liespan;
        //    }

        //    cr = new FarPoint.Win.Spread.Model.CellRange(4, 2, 3, lieindex);
        //    sv.SetOutlineBorder(cr, b);
        //    //累计长度(m)
        //    sv.Cells[14, 2].Text = xl.TotalLength.ToString();
        //    sv.Cells[14, 2].Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        //    sv.Cells[14, 2].HorizontalAlignment = CellHorizontalAlignment.Center;
        //    sv.Cells[14, 2].VerticalAlignment = CellVerticalAlignment.Center;
        //    sv.Cells[14, 2].ColumnSpan = lieindex;
        //    cr = new FarPoint.Win.Spread.Model.CellRange(14, 2, 1, lieindex);
        //    sv.SetOutlineBorder(cr, b);
        //    ihang += sv.Cells[ihang, 0].RowSpan;
        //    fystart = 0;
        //    for (itemp = 0; itemp <=4; itemp++)
        //    {
        //        if(itemp <4)
        //        fystart += sv.Cells[itemp, 0].Row.Height;
        //        else
        //            fystart += sv.Cells[itemp, 0].Row.Height/2;
        //    }

        //    #endregion
        //    ColumnCount = sv.NonEmptyColumnCount;
        //    RowCount = sv.NonEmptyRowCount;
        //    sv.Cells[0, 0].ColumnSpan = ColumnCount;
        //    fps.SaveExcel(outfname);
        //    #region 画图形
        //    DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl();
        //    dsoFramerWordControl1.FileOpen(outfname);
        //     Microsoft.Office.Interop.Excel.Workbook wb;
        //     Microsoft.Office.Interop.Excel.Worksheet xx;
        //     try {
        //         wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook;
        //         xx = wb.Application.Sheets[1] as Microsoft.Office.Interop.Excel.Worksheet;

        //     } catch (Exception err) {
        //         dsoFramerWordControl1.FileClose();
        //         throw new Exception("excel的打开方式不对,有可能装有wps", err);
        //     }
        //    Excel.Range range;
        //    if (lieindex < 1)
        //        range = (Excel.Range)xx.get_Range(xx.Cells[5, 1], xx.Cells[RowCount , ColumnCount]);
        //    else
        //        range = (Excel.Range)xx.get_Range(xx.Cells[5, 1], xx.Cells[RowCount, lieindex + 2]);

        //    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous;
        //    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].Weight = Excel.XlBorderWeight.xlThick;
        //    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight ].LineStyle = Excel.XlLineStyle.xlContinuous;
        //    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight].Weight = Excel.XlBorderWeight.xlThick;
        //    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom ].LineStyle = Excel.XlLineStyle.xlContinuous;
        //    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Excel.XlBorderWeight.xlThick;

        //    float gwidth = 13.50F, gheifht = 15.75F;
        //    Microsoft.Office.Interop.Excel.Shape activShape,oldShape=null;
        //    int icolor = (int)(((uint)Color.White.B << 16) | (ushort)(((ushort)Color.White.G << 8) | Color.White.R));
        //    i =3;

        //    range = (Excel.Range)xx.get_Range(xx.Cells[6, 1], xx.Cells[6,2]);
        //    fxstart = (float)Convert.ToDouble(range.Cells.Width);
        //    for (itemp = 0; itemp < gtlis.Count; itemp++)
        //    {

        //        range = (Excel.Range)xx.get_Range(xx.Cells[8, i], xx.Cells[8, i + gtwidth[itemp] - 1]);
        //        float width = (float)Convert.ToDouble(range.Cells.Width);
        //        if (hs[gtlis[itemp].gtID].ToString() == "1")
        //        {
        //            activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart - gwidth + width / 2, fystart, gwidth, gheifht);
        //            //activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart, fystart, gwidth, gheifht);
        //            activShape.Fill.ForeColor.RGB = icolor;
        //            if (itemp > 0)
        //            {
        //                //Texture Image Recognition Algorithm Based on Steerable Pyramid Transform

        //                xx.Shapes.AddLine(oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, activShape.Left, activShape.Top + activShape.Height / 2);

        //            }
        //            activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, activShape.Left + activShape.Width, fystart, gwidth, gheifht);
        //            activShape.Fill.ForeColor.RGB = icolor;
                    
        //        }
        //        else
        //        {
        //            activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart + width / 2, fystart, gwidth, gheifht);
        //            //activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart, fystart, gwidth, gheifht);
        //            activShape.Fill.ForeColor.RGB = icolor;
        //            if (itemp > 0)
        //            {
        //                //Texture Image Recognition Algorithm Based on Steerable Pyramid Transform

        //                xx.Shapes.AddLine(oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2, activShape.Left, activShape.Top + activShape.Height / 2);

        //            }
        //        }

        //        //fxstart += gtwidth[itemp];
        //        fxstart += width;  
        //        i += gtwidth[itemp];
        //        oldShape = activShape;
        //    }
        //    dsoFramerWordControl1.FileSave();
        //    pj17.BigData = dsoFramerWordControl1.FileDataGzip; 
        //    dsoFramerWordControl1.FileClose(); 
        //    dsoFramerWordControl1.Dispose();
        //    #endregion
        //    //System.Diagnostics.Process.Start(outfname);
        //    return 1;
        //}


        public static int ExportToExcel(string title, string dw, PJ_17 pj17) {
            string fname = Application.StartupPath + "\\00记录模板\\17线路条图2.xls";
            float fxstart = 0, fystart = 0, fwidth = 0, fheight = 0;
            DSOFramerControl dsoFramerWordControl1 = new DSOFramerControl();
            string outfname = Path.GetTempFileName() + ".xls";
            File.Copy(fname, outfname);
            dsoFramerWordControl1.FileOpen(outfname);
            Microsoft.Office.Interop.Excel.Worksheet xx;
            Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            ExcelAccess ex = new ExcelAccess();
            ex.MyWorkBook = wb;
            ex.MyExcel = wb.Application;
            PS_xl xl = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineCode='" + pj17.LineCode + "'");
            try {
                if (xl == null) {
                    MsgBox.ShowWarningMessageBox("数据出错,没找到线路");
                    return -1;
                }
                string strLinexh = xl.WireType;//导线型号
                PS_gt gtformer = null;
                IList<PS_gt> gtlis = Client.ClientHelper.PlatformSqlMap.GetList<PS_gt>(" Where LineCode='" + xl.LineCode + "' order by gtcode");
                gtformer = Client.ClientHelper.PlatformSqlMap.GetOne<PS_gt>(" Where gtID='" + xl.ParentGT + "'");
                gtlis.Insert(0, gtformer);
                //计算页码
                int pagecount = 1, jmax = 15, m = 0, j = 0;
                pagecount = gtlis.Count / 15 + 1;
                int ihang = 8, jlie = 2;
                int i = 0;
                //复制空模板
                for (m = 1; m < pagecount; m++) {
                    ex.CopySheet(1, m);
                    ex.ReNameWorkSheet(m + 1, "Sheet" + (m + 1));
                }
                string[] strname = new string[3];
                strname[0] = "";
                strname[1] = "";
                strname[2] = "";

                if (xl.LineType == "1") {
                    strname[0] = xl.LineName.Split('线')[0] + "线";
                    strname[1] = xl.LineName.Replace(strname[0], "");


                } else
                    if (xl.LineType == "2") {
                        PS_xl xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineID='" + xl.ParentID + "'");
                        if (xltemp != null)
                            strname[0] = xltemp.LineName;
                        strname[1] = xl.LineName.Replace(xltemp.LineName, "");
                    } else if (xl.LineType == "3") {
                        strname[2] = xl.LineName;
                        PS_xl xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineID='" + xl.ParentID + "'");
                        if (xltemp != null) {
                            strname[1] = xltemp.LineName;
                            xltemp = MainHelper.PlatformSqlMap.GetOne<PS_xl>(" where LineID='" + xltemp.ParentID + "'");
                            if (xltemp != null) strname[0] = xltemp.LineName;
                        }
                        strname[2].Replace(strname[1], "");
                        strname[1].Replace(strname[0], "");
                    }
                //填写公共项
                for (m = 1; m <= pagecount; m++) {
                    ex.ActiveSheet("Sheet" + m);
                    ex.SetCellValue(strname[0], 3, 2);
                    ex.SetCellValue(strname[1], 3, 5);
                    ex.SetCellValue(strname[2], 3, 11);
                    ex.SetCellValue(xl.LineVol.ToString(), 3, 20);

                }
                ihang = 8;
                jlie = 3;
                int hdRowCount = 1;
                int jyzRowCount = 1;
                int dxRowCount = 1;
                int btRowCount = 1;
                int blqRowCount = 1;
                int kgRowCount = 1;
                int lxRowCount = 1;
                int jstart = 3;
                double dc = 0;
                string strfx = "";
                Excel.Range range;
                for (i = 1; i < gtlis.Count; i++) {
                    if ((i + 0.0) % (jmax) == 1) {

                        jlie = 3;
                        ihang = 8;
                        hdRowCount = 1;
                        jyzRowCount = 1;
                        dxRowCount = 1;
                        btRowCount = 1;
                        blqRowCount = 1;
                        kgRowCount = 1;
                        lxRowCount = 1;

                    }
                    if (Math.Ceiling((i + 0.0) / (jmax)) > 1) {
                        ex.ActiveSheet("Sheet" + Math.Ceiling((i + 0.0) / (jmax)));
                        xx = wb.Application.Sheets["Sheet" + Math.Ceiling((i + 0.0) / (jmax))] as Microsoft.Office.Interop.Excel.Worksheet;


                    } else {
                        ex.ActiveSheet("Sheet1");
                        xx = wb.Application.Sheets["Sheet1"] as Microsoft.Office.Interop.Excel.Worksheet;
                    }

                    //ex.SetCellValue(i.ToString(), ihang, jlie);

                    ////杆塔数
                    PS_gt gtobj = gtlis[i];
                    //if (gtobj == null)
                    //{
                    //    if ((i + 0.0) % (jmax) == 0&&i>1)
                    //    {
                    //        //累计长度
                    //        double sum = 0;
                    //        for (int item = i; item < i + 15 && item < gtlis.Count; item++)
                    //        {
                    //            PS_gt gttemp = gtlis[item];
                    //            if (gttemp != null)
                    //            {
                    //                sum += Convert.ToDouble(gttemp.gtSpan);
                    //            }
                    //        }
                    //        ex.SetCellValue(sum.ToString(), ihang, 2);
                    //    }
                    //    jlie += 2;
                    //    continue;

                    //}
                    //绝缘子
                    string strSQL = "select distinct sbModle from PS_gtsb Where  gtID='" + gtobj.gtID + "' ";
                    if (xl.LineVol != "" && Convert.ToDouble(xl.LineVol) >= 10) {
                        strSQL += "  and (sbName like '高压%立瓶%' or sbName like '高压%悬垂%' or sbName like '高压%茶台%' )";
                    } else
                        if (xl.LineVol != "" && 0.4 >= Convert.ToDouble(xl.LineVol)) {
                            strSQL += "  and (sbName like '低压%立瓶%'  or sbName like '低压%茶台%' )";
                        }

                    IList jyuzlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", strSQL);

                    //变台
                    //IList btlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from PS_gtsb Where sbName like '%变压器%' and gtID='" + gtobj.gtID + "'");
                    IList btlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct bttype from PS_tq Where   gtID='" + gtobj.gtID + "'");

                    //避雷器
                    IList blqlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from PS_gtsb Where sbName='避雷器' and gtID='" + gtobj.gtID + "'");

                    //开关
                    IList kglist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct kgModle from PS_kg Where gtID='" + gtobj.gtID + "'");

                    //导线型号
                    IList dxlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct sbModle from PS_gtsb  Where sbName like '%导线%' and gtID='" + gtobj.gtID + "'");
                    //导线排列方式
                    IList dxpllist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct C1 from PS_gtsb  Where sbName like '%导线%' and gtID='" + gtobj.gtID + "'");

                    //横担规格
                    IList hdobj = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from PS_gtsb Where sbName like '%横担%' and gtID='" + gtobj.gtID + "'");

                    //拉线规格
                    IList lxlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", " select distinct sbModle from PS_gtsb  Where sbName like '%拉线%' and gtID='" + gtobj.gtID + "'");

                    IList ilisttemp = null;


                    ihang = 8;
                    ////杆号
                    ex.SetCellValue((i).ToString(), ihang, jlie);
                    ihang++;

                    //转角方向
                    if (gtobj.gtModle.IndexOf("转角") > -1) {
                        if (i != 1 && i < gtlis.Count - 1) {


                            decimal[,] a1 = new decimal[1, 2];
                            decimal[,] a2 = new decimal[1, 2];
                            a1[0, 0] = gtlis[i].gtLat - gtlis[i - 1].gtLat;
                            a1[0, 1] = gtlis[i].gtLon - gtlis[i - 1].gtLon;

                            a2[0, 0] = gtlis[i + 1].gtLat - gtlis[i].gtLat;
                            a2[0, 1] = gtlis[i + 1].gtLon - gtlis[i].gtLon;
                            decimal di = a1[0, 0] * a2[0, 0] + a1[0, 1] * a2[0, 1];
                            double dl = Math.Sqrt(Convert.ToDouble(a1[0, 0] * a1[0, 0] + a1[0, 1] * a1[0, 1]) * Math.Sqrt(Convert.ToDouble(
                                a2[0, 0] * a2[0, 0] + a2[0, 1] * a2[0, 1])));
                            dc = Math.Round(180 * Math.Acos(Convert.ToDouble(di) / Convert.ToDouble(dl)) / 3.1415926, 0);
                            if (gtlis[i].gtLon > gtlis[i - 1].gtLon) {
                                strfx = "右转";
                            } else {
                                strfx = "左转";
                            }
                            if (dc.ToString() != "NaN" && dc.ToString() != "非数字")
                                ex.SetCellValue(strfx + dc + "度", ihang, jlie);
                            else {

                            }
                        }

                    }
                    ihang++;

                    //杆高(m)
                    if (gtobj != null) {

                        ex.SetCellValue(gtobj.gtHeight.ToString(), ihang, jlie);

                    }
                    ihang++;

                    //电杆种类/杆型
                    if (gtobj != null) {
                        string strtype = "", strzj = "";
                        if (gtobj.gtType.IndexOf("混凝土拔梢杆") > -1) {
                            strtype = "砼";
                        }
                        if (gtobj.gtModle.IndexOf("直线杆") > -1) {
                            strzj = "直";
                        } else if (gtobj.gtModle.IndexOf("分支杆") > -1) {
                            strzj = "分";
                        } else if (gtobj.gtModle.IndexOf("转角杆") > -1) {
                            strzj = "转";
                        } else if (gtobj.gtModle.IndexOf("耐张杆") > -1) {
                            strzj = "耐";
                        } else if (gtobj.gtModle.IndexOf("终端杆") > -1) {
                            strzj = "终";
                        }

                        if (strtype != "" && strzj != "") {
                            ex.SetCellValue(strtype + "/" + strzj, ihang, jlie);
                        } else {
                            ex.SetCellValue(gtobj.gtType + "/" + gtobj.gtModle, ihang, jlie);
                        }
                    }
                    ihang++;
                    //导线排列方式

                    if (hdobj.Count > 0 && hdobj[0].ToString().Contains("三角")) {

                        ex.SetCellValue("三角排列", ihang, jlie);
                    } else {
                        ex.SetCellValue("水平排列", ihang, jlie);
                    }
                    /*
                    if (((i + 0.0) % (jmax) == 0 && i > 1) || i == gtlis.Count) {
                        //合并同类项
                        string stplrname = "";
                        int ista = i, item = i, jlietemp = jlie;
                        for (item = i; item > 1; item--) {
                            PS_gt gttemp = gtlis[item - 1];
                            PS_gt gttemp2 = gtlis[item - 2];
                            IList dxpllist2 = null;
                            IList dxpllist3 = null;
                            string str1 = "", str2 = "";
                            if (gttemp != null) {
                                dxpllist2 = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr",
                                    "select distinct sbName from PS_gtsb  Where sbName like '%横担%' and gtID='" + gttemp.gtID + "'");
                                if (dxpllist2.Count > 0) str1 = dxpllist2[0].ToString();
                            }
                            if (gttemp2 != null) {
                                dxpllist3 = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr",
                                    "select distinct sbName from PS_gtsb  Where sbName like '%横担%' and gtID='" + gttemp2.gtID + "'");
                                if (dxpllist3.Count > 0) str2 = dxpllist3[0].ToString();
                            }

                            if (gttemp2 == null || str2 == str1) {
                                if (jlietemp > 4) {
                                    range = (Excel.Range)xx.get_Range(xx.Cells[ihang, jlietemp], xx.Cells[ihang, jlietemp - 2]);
                                    range.Merge(Type.Missing);
                                    if ((item % jmax == 2 && ista != item) || jlietemp == 5) {
                                        if (str1 != "" && str1.Contains("三角"))
                                        {                                          
                                            ex.SetCellValue("角排列", ihang, jlietemp - 2);
                                        }
                                        else
                                        {
                                            ex.SetCellValue("水平排列", ihang, jlietemp - 2);
                                        }

                                    }
                                }
                            } else {
                                if (str1 != "" && str1.Contains("三角"))
                                {
                                    ex.SetCellValue("角排列", ihang, jlietemp);
                                }
                                else
                                {
                                    ex.SetCellValue("水平排列", ihang, jlietemp);
                                }                               
                            }
                            jlietemp = jlietemp - 2;
                            if (item % jmax == 2 && ista != item) {
                                break;
                            }

                        }
                    }
                    else
                    {
                        if (gtlis.Count>0)
                        {
                            string stplrname = "";
                            int ista = i, item = i, jlietemp = jlie;
                            for (item = i; item > 1; item--)
                            {
                                PS_gt gttemp = gtlis[item - 1];
                                PS_gt gttemp2 = gtlis[item - 2];
                                IList dxpllist2 = null;
                                IList dxpllist3 = null;
                                string str1 = "", str2 = "";
                                if (gttemp != null)
                                {
                                    dxpllist2 = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr",
                                        "select distinct sbName from PS_gtsb  Where sbName like '%横担%' and gtID='" + gttemp.gtID + "'");
                                    if (dxpllist2.Count > 0) str1 = dxpllist2[0].ToString();
                                }
                                if (gttemp2 != null)
                                {
                                    dxpllist3 = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr",
                                        "select distinct sbName from PS_gtsb  Where sbName like '%横担%' and gtID='" + gttemp2.gtID + "'");
                                    if (dxpllist3.Count > 0) str2 = dxpllist3[0].ToString();
                                }

                                if (gttemp2 == null || str2 == str1)
                                {
                                    if (jlietemp > 4)
                                    {
                                        range = (Excel.Range)xx.get_Range(xx.Cells[ihang, jlietemp], xx.Cells[ihang, jlietemp - 2]);
                                        range.Merge(Type.Missing);
                                        if ((item % jmax == 2 && ista != item) || jlietemp == 5)
                                        {
                                            if (str1 != "" && str1.Contains("三角"))
                                            {
                                                ex.SetCellValue("角排列", ihang, jlietemp - 2);
                                            }
                                            else
                                            {
                                                ex.SetCellValue("水平排列", ihang, jlietemp - 2);
                                            }

                                        }
                                    }
                                }
                                else
                                {
                                    if (str1 != "" && str1.Contains("三角"))
                                    {
                                        ex.SetCellValue("角排列", ihang, jlietemp);
                                    }
                                    else
                                    {
                                        ex.SetCellValue("水平排列", ihang, jlietemp);
                                    }
                                }
                                jlietemp = jlietemp - 2;
                                if (item % jmax == 2 && ista != item)
                                {
                                    break;
                                }

                            }
                        }
                    }
                    */
                    ihang++;
                    //导线型号规格(mm2)
                    if (dxlist != null && dxlist.Count > 0) {
                        if (dxlist.Count > dxRowCount) {
                            for (j = dxRowCount; j < dxlist.Count; j++) {
                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + dxRowCount, "A"], xx.Cells[ihang + dxRowCount, "A"]);
                                range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing);

                            }
                            for (int jtem = 1; jtem < dxlist.Count; jtem++) {
                                for (int item = 0; item < 29; item += 2) {
                                    range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + 1 + item]);
                                    range.Merge(Type.Missing);
                                }
                            }
                            dxRowCount = dxlist.Count;
                            range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + dxRowCount - 1, 1]);
                            range.Merge(Type.Missing);
                        }
                        if (dxlist.Count > 0) {

                            for (j = 0; j < dxlist.Count; j++)
                                ex.SetCellValue(dxlist[j].ToString(), ihang + j, jlie);
                        }

                    } else {
                        ex.SetCellValue(strLinexh, ihang, jlie);
                    }

                    ihang += dxRowCount;
                    if (i == 15) {
                        int nn = 0;
                    }
                    //档        距(m)
                    if (gtobj != null && gtobj.gtSpan > 0) {
                        if (jlie > 3)
                            ex.SetCellValue(gtobj.gtSpan.ToString(), ihang, jlie - 1);
                        else
                            ex.SetCellValue(gtobj.gtSpan.ToString(), ihang, jlie);
                    }
                    ihang++;
                    //累计长度


                    if (((i + 0.0) % (jmax) == 0 && i > 1) || i == gtlis.Count - 1) {
                        //累计长度
                        double sum = 0;
                        int ista = i, item = i;
                        for (item = i; item > 0; item--) {
                            PS_gt gttemp = gtlis[item];
                            if (gttemp != null) {
                                sum += Convert.ToDouble(gttemp.gtSpan);
                            }
                            if (i < gtlis.Count - 1) {
                                if (item % jmax == 1 && ista != item) {
                                    break;
                                }
                            } else {
                                if (item % jmax == 1) {
                                    break;
                                }
                            }
                        }
                        sum = 0;
                        for (int m1 = 0; m1 < gtlis.Count; m1++) {
                            PS_gt gttemp = gtlis[m1];
                            if (gttemp != null) {
                                sum += Convert.ToDouble(gttemp.gtSpan);
                            }
                        }
                        ex.SetCellValue(sum.ToString(), ihang, jstart);

                        float gwidth = 13.50F, gheifht = 13.50F;
                        //float gwidth = 10F, gheifht = 10F;
                        Microsoft.Office.Interop.Excel.Shape activShape, oldShape = null, kywShape = null;
                        int icolor = (int)(((uint)Color.White.B << 16) | (ushort)(((ushort)Color.White.G << 8) | Color.White.R));
                        range = (Excel.Range)xx.get_Range(xx.Cells[6, 1], xx.Cells[6, 1]);
                        fxstart = (float)Convert.ToDouble(range.Cells.Width);
                        range = (Excel.Range)xx.get_Range(xx.Cells[6, 2], xx.Cells[6, 2]);
                        fxstart += (float)Convert.ToDouble(range.Cells.Width);
                        range = (Excel.Range)xx.get_Range(xx.Cells[1, 1], xx.Cells[5, 1]);
                        fystart = (float)Convert.ToDouble(range.Cells.Height);
                        range = (Excel.Range)xx.get_Range(xx.Cells[6, 1], xx.Cells[6, 1]);
                        fystart = fystart + (float)(Convert.ToDouble(range.Cells.Height) / 2);
                        activShape = null;
                        for (int itemp = 0; itemp <= ista - item; itemp++) {

                            range = (Excel.Range)xx.get_Range(xx.Cells[6, itemp * 2 + jstart], xx.Cells[6, itemp * 2 + jstart + 1]);
                            float width = (float)Convert.ToDouble(range.Cells.Width);

                            PS_xl xl2 = Client.ClientHelper.PlatformSqlMap.GetOne<PS_xl>("where ParentGT='" + gtlis[item + itemp].gtID + "'");
                            if (xl2 == null) {
                                if (gtlis[item + itemp].gtModle.IndexOf("转角") == -1) {
                                    activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart + width / 2, fystart, gwidth, gheifht);
                                } else {
                                    PJ_tbsj tb2 = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '直角'");
                                    if (tb2 != null) {

                                        string tempPath = Path.GetTempPath();
                                        string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb2.S1;
                                        FileStream fs;
                                        fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write);
                                        BinaryWriter bw = new BinaryWriter(fs);
                                        bw.Write(tb2.picImage);
                                        bw.Flush();
                                        bw.Close();
                                        fs.Close();
                                        Image im = Bitmap.FromFile(tempfile);
                                        Bitmap bt = new Bitmap(im);
                                        decimal[,] a1 = new decimal[1, 2];
                                        decimal[,] a2 = new decimal[1, 2];
                                        if (item + itemp < gtlis.Count) {
                                            a1[0, 0] = gtlis[item + itemp].gtLat - gtlis[item + itemp - 1].gtLat;
                                            a1[0, 1] = gtlis[item + itemp].gtLon - gtlis[item + itemp - 1].gtLon;

                                            a2[0, 0] = gtlis[item + itemp + 1].gtLat - gtlis[item + itemp].gtLat;
                                            a2[0, 1] = gtlis[item + itemp + 1].gtLon - gtlis[item + itemp].gtLon;
                                        }
                                        decimal di = a1[0, 0] * a2[0, 0] + a1[0, 1] * a2[0, 1];
                                        double dl = Math.Sqrt(Convert.ToDouble(a1[0, 0] * a1[0, 0] + a1[0, 1] * a1[0, 1]) * Math.Sqrt(Convert.ToDouble(
                                            a2[0, 0] * a2[0, 0] + a2[0, 1] * a2[0, 1])));
                                        dc = Math.Round(180 * Math.Acos(Convert.ToDouble(di) / Convert.ToDouble(dl)) / 3.1415926, 0);
                                        if (gtlis[item + itemp].gtLon > gtlis[item + itemp - 1].gtLon) {
                                            strfx = "右转";
                                        } else {
                                            strfx = "左转";
                                        }
                                        int btw = (int)(bt.Width / 1.33f);
                                        int bth = (int)(bt.Height / 1.33f);
                                        if (btw < width / 2) {

                                            activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 2 - btw / 2, fystart + gheifht / 2 - bth / 2, btw, bth);
                                            if (strfx == "左转") {
                                                if (dc.ToString() != "NaN" && dc.ToString() != "非数字")
                                                    activShape.Rotation = (float)(90 - Convert.ToDouble(dc));
                                            } else {
                                                if (dc.ToString() != "NaN" && dc.ToString() != "非数字")
                                                    activShape.Rotation = (float)(90 + Convert.ToDouble(dc));
                                            }

                                        } else {
                                            activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 5, fystart + gheifht / 2 - bt.Height / 2, bt.Width, bt.Height);
                                            if (strfx == "左转") {
                                                if (dc.ToString() != "NaN" && dc.ToString() != "非数字")
                                                    activShape.Rotation = (float)(90 - Convert.ToDouble(dc));
                                            } else {
                                                if (dc.ToString() != "NaN" && dc.ToString() != "非数字")
                                                    activShape.Rotation = (float)(90 + Convert.ToDouble(dc));
                                            }

                                        }
                                    }
                                }
                            } else {
                                ex.SetCellValue(xl2.LineName, 5, itemp * 2 + 4);//分支线路
                                PJ_tbsj tb2 = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '分支'");
                                if (tb2 != null) {

                                    string tempPath = Path.GetTempPath();
                                    string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb2.S1;
                                    FileStream fs;
                                    fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write);
                                    BinaryWriter bw = new BinaryWriter(fs);
                                    bw.Write(tb2.picImage);
                                    bw.Flush();
                                    bw.Close();
                                    fs.Close();
                                    Image im = Bitmap.FromFile(tempfile);
                                    Bitmap bt = new Bitmap(im);
                                    int btw = (int)(bt.Width / 1.33f);
                                    int bth = (int)(bt.Height / 1.33f);
                                    if (btw < width / 2) {
                                        activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 2 - btw / 2, fystart + gheifht / 2 - bth / 2, btw, bth);
                                    } else {
                                        activShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, fxstart + width / 5, fystart + gheifht / 2 - bth / 2, btw, bth);
                                    }

                                } else {
                                    activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart + width / 2, fystart, gwidth, gheifht);
                                }


                            }
                            //activShape = xx.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeOval, fxstart, fystart, gwidth, gheifht);
                            activShape.Fill.ForeColor.RGB = icolor;
                            if (itemp > 0) {
                                IList<PJ_05jcky> kyxli = MainHelper.PlatformSqlMap.GetList<PJ_05jcky>(" where gtID='" + gtlis[item + itemp].gtID + "'");
                                if (kyxli.Count == 0) {
                                    //Texture Image Recognition Algorithm Based on Steerable Pyramid Transform
                                    //if (Export17.ExistsRegedit() == 1) {//vs2003
                                    //    xx.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight,
                                    //        oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2,
                                    //        //activShape.Left , oldShape.Top + oldShape.Height / 2);
                                    //     activShape.Left - (oldShape.Left + oldShape.Width), 0);
                                    //} else 
                                    {
                                        xx.Shapes.AddLine(
                                              oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2,
                                              activShape.Left, activShape.Top + activShape.Height / 2);
                                    }
                                } else {
                                    PJ_tbsj tb = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '" + kyxli[0].kymc + "'");
                                    if (tb != null) {
                                        string tempPath = Path.GetTempPath();
                                        string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb.S1;
                                        FileStream fs;
                                        fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write);
                                        BinaryWriter bw = new BinaryWriter(fs);
                                        bw.Write(tb.picImage);
                                        bw.Flush();
                                        bw.Close();
                                        fs.Close();
                                        Image im = Bitmap.FromFile(tempfile);
                                        Bitmap bt = new Bitmap(im);
                                        int btw = (int)(bt.Width / 1.33f);
                                        int bth = (int)(bt.Height / 1.33f);
                                        if (btw < width / 2) {
                                            kywShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, oldShape.Left + oldShape.Width + width / 2 - btw / 2, oldShape.Top + oldShape.Height / 2 - bth / 2, btw, bth);
                                            // xx.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight,
                                            //oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2,
                                            //kywShape.Left, oldShape.Top + oldShape.Height / 2);
                                            xx.Shapes.AddLine(
                                          oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2,
                                          kywShape.Left, oldShape.Top + oldShape.Height / 2);

                                            //  xx.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight,
                                            //kywShape.Left + (float)(kywShape.Width - 2), kywShape.Top + kywShape.Height / 2,
                                            //activShape.Left + 2, kywShape.Top + kywShape.Height / 2);

                                            xx.Shapes.AddLine(
                                          kywShape.Left + (float)(kywShape.Width - 2), kywShape.Top + kywShape.Height / 2,
                                          activShape.Left + 2, kywShape.Top + kywShape.Height / 2);
                                        } else {
                                            //  kywShape = xx.Shapes.AddPicture(tempfile, MsoTriState.msoFalse, MsoTriState.msoTrue, oldShape.Left + oldShape.Width + width / 5, oldShape.Top + oldShape.Height / 2 - bth / 2, btw, bth);
                                            //  xx.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight,
                                            // oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2,
                                            // kywShape.Left, oldShape.Top + oldShape.Height / 2);

                                            //  xx.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight,
                                            //kywShape.Left + (float)(kywShape.Width - 1), kywShape.Top + kywShape.Height / 2,
                                            //activShape.Left + 1, kywShape.Top + kywShape.Height / 2);

                                            xx.Shapes.AddLine(
                                           oldShape.Left + oldShape.Width, oldShape.Top + oldShape.Height / 2,
                                           kywShape.Left, oldShape.Top + oldShape.Height / 2);

                                            xx.Shapes.AddLine(
                                          kywShape.Left + (float)(kywShape.Width - 1), kywShape.Top + kywShape.Height / 2,
                                          activShape.Left + 1, kywShape.Top + kywShape.Height / 2);
                                        }
                                        //Image im = Bitmap.FromFile(tempfile);
                                        //Bitmap bt = new Bitmap(im);
                                        //DataObject dataObject = new DataObject();
                                        //dataObject.SetData(DataFormats.Bitmap, bt);
                                        //Clipboard.SetDataObject(dataObject, true);

                                    }
                                }
                            }
                            //fxstart += gtwidth[itemp];
                            fxstart += width;
                            oldShape = activShape;
                        }
                    }
                    ihang++;

                    //横担
                    if (hdobj != null && hdobj.Count > 0) {

                        if (hdobj.Count > hdRowCount) {
                            for (j = hdRowCount; j < hdobj.Count; j++) {
                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + hdRowCount, "A"], xx.Cells[ihang + hdRowCount, "A"]);
                                range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing);
                                for (int item = 0; item < 29; item += 2) {
                                    range = (Excel.Range)xx.get_Range(xx.Cells[ihang + hdRowCount, jstart + item], xx.Cells[ihang + hdRowCount, jstart + 1 + item]);
                                    range.Merge(Type.Missing);
                                }
                            }

                            hdRowCount = hdobj.Count;
                            range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + hdRowCount - 1, 1]);
                            range.Merge(Type.Missing);
                        }
                        for (j = 0; j < hdobj.Count; j++) {
                            ex.SetCellValue(hdobj[j].ToString(), ihang + j, jlie);
                            //if (j + 1 < hdobj.Count)
                            //{
                            //    range = (Excel.Range)xx.get_Range(xx.Cells[ihang + 1, 1], xx.Cells[ihang + 1, 1]);
                            //    range.Insert(Excel.XlInsertShiftDirection.xlShiftDown, Type.Missing);
                            //    ihang++;
                            //}
                        }

                    }
                    ihang += hdRowCount;
                    //拉线规格/条数
                    if (lxlist != null && lxlist.Count > 0) {

                        if (lxlist.Count > lxRowCount) {
                            for (j = lxRowCount; j < lxlist.Count; j++) {
                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + lxRowCount, "A"], xx.Cells[ihang + lxRowCount, "A"]);
                                range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing);
                                //for (int item = 0; item < 29; item += 2)
                                //{
                                //    range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j + 1, jstart + item], xx.Cells[ihang + j + 1, jstart + 1 + item]);
                                //    range.Merge(Type.Missing);
                                //}
                            }
                            for (int jtem = lxRowCount; jtem < lxlist.Count; jtem++) {
                                for (int item = 0; item < 29; item += 2) {
                                    range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + item + 1]);
                                    range.Merge(Type.Missing);
                                }
                            }
                            lxRowCount = lxlist.Count;
                            range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + lxRowCount - 1, 1]);
                            range.Merge(Type.Missing);
                        }
                        for (j = 0; j < lxlist.Count; j++) {
                            int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select   sum(sbNumber) from PS_gtsb where sbModle = '" + lxlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"));
                            //int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<PS_gtsb>(" Where sbModle = '" + lxlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'");
                            ex.SetCellValue(lxlist[j].ToString()/* + "/" + icount*/, ihang + j, jlie);

                        }
                    }
                    ihang += lxRowCount;

                    //绝缘子型号/数量
                    if (jyuzlist != null) {

                        if (jyuzlist.Count > jyzRowCount) {
                            for (j = jyzRowCount + 1; j < jyuzlist.Count; j = j + 2) {

                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jyzRowCount, "A"], xx.Cells[ihang + jyzRowCount, "A"]);
                                range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing);

                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j, 2], xx.Cells[ihang + j - 1, 2]);
                                range.Merge(Type.Missing);
                            }
                            //for (int jtem = 0; jtem < jyuzlist.Count; jtem++) {
                            //    for (int item = 0; item < 29; item += 2) {
                            //        range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + 1 + item]);
                            //        range.Merge(Type.Missing);
                            //    }
                            //}
                            jyzRowCount = jyuzlist.Count / 2 + jyuzlist.Count % 2 == 0 ? 0 : 1;
                            range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + jyzRowCount - 1, 1]);
                            range.Merge(Type.Missing);
                        }
                        for (j = 0; j < jyuzlist.Count; j++) {
                            int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select   sum(sbNumber) from PS_gtsb where sbModle = '" + jyuzlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"));
                            //int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<PS_gtsb>(" Where sbModle = '" + jyuzlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'");
                            ex.SetCellValue(jyuzlist[j].ToString() /*+ "/" + icount*/, ihang + j / 2, jlie + j % 2);
                            ex.SetCellValue(icount.ToString(), ihang + j / 2 + 1, jlie + j % 2);

                        }
                    }
                    ihang += jyzRowCount * 2;
                    //变台型式
                    if (btlist != null) {
                        if (btlist.Count > 0) {
                            //ilisttemp = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct sbCode from PS_gtsb  Where  sbModle = '" + btlist[0].ToString() + "' and gtID='" + gtobj.gtID + "'");
                            ilisttemp = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct byqModle from PS_tqbyq  Where tqID  in ( select tqID from PS_tq where  gtID='" + gtobj.gtID + "')");
                            //if (ilisttemp.Count > btRowCount) {
                            //    for (j = btRowCount; j < ilisttemp.Count; j++) {
                            //        range = (Excel.Range)xx.get_Range(xx.Cells[ihang + btRowCount + 1, "A"], xx.Cells[ihang + btRowCount + 1, "A"]);
                            //        range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing);

                            //        range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j, 2], xx.Cells[ihang + j + 1, 2]);
                            //        range.Merge(Type.Missing);

                            //    }
                            //    for (int jtem = 1; jtem < ilisttemp.Count; jtem++) {
                            //        for (int item = 0; item < 29; item += 2) {
                            //            range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem + 3, jstart + item], xx.Cells[ihang + jtem + 3, jstart + item + 1]);
                            //            range.Merge(Type.Missing);
                            //        }
                            //    }

                            //    btRowCount = ilisttemp.Count;
                            //    range = (Excel.Range)xx.get_Range(xx.Cells[ihang + 1, 1], xx.Cells[ihang + btRowCount + 1 - 1, 1]);
                            //    range.Merge(Type.Missing);
                            //}
                            //if (btlist.Count == 1)
                            ex.SetCellValue(btlist[0].ToString(), ihang, jlie);
                            //else
                            //{
                            //    j = j;
                            //}
                            int byqrl = 0;
                            int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select   count(*) from PS_tqbyq where  tqID  in ( select tqID from PS_tq where  gtID='" + gtobj.gtID + "')"));
                            for (j = 0; j < Math.Min(ilisttemp.Count, 2); j++) {//只能显示两个
                                //int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select   sum(sbNumber) from PS_gtsb where sbCode='" + ilisttemp[0].ToString() + "' and  sbModle = '" + btlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"));
                                ////int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<PS_gtsb>(" Where sbCode='" + ilisttemp[0].ToString() + "' and  sbModle = '" + btlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'");
                                //PS_gtsb gtsbtemp = Client.ClientHelper.PlatformSqlMap.GetOne<PS_gtsb>(" Where sbCode='" + ilisttemp[0].ToString() + "' and sbModle = '" + btlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'");
                                PS_tqbyq gtsbtemp = Client.ClientHelper.PlatformSqlMap.GetOne<PS_tqbyq>(" Where byqModle='" + ilisttemp[j].ToString() + "'   and tqID  in ( select tqID from PS_tq where  gtID='" + gtobj.gtID + "')");
                                if (gtsbtemp != null) {
                                    //PS_sbcs sbcstemp = Client.ClientHelper.PlatformSqlMap.GetOneByKey<PS_sbcs>(gtsbtemp.sbType + ilisttemp[0].ToString());
                                    //if (sbcstemp != null)
                                    //{
                                    //ex.SetCellValue(sbcstemp.xh + "/" + icount.ToString(), ihang + j + 1, jlie);
                                    //}
                                    byqrl += gtsbtemp.byqCapcity;
                                    if (gtsbtemp.byqModle.IndexOf("-") < 0) {
                                        ex.SetCellValue(gtsbtemp.byqModle /*+ "/" + icount.ToString()*/, ihang + 1, jlie + j);
                                        //ex.SetCellValue(/*gtsbtemp.byqModle + "/" +*/ icount.ToString(), ihang+j  + 2, jlie);
                                        //ex.SetCellValue(gtsbtemp.byqCapcity.ToString(), ihang+j  + 3, jlie);
                                    } else {
                                        ex.SetCellValue(gtsbtemp.byqModle.Substring(0, gtsbtemp.byqModle.IndexOf("-"))  /*+ "/"+ icount.ToString()*/, ihang + 1, jlie + j);

                                    }
                                }
                            }
                            ex.SetCellValue(icount.ToString(), ihang + 2, jlie);
                            ex.SetCellValue(byqrl.ToString(), ihang + 3, jlie);
                        }

                    }
                    ihang += btRowCount + 3;

                    //避雷器型号/数量
                    if (blqlist != null && blqlist.Count > 0) {

                        if (blqlist.Count > blqRowCount) {

                            for (j = blqRowCount; j < blqlist.Count; j++) {
                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + blqRowCount, "A"], xx.Cells[ihang + blqRowCount, "A"]);
                                range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, Type.Missing);

                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j, 2], xx.Cells[ihang + j - 1, 2]);
                                range.Merge(Type.Missing);


                            }
                            for (int jtem = 0; jtem < blqlist.Count; jtem++) {
                                for (int item = 0; item < 29; item += 2) {
                                    range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + 1 + item]);
                                    range.Merge(Type.Missing);
                                }
                            }
                            blqRowCount = blqlist.Count;
                            range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + blqRowCount - 1, 1]);
                            range.Merge(Type.Missing);
                        }
                        for (j = 0; j < blqlist.Count; j++) {
                            int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select   sum(sbNumber) from PS_gtsb  Where sbModle = '" + blqlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"));
                            // int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<PS_gtsb>(" Where sbModle = '" + blqlist[j].ToString() + "' and gtID='" + gtobj.gtID + "'");
                            ex.SetCellValue(blqlist[j].ToString(), ihang + j, jlie);
                            ex.SetCellValue(icount.ToString(), ihang + j + 1, jlie);

                        }


                    }
                    ihang += blqRowCount + 1;

                    //开关型号/数量
                    if (kglist != null && kglist.Count > 0) {

                        if (kglist.Count > kgRowCount) {

                            for (j = kgRowCount; j < kglist.Count; j++) {
                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + kgRowCount, "A"], xx.Cells[ihang + kgRowCount, "A"]);
                                range.EntireRow.Insert(Excel.XlInsertShiftDirection.xlShiftDown, Type.Missing);

                                range = (Excel.Range)xx.get_Range(xx.Cells[ihang + j, 2], xx.Cells[ihang + j - 1, 2]);
                                range.Merge(Type.Missing);


                            }
                            for (int jtem = 0; jtem < kglist.Count; jtem++) {
                                for (int item = 0; item < 29; item += 2) {
                                    range = (Excel.Range)xx.get_Range(xx.Cells[ihang + jtem, jstart + item], xx.Cells[ihang + jtem, jstart + 1 + item]);
                                    range.Merge(Type.Missing);
                                }
                            }
                            kgRowCount = kglist.Count;
                            range = (Excel.Range)xx.get_Range(xx.Cells[ihang, 1], xx.Cells[ihang + kgRowCount - 1, 1]);
                            range.Merge(Type.Missing);
                        }
                        for (j = 0; j < kglist.Count; j++) {
                            try {
                                //int icount = Convert.ToInt32(Client.ClientHelper.PlatformSqlMap.GetObject("SelectOneInt", "select   sum(sbNumber) from PS_gtsb  Where sbModle = '" + kglist[j].ToString() + "' and gtID='" + gtobj.gtID + "'"));
                                //int icount = Client.ClientHelper.PlatformSqlMap.GetRowCount<PS_kg>(" Where kgModle = '" + kglist[j].ToString() + "' and gtID='" + gtobj.gtID + "'");
                                ex.SetCellValue(kglist[j].ToString(), ihang + j, jlie);

                            } catch { }

                        }
                        ex.SetCellValue(kglist.Count.ToString(), ihang + 2, jlie);
                    }
                    ihang += kgRowCount + 2;

                    jlie += 2;
                }
                //#region 画图形
                //dsoFramerWordControl1.FileOpen(outfname);
                //Microsoft.Office.Interop.Excel.Workbook wb;
                //Microsoft.Office.Interop.Excel.Worksheet xx;
                //try
                //{
                //    wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook;
                //    xx = wb.Application.Sheets[1] as Microsoft.Office.Interop.Excel.Worksheet;

                //}
                //catch (Exception err)
                //{
                //    dsoFramerWordControl1.FileClose();
                //    throw new Exception("excel的打开方式不对,有可能装有wps", err);
                //}
                //Excel.Range range;
                //if (lieindex < 1)
                //    range = (Excel.Range)xx.get_Range(xx.Cells[5, 1], xx.Cells[RowCount, ColumnCount]);
                //else
                //    range = (Excel.Range)xx.get_Range(xx.Cells[5, 1], xx.Cells[RowCount, lieindex + 2]);

                //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous;
                //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].Weight = Excel.XlBorderWeight.xlThick;
                //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight].LineStyle = Excel.XlLineStyle.xlContinuous;
                //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight].Weight = Excel.XlBorderWeight.xlThick;
                //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].LineStyle = Excel.XlLineStyle.xlContinuous;
                //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Excel.XlBorderWeight.xlThick;
                ex.ActiveSheet(1);


            } catch (Exception exmess) {
                MsgBox.ShowTipMessageBox(exmess.Message.ToString());
            }
            dsoFramerWordControl1.FileSave();
            pj17.BigData = dsoFramerWordControl1.FileDataGzip;
            dsoFramerWordControl1.FileClose();
            dsoFramerWordControl1.Dispose();
            //#endregion
            //System.Diagnostics.Process.Start(outfname);
            return 1;
        }
Esempio n. 11
0
        void gridViewOperation_AfterEdit(PJ_23 obj)
        {
            //修改模板

            mOrg org = MainHelper.PlatformSqlMap.GetOneByKey<mOrg>(obj.ParentID);
            string fname = Application.StartupPath + "\\00记录模板\\23配电线路产权维护范围协议书.xls";
            string bhname = org.OrgName.Replace("供电所", "");
            DSOFramerControl dsoFramerControl1 = new DSOFramerControl();
            dsoFramerControl1.FileOpen(fname);
            Microsoft.Office.Interop.Excel.Workbook wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook;
            //PJ_23 obj1 = (PJ_23)MainHelper.PlatformSqlMap.GetObject("SelectPJ_23List", "where ParentID='" + obj.ParentID + "' and xybh like '" + SelectorHelper.GetPysm(org.OrgName.Replace("供电所", ""), true) + "-" + DateTime.Now.Year.ToString() + "-%' order by xybh ASC");
            //int icount = 1;
            //if (obj1 != null && obj1.xybh != "")
            //{
            //    //icount = Convert.ToInt32(obj.xybh.Split('-')[2]) + 1;
            //}
            string strname = obj.xybh;// SelectorHelper.GetPysm(bhname, true);
            ExcelAccess ea = new ExcelAccess();
            ea.MyWorkBook = wb;
            ea.MyExcel = wb.Application;
            ea.SetCellValue(strname.ToUpper(), 4, 8);
            //strname = DateTime.Now.Year.ToString();
            //ea.SetCellValue(strname, 4, 9);
            //strname = string.Format("{0:D3}", icount);
            //ea.SetCellValue(strname, 4, 10);
            ea.SetCellValue(obj.cqdw + ":", 6, 4);
            ea.SetCellValue(obj.linename, 10, 7);
            ea.SetCellValue(obj.fzlinename, 10, 10);
            ea.SetCellValue("'" + obj.gh, 10, 16);
            ea.SetCellValue(obj.cqfw, 11, 4);
            ea.SetCellValue(obj.cqdw, 13, 4);
            ea.SetCellValue(obj.qdrq.Year.ToString(), 21, 7);
            ea.SetCellValue(obj.qdrq.Month.ToString(), 21, 9);
            ea.SetCellValue(obj.qdrq.Day.ToString(), 21, 11);
            dsoFramerControl1.FileSave();
            obj.BigData = dsoFramerControl1.FileData;
            dsoFramerControl1.FileClose();
            dsoFramerControl1.Dispose();
            dsoFramerControl1 = null;
            MainHelper.PlatformSqlMap.Update<PJ_23>(obj);
        }
Esempio n. 12
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //if (comboBoxEdit1.Text == "")
            //{
            //    MsgBox.ShowTipMessageBox("变动地点不能为空。");
            //    comboBoxEdit1.Focus();
            //    return;
            //}

            ////if (rowData.BigData == null)
            ////{
            ////    rowData.BigData = new byte[0];
            ////}
            //this.DialogResult = DialogResult.OK;
            //this.Close();
            string strmes = "";
            DSOFramerControl dsoFramerControl1 = new DSOFramerControl();
            Microsoft.Office.Interop.Excel.Workbook wb;
            if (rowData.BigData == null || rowData.BigData.Length == 0)
            {
                string fname = Application.StartupPath + "\\00记录模板\\24设备变更通知书.xls";
                dsoFramerControl1.FileOpen(fname);
            }
            else
                dsoFramerControl1.FileData = rowData.BigData;
            wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook;
            ExcelAccess ea = new ExcelAccess();
            ea.MyWorkBook = wb;
            ea.MyExcel = wb.Application;
            DateTime dt = Convert.ToDateTime(dateEdit1.EditValue);
            ea.SetCellValue(dt.Year.ToString(), 4, 7);
            mOrg org = MainHelper.PlatformSqlMap.GetOne<mOrg>(" where orgid='" + rowData.ParentID + "'");
            if (org != null)
                ea.SetCellValue(org.OrgName,4, 9);
            ea.SetCellValue(dt.Year.ToString(), 9, 1);
            ea.SetCellValue(dt.Month.ToString(), 9, 3);
            ea.SetCellValue(dt.Day.ToString(), 9, 5);
            ea.SetCellValue(comboBoxEdit1.Text, 6, 7);
            ea.SetCellValue(memoEdit1.Text, 6, 8);
            ea.SetCellValue(memoEdit2.Text, 6, 11);
            dsoFramerControl1.FileSave();
            rowData.BigData = dsoFramerControl1.FileData;
            dsoFramerControl1.FileClose();
            dsoFramerControl1.Dispose();
            dsoFramerControl1 = null;
            MainHelper.PlatformSqlMap.Update<PJ_24>(rowData);

            currRecord.LastChangeTime = DateTime.Now.ToString();
            if (RecordWorkTask.CheckOnRiZhi(WorkFlowData))
            {

                RecordWorkTask.CreatRiZhi(WorkFlowData, null, currRecord.ID, new object[] { rowData, currRecord });

            }


           
            WF_WorkTaskCommands wt;

            
            //string[] strtemp = RecordWorkTask.RunNewGZPRecord(currRecord.ID, kind, MainHelper.User.UserID);
            wt = (WF_WorkTaskCommands)MainHelper.PlatformSqlMap.GetObject("SelectWF_WorkTaskCommandsList", " where WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "' and WorkTaskId='" + WorkFlowData.Rows[0]["WorkTaskId"].ToString() + "'");
            if (wt != null)
            {
                strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), wt.CommandName);
            }
            else
            {
                strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), "提交");
            }
            if (strmes.IndexOf("未提交至任何人") > -1)
            {
                MsgBox.ShowTipMessageBox("未提交至任何人,创建失败,请检查流程模板和组织机构配置是否正确!");
                return;
            }
            else
                MsgBox.ShowTipMessageBox(strmes);
            strmes = RecordWorkTask.GetWorkFlowTaskCaption(WorkFlowData.Rows[0]["WorkTaskInsId"].ToString());
            if (strmes == "结束节点1")
            {
                currRecord.Status = "存档";
            }
            else
            {
                currRecord.Status = strmes;
            }
            if (currRecord.ImageAttachment == null)
            {
                currRecord.ImageAttachment = new byte[0];
            }
            if (currRecord.DocContent == null)
            {
                currRecord.DocContent = new byte[0];
            }
            if (currRecord.SignImg == null)
            {
                currRecord.SignImg = new byte[0];
            }

            currRecord.LastChangeTime = DateTime.Now.ToString();
            if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0];
            if (currRecord.SignImg == null) currRecord.SignImg = new byte[0];
            MainHelper.PlatformSqlMap.Update("UpdateLP_Record", currRecord);
        }
Esempio n. 13
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string strname = "";
            string fname = "";
            string bhname="";
            int icount = 1;

           
            DSOFramerControl dsoFramerControl1 = new DSOFramerControl();
            Microsoft.Office.Interop.Excel.Workbook wb;
            ExcelAccess ea = new ExcelAccess();
            if (rowData.BigData == null || rowData.BigData.Length == 0)
            {
                 fname = Application.StartupPath + "\\00记录模板\\26防护通知书.xls";
                dsoFramerControl1.FileOpen(fname);
            }
            else
                dsoFramerControl1.FileData = rowData.BigData;
            wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook;
            ea.MyWorkBook = wb;
            ea.MyExcel = wb.Application;
            if (rowData.BigData == null || rowData.BigData.Length == 0)
            {
                fname = Application.StartupPath + "\\00记录模板\\26防护通知书.xls";



                mOrg org = MainHelper.PlatformSqlMap.GetOneByKey<mOrg>(rowData.ParentID);
                bhname = org.OrgName.Replace("供电所", "");
                PJ_26 obj = (PJ_26)MainHelper.PlatformSqlMap.GetObject("SelectPJ_26List", "where ParentID='" + rowData.ParentID + "' and xybh like '" + SelectorHelper.GetPysm(org.OrgName.Replace("供电所", ""), true) + "-" + DateTime.Now.Year.ToString() + "-%' order by xybh ASC");

                if (obj != null && obj.xybh != "")
                {
                    icount = Convert.ToInt32(obj.xybh.Split('-')[2]) + 1;
                }
                rowData.xybh = SelectorHelper.GetPysm(bhname, true).ToUpper() + "-" + DateTime.Now.Year.ToString() + "-" + string.Format("{0:D3}", icount);
                strname = SelectorHelper.GetPysm(bhname, true);
                ea.SetCellValue(strname.ToUpper(), 4, 9);
                strname = DateTime.Now.Year.ToString();
                ea.SetCellValue(strname, 4, 11);
                strname = string.Format("{0:D3}", icount);
                ea.SetCellValue(strname, 4, 13);
               
            }
            ea.SetCellValue(comboBoxEdit1.Text + ":", 5, 2);
            ea.SetCellValue(comboBoxEdit3.Text, 6, 11);
            if (memoEdit2.Text.Length > 25)
            {
                ea.SetCellValue(memoEdit2.Text.Substring(0, 25), 7, 3);
                ea.SetCellValue(memoEdit2.Text.Substring(26), 8, 2);
            }
            else
                {
                    ea.SetCellValue(memoEdit2.Text, 7, 3);
                }
            if (memoEdit3.Text.Length > 23)
            {
                ea.SetCellValue(memoEdit3.Text.Substring(0, 23), 13, 4);
                ea.SetCellValue(memoEdit3.Text.Substring(24), 14, 2);
            }
            else
                {
                    ea.SetCellValue(memoEdit3.Text, 13, 4);
                }
            dsoFramerControl1.FileSave();
            rowData.BigData = dsoFramerControl1.FileData;
            dsoFramerControl1.FileClose();
            dsoFramerControl1.Dispose();
            dsoFramerControl1 = null;
        }
Esempio n. 14
0
        private void buttonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "Excel文件(*.xls)|*.xls";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                buttonEdit1.Text = openFileDialog1.FileName;
                DSOFramerControl dsoFramerControl1 = new DSOFramerControl();
                Microsoft.Office.Interop.Excel.Workbook wb;
                dsoFramerControl1.FileOpen(buttonEdit1.Text);
                dsoFramerControl1.FileSave();
                rowData.BigData = dsoFramerControl1.FileDataGzip;

                dsoFramerControl1.FileClose() ;
                dsoFramerControl1.Dispose();
                //string[] str_name =  buttonEdit1.Text.Split("\\".ToCharArray());
                //string[] filename = str_name[str_name.Length - 1].Split(".".ToCharArray());
                //byte[] Excbyte = System.Text.Encoding.Default.GetBytes(filename[filename.Length - 1]);
                //string Exc = System.Text.Encoding.Default.GetString(Excbyte);
                //rowData.S1 ="."+ Exc;
            }
        }