Ejemplo n.º 1
0
        public void ExportExcelMonth(DateTime dt, DateTime dt2, string orgid)
        {
            //lgm
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\所月度停电计划.xls";
            ex.Open(fname);
            string startday = "20";
            IList list = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr",
                string.Format("select nr from pj_dyk where  dx='所月度停电计划' and sx like '%{0}%' and nr!=''", "申报截止日期"));
            if (list.Count > 0)
                startday=list[0].ToString();
            string str = " where (TDtime between '" +dt.Year + "-"
                + dt.Month + "-" + dt.Day
                + " 00:00:00' and  '"
                + dt2.Year + "-"
                + dt2.Month + "-" + dt2.Day + " 23:59:59' ) ";
            if (orgid != "") str += " and OrgCode='" + orgid + "'";
            IList<PJ_tdjh> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_tdjh>(
               str
                );
            ExportExcel(dt, ex, datalist);
            ex.ShowExcel();

        }
Ejemplo n.º 2
0
        public static void Print(PrintType printType, BarcodeSample sample, TestResult technic, TestResult reality)
        {
            ExcelAccess access   = new ExcelAccess();
            string      path     = ConfigurationManager.AppSettings["template"];
            string      fullPath = Path.GetFullPath(path);

            access.Open(fullPath);
            access.IsVisibledExcel = true;
            access.FormCaption     = "商品条码符号检测数据";
            switch (printType)
            {
            case PrintType.Print:
                access.Print();
                break;

            case PrintType.PrintView:
                access.PrintPreview();
                break;

            default:
                access.Close();
                break;
            }
            access.Close();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 文档格式预定义好的,只填写内容
 /// </summary>
 /// <param name="obj"></param>
 public static void ExportExcel(sdjl_26 obj) {
     ExcelAccess ex = new ExcelAccess();
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     string fname = Application.StartupPath + "\\00记录模板\\送电17防护通知书.xls";
     int sz = 30;//一行最多30个
     ex.Open(fname);
     //此处写填充内容代码
     ex.ActiveSheet(1);
     //通知单位
     ex.SetCellValue(obj.tzdw, 5, 1);
     //电压
     ex.SetCellValue(obj.lineVol, 6, 7);
     //线路
     ex.SetCellValue(obj.c1, 6, 9);
     //发现问题
     List<string> fxwtList = GetList(obj.fxwt, sz);
     for (int i = 0; i < fxwtList.Count; i++)
     {
         ex.SetCellValue(fxwtList[i], 7+i, 1);
         if (i > 1)
             break;
     }
     //处理措施
     List<string> clcsList = GetList(obj.clcs, sz);
     for (int i = 0; i < clcsList.Count; i++)
     {
         ex.SetCellValue(obj.clcs, 12+i, 1);
         if (i > 2)
             break;
     }
    
    ex.ShowExcel();
 }
Ejemplo n.º 4
0
        internal static void ExportCK(string rkid) {
            ExcelAccess ea = new ExcelAccess();
            string filename = AppDomain.CurrentDomain.BaseDirectory + "\\00记录模板\\.xls";
            if (!File.Exists(filename))
            {
                //导出资源文件到本机
                Stream obj = typeof(PrintHelper).Assembly.GetManifestResourceStream("Ebada.Kcgl._00记录模板..xls");
                object[] files = typeof(PrintHelper).Assembly.GetManifestResourceNames();
                if (obj != null) {
                    byte[] buff = new byte[obj.Length];
                    obj.Read(buff, 0, (int)obj.Length);

                    FileStream fs = new FileStream(filename, FileMode.OpenOrCreate);
                    fs.Write(buff, 0, buff.Length);
                    fs.Flush();
                    fs.Close();
                    fs.Dispose();
                }

            }
            ea.Open(filename);

          
            //显示文件
            ea.Print();
            ea.DisPoseExcel();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
        public void ExportExcel()
        {
            ////lgm
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\局设备评级计划.xls";
            ex.Open(fname);

            string strfirst = "";
            string filter = "";

            filter = "  where 1=1 ";
            if (isWorkflowCall)
            {
                filter = filter + " and id not in (select ModleRecordID from WF_ModleRecordWorkTaskIns where  WorkFlowId='"
                    + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "') "
                        + " or id in  (select ModleRecordID from WF_ModleRecordWorkTaskIns where "
                    + "    RecordID='" + currRecord.ID + "') "
                    ;
            }
            IList<PJ_jsbpjjh> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_jsbpjjh>(
             filter
               );
            ExportExcel(ex, datalist);




            ex.ShowExcel();
        }
Ejemplo n.º 6
0
        public void ExportExcelYear(string orgid, string year) {
            ////lgm
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\设备标志缺失变更明细表二.xls";
            ex.Open(fname);

            string strfirst = "";
            string filter = "";

            filter = "  where 1=1 ";
            if (orgid != "") filter += " and OrgCode='" + orgid + "'";

            if (isWorkflowCall) {
                filter = filter + " and id not in (select ModleRecordID from WF_ModleRecordWorkTaskIns where  WorkFlowId='"
                    + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "') "
                        + " or id in  (select ModleRecordID from WF_ModleRecordWorkTaskIns where "
                    + "    RecordID='" + currRecord.ID + "') "
                    ;
            }
            IList<PJ_sbbzqsbgmxb2> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_sbbzqsbgmxb2>(
             filter
               );
            ExportExcel(ex, datalist, orgid);

            ex.ShowExcel();
        }
Ejemplo n.º 7
0
        public static void ExportExcel(Dictionary<string, List<PJ_qxfl>> objdic)
        {
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\06设备巡视及缺陷消除记录.xls";

            ex.Open(fname);
            int zc = 20;
            //与会人员之间的间隔符号
            char[] jksign = new char[1] { ';' };
            int row = 7;
            int col = 1;
            int len1 = 3;
            int pageindex = 1;
            pageindex = objdic.Count;
            //根据所有的线路数来确定创建的页数
            for (int j = 1; j <= pageindex; j++)
            {
                if (j > 1)
                {
                    ex.CopySheet(1, 1);
                }
            }
            int pags = 0;
            foreach (KeyValuePair<string, List<PJ_qxfl>> pp in objdic)
            {
                List<PJ_qxfl> objlist = pp.Value;
                ex.ActiveSheet(pags++);

            }

        }
Ejemplo n.º 8
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
              SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = "";
            saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                fname = saveFileDialog1.FileName;
                try
                {
                    dsoFramerControl1.FileSave(saveFileDialog1.FileName, true);
                    if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK)
                    {
                        ExcelAccess ex = new ExcelAccess();
                        ex.Open(fname);
                        //此处写填充内容代码

                        ex.ShowExcel();
                        return;
                    }
                }
                catch
                {
                    MsgBox.ShowSuccessfulMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。");
                    return;
                }
            }
        }
Ejemplo n.º 9
0
        public static void ExportExcel10KV(IList<PS_kgjctj> datalist)
        {
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\10KV用户供电可靠性基础数据统计表.xls";
            ex.Open(fname);

            int rowcount = 1;
            if (datalist.Count < 1) return;
            string tablename = "10KV用户供电可靠性基础数据统计表";
            if (tablename.Length > 30)
            {
                tablename = tablename.Substring(tablename.Length - 31);
            }
            //
            //加页
            int pageindex = datalist.Count;

            for (int j = 1; j < pageindex; j++)
            {
                ex.CopySheet(1, j);
                ex.ReNameWorkSheet(j + 1, tablename + "(" + (j) + ")");
            }
            for (int j = 0; j < datalist.Count; j++)
            {
                if (j == 0)
                {
                    ex.ActiveSheet(tablename);
                }
                else
                {
                    ex.ActiveSheet(tablename + "(" + j + ")");
                }
                // 填值
                ex.SetCellValue(datalist[j].OrgName, 3, 2);
                ex.SetCellValue(datalist[j].CreateTime.ToString("yyyy年MM月dd日"), 5, 9);
                ex.SetCellValue(datalist[j].kgModel, 5, 2);
                ex.SetCellValue(datalist[j].iscxkg == true ? "是" : "否", 5, 7);
                ex.SetCellValue(datalist[j].kgCode, 5, 9);
                ex.SetCellValue(datalist[j].jkdxcd, 10, 2);
                ex.SetCellValue(datalist[j].dlxlcd, 10, 7);
                ex.SetCellValue(datalist[j].publicusercount.ToString(), 11, 2);
                ex.SetCellValue(datalist[j].publicbtcount.ToString(), 11, 5);
                ex.SetCellValue(datalist[j].publicbtrlcount.ToString(), 11, 9);
                ex.SetCellValue(datalist[j].zyusercount.ToString(), 12, 2);
                ex.SetCellValue(datalist[j].zybtcount.ToString(), 12, 5);
                ex.SetCellValue(datalist[j].zybtrlcount.ToString(), 12, 9);

                ex.SetCellValue(datalist[j].sdyusercount.ToString(), 13, 2);
                ex.SetCellValue(datalist[j].sdyrlcount.ToString(), 13, 5);
                ex.SetCellValue(datalist[j].zyuserqtsbcount.ToString(), 13, 9);

                ex.SetCellValue(datalist[j].drqcount.ToString(), 14, 2);
                ex.SetCellValue(datalist[j].drqrl, 14, 5);
                ex.SetCellValue(datalist[j].zyuserqtsbrlcount.ToString(), 14, 9);
            }
            ex.ActiveSheet(tablename);
            ex.ShowExcel();
        }
Ejemplo n.º 10
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = "";
            saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls";


            if (saveFileDialog1.ShowDialog() == DialogResult.OK) {
                fname = saveFileDialog1.FileName;
                try {
                    dsoFramerControl1.FileSave(saveFileDialog1.FileName, true);
                    //dsoFramerControl1.Dispose();

                    //dsoExcelControl1.AxFramerControl.Save(fname,true,null,null);
                    // dsoExcelControl1.FileSaveAs(out fname);
                    //if (MsgBox.Show("导出成功!") != DialogResult.Yes)
                    //////MsgBox.Show("导出成功!");
                    //////dsoExcelControl1.AxFramerControl.Dispose();
                    //////return;

                    if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK) {
                        //dsoExcelControl1.AxFramerControl.Dispose();
                        //dsoExcelControl1.Dispose();
                        ExcelAccess ex = new ExcelAccess();
                        //SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                        //string fname = Application.StartupPath + "\\00记录模板\\26防护通知书.xls";

                        ex.Open(fname);
                        //此处写填充内容代码

                        ex.ShowExcel();
                        //Microsoft.Office.Interop.Excel.Application exc = new Microsoft.Office.Interop.Excel.Application(); //引用Excel对象
                        //Microsoft.Office.Interop.Excel.Workbook book = exc.Application.Workbooks.Add(fname); //引用Excel工作簿
                        //exc.Visible = true; //使Excel可视
                        return;
                    }
                    //System.Diagnostics.Process.Start(fname);

                    //ExcelAccess ex = new ExcelAccess();
                    ////SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                    ////string fname = Application.StartupPath + "\\00记录模板\\26防护通知书.xls";

                    //ex.Open(fname);
                    ////此处写填充内容代码

                    //ex.ShowExcel();




                    //  System.Diagnostics.Process.Start(fname);
                } catch {
                    MsgBox.ShowSuccessfulMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。");
                    return;
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
        public static void ExportExcel(object obj) {
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\17线路条图.xls";

            ex.Open(fname);
            //此处写填充内容代码

           ex.ShowExcel();
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 文档格式预定义好的,只填写内容
 /// </summary>
 /// <param name="obj"></param>
 public static void ExportExcel(sdjl_23 obj)
 {
     ExcelAccess ex = new ExcelAccess();
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     string fname = Application.StartupPath + "\\00记录模板\\送电16电力设备产权、维护范围协议书.xls";
     if (obj.BigData != null)
     {
         if (obj.BigData.Length > 10)
         {
             fname = Path.GetTempPath() + "送电16电力设备产权、维护范围协议书.xls";
             //MemoryStream ms = new MemoryStream(obj.BigData);
             FileStream fs = new FileStream(fname, FileMode.OpenOrCreate);
             fs.Write(obj.BigData, 0, obj.BigData.Length);
             fs.Flush();
             fs.Close();
         }
     }
     ex.Open(fname);
     ex.SetCellValue(obj.jf, 5, 4);
     ex.SetCellValue(obj.xybh, 4, 11);
     ex.SetCellValue(obj.cqdw + ":", 6, 4);
     string linename = "";
     if (obj.linename.Contains("线"))
     {
         linename = obj.linename.Substring(0, obj.linename.LastIndexOf("线"));
     }
     else
         linename = obj.linename;
     string[] filtchar = { "V", "v" };
     for (int i = 0; i < filtchar.Length; i++)
     {
         if (linename.Contains(filtchar[i]))
         {
             linename = linename.Substring(linename.LastIndexOf(filtchar[i]) + 1);
         }
     }
     ex.SetCellValue(linename,9, 9);
     //string fzlinename = "";
     //if (obj.fzlinename.Contains("支"))
     //{
     //    fzlinename = obj.fzlinename.Substring(0, obj.fzlinename.LastIndexOf("支"));
     //}
     //else
     //    fzlinename = obj.fzlinename;
     //ex.SetCellValue(fzlinename, 10, 10);
     ex.SetCellValue(obj.cqfw, 10, 4);
     ex.SetCellValue("'" + obj.gh, 9, 12);
     ex.SetCellValue(obj.cqdw+"。", 12, 4);
     ex.SetCellValue(obj.jf, 11, 4);
     ex.SetCellValue(obj.qxydd, 15, 8);
     ex.SetCellValue(obj.qdrq.Year.ToString(), 21, 11);
     ex.SetCellValue(obj.qdrq.Month.ToString(), 21, 13);
     ex.SetCellValue(obj.qdrq.Day.ToString(), 21, 16);
     ex.ShowExcel();
 }
Ejemplo n.º 13
0
        public void ExportExcelMonth(string orgid)
        {
            //lgm
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\客户电力电容器台帐.xls";
            ex.Open(fname);
           
            ex.ShowExcel();

        }
Ejemplo n.º 14
0
 /// <summary>
 /// 文档格式预定义好的,只填写内容
 /// </summary>
 /// <param name="obj"></param>
 public  void ExportExcel(IList<PJ_sdytz> datalist)
 {
     //lgm
     ExcelAccess ex = new ExcelAccess();
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     string fname = Application.StartupPath + "\\00记录模板\\双电源台账.xls";
     ex.Open(fname);
     ExportExcel(ex, datalist);
     ex.ShowExcel();
    
 }
Ejemplo n.º 15
0
 /// <summary>
 /// 文档格式预定义好的,只填写内容
 /// </summary>
 /// <param name="obj"></param>
 public  void ExportExcel(IList<PJ_21dyjcdcbkchild> datalist)
 {
     //lgm
     ExcelAccess ex = new ExcelAccess();
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     string fname = Application.StartupPath + "\\00记录模板\\电压检测点抄表卡.xls";
     ex.Open(fname);
     ExportExcel(ex, datalist);
     ex.ShowExcel();
    
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 文档格式预定义好的,只填写内容
 /// </summary>
 /// <param name="obj"></param>
 public  void ExportExcel(IList<PJ_tdjh> datalist)
 {
     //lgm
     ExcelAccess ex = new ExcelAccess();
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     string fname = Application.StartupPath + "\\00记录模板\\所月度停电计划.xls";
     ex.Open(fname);
     ExportExcel(DateTime.Now, ex, datalist);
     ex.ShowExcel();
    
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 文档格式预定义好的,只填写内容
 /// </summary>
 /// <param name="obj"></param>
 public void ExportExcel(IList<PJ_clcrkd> datalist)
 {
     //lgm
     ExcelAccess ex = new ExcelAccess();
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     string fname = Application.StartupPath + "\\00记录模板\\生产台账.xls";
     ex.Open(fname);
     ExportExcel(ex, datalist, "生产物资管理生产台账");
     
     ex.DeleteSheet(1);
     ex.ShowExcel();
    
 }
Ejemplo n.º 18
0
        public void ExportExcelCunJian(string orgid)
        {

            
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\供电所春秋查停电检修计划.xls";
            ex.Open(fname);
            string startmonth = "3", startday= "1", endmonth = "5", endtday = "31";
            IList list = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr",
                string.Format("select nr  from pj_dyk where  dx='供电所春秋查停电检修计划' and sx like '%{0}%' and nr!=''", "春查停电检修开始日期"));
            if (list.Count > 0)
            {

                Regex r1 = new Regex(@"[0-9]+(?=月)");
                if(r1.Match(list[0].ToString()).Value!="")
                {
                    startmonth = r1.Match(list[0].ToString()).Value;
                }
                r1 = new Regex(@"(?<=月)[0-9]+");
                if (r1.Match(list[0].ToString()).Value != "")
                {
                    startday = r1.Match(list[0].ToString()).Value;
                }
            }
            list = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr",
               string.Format("select nr  from pj_dyk where  dx='供电所春秋查停电检修计划' and sx like '%{0}%' and nr!=''", "春查停电检修截止日期"));
            if (list.Count > 0)
            {

                Regex r1 = new Regex(@"[0-9]+(?=月)");
                if (r1.Match(list[0].ToString()).Value != "")
                {
                    endmonth = r1.Match(list[0].ToString()).Value;
                }
                r1 = new Regex(@"(?<=月)[0-9]+");
                if (r1.Match(list[0].ToString()).Value != "")
                {
                    endtday = r1.Match(list[0].ToString()).Value;
                }
            }
            string str = " where 1=1 and  TDtime between '" + DateTime.Now.Year + "-" + startmonth + "-" + startday + " 00:00:00' and  cast('"
                + DateTime.Now.Year + "-" + endmonth + "-" + endtday + " 23:59:59' as datetime) ";
            if (orgid != "") str += " and OrgCode='" + orgid + "' ";
            IList<PJ_cqctdjxjh> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_cqctdjxjh>(
               str
                );
            ExportExcel(ex, datalist);
            ex.ShowExcel();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
        public void ExportExcel(string orgid) {
            //lgm
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\设备标志缺失变更明细表二.xls";
            ex.Open(fname);
            string filter = "where 1=1 ";
            if (orgid != "") filter += " and OrgCode='" + orgid + "'";
            IList<PJ_sbbzqsbgmxb2> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_sbbzqsbgmxb2>(
             filter

               );
            ExportExcel(ex, datalist, orgid);
            ex.ShowExcel();
        }
Ejemplo n.º 20
0
 /// <summary>
 /// 文档格式预定义好的,只填写内容
 /// </summary>
 /// <param name="obj"></param>
 public static void ExportExcel(PJ_23 obj)
 {
     ExcelAccess ex = new ExcelAccess();
     string fname = Application.StartupPath + "\\00记录模板\\23配电线路产权维护范围协议书.xls";
     if (obj.BigData != null && obj.BigData.Length > 10) {
         fname = Path.GetTempPath() + "23配电线路产权维护范围协议书.xls";
         //MemoryStream ms = new MemoryStream(obj.BigData);
         FileStream fs = new FileStream(fname, FileMode.OpenOrCreate);
         fs.Write(obj.BigData, 0, obj.BigData.Length);
         fs.Flush();
         fs.Close();
     }
     ex.Open(fname);
     ExportExcel(obj, ex);
     ex.ShowExcel();
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 文档格式预定义好的,只填写内容
 /// </summary>
 /// <param name="obj"></param>
 public void ExportExcel(string orgid)
 {
     //lgm
     ExcelAccess ex = new ExcelAccess();
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     string fname = Application.StartupPath + "\\00记录模板\\电压监测装置设置台帐.xls";
     ex.Open(fname);
    
         IList<PJ_dyjczzsztz> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_dyjczzsztz>(
            " where OrgCode='" + orgid + "' order by id"
            );
         ExportExcel(ex, datalist);
     
    
     ex.ShowExcel();
    
 }
Ejemplo n.º 22
0
        /// <summary>
        /// 根据入库单id,导出入库单
        /// </summary>
        /// <param name="rkid"></param>
        internal static void ExportRK(string rkid) {
            ExcelAccess ea = new ExcelAccess();
            string filename=AppDomain.CurrentDomain.BaseDirectory+"\\00记录模板\\.xls";
            if (!File.Exists(filename))
            {
                //导出资源文件到本机
                Stream obj = typeof(PrintHelper).Assembly.GetManifestResourceStream("Ebada.Kcgl._00记录模板..xls");
                object[] files = typeof(PrintHelper).Assembly.GetManifestResourceNames();
                if (obj != null) {
                    byte[] buff = new byte[obj.Length];
                    obj.Read(buff, 0, (int)obj.Length);

                    FileStream fs = new FileStream(filename, FileMode.OpenOrCreate);
                    fs.Write(buff, 0, buff.Length);
                    fs.Flush();
                    fs.Close();
                    fs.Dispose();
                }
                
            }
            ea.Open(filename);

            JH_yearks rkobj=Client.ClientHelper.TransportSqlMap.GetOneByKey<JH_yearks>(rkid);
            if(rkobj==null)return;
            
            int brow = 5;
            int bcol = 2;
            //填充数据
            //for (int i = 0; i < list.Count; i++) {
            //    var obj = list[i];
            //    ea.SetCellValue((i+1).ToString(), i + brow, bcol-1);
            //    ea.SetCellValue(kcname, i + brow, bcol);
            //    ea.SetCellValue(obj.供货厂家, i + brow, bcol + 1);
            //    ea.SetCellValue(obj.材料名称, i + brow, bcol + 2);
            //    ea.SetCellValue(obj.规格及型号, i + brow, bcol + 3);
            //    ea.SetCellValue(obj.计量单位, i + brow, bcol + 4);
            //    ea.SetCellValue(obj.数量.ToString(), i + brow, bcol + 5);
            //    ea.SetCellValue(obj.备注, i + brow, bcol + 6);
            //}

            //显示文件
            ea.Print();
            ea.DisPoseExcel();
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
        public static void ExportExcel(PJ_24 jl)
        {
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\24设备变更通知书.xls";

            ex.Open(fname);
            int row = 1;
            int col = 1;
            //
            ex.SetCellValue(jl.sj.Year.ToString(), row + 8, col);
            ex.SetCellValue(jl.sj.Month.ToString(), row + 8, col+2);
            ex.SetCellValue(jl.sj.Day.ToString(), row + 8, col+4);
            ex.SetCellValue(jl.dd, row + 5, col+6);
            ex.SetCellValue(jl.nr, row + 5, col + 7);
            ex.SetCellValue(jl.Remark, row + 5, col + 10);

            ex.ShowExcel();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
        public void ExportExcelProjectCKD(string orgid, string strNum)
        {
            ////lgm
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\供电所安全工器具出库单.xls";
            ex.Open(fname);
            string strfirst = "";
            string filter = "";
            string filter2 = "";
            string filter3 = "";
            string filter4 = "";
            if (strNum != "全部")
                filter = "  where 1=1 and num='" + strNum + "'  and type = '所安全工器具出库单' ";
            else
                filter = "  where 1=1  and type = '所安全工器具出库单' ";

            
                        if (isWorkflowCall)
                        {

                            filter = filter + " and id not in (select ModleRecordID from WF_ModleRecordWorkTaskIns where  WorkFlowId='"
                                + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "') "
                                    + " or id in  (select ModleRecordID from WF_ModleRecordWorkTaskIns where "
                                + "    RecordID='" + currRecord.ID + "') "
                                ;
                        }

                        IList<PJ_anqgjcrkd> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_anqgjcrkd>(
                         filter
                           );
                        ExportExcel(ex, datalist);



                        try
                        {
                            ex.DeleteSheet(1);
                        }
                        catch { }
            ex.ShowExcel();
        }
Ejemplo n.º 25
0
 /// <summary>
 /// 文档格式预定义好的,只填写内容
 /// </summary>
 /// <param name="obj"></param>
 public  void ExportExcel(string orgid)
 {
     //lgm
     ExcelAccess ex = new ExcelAccess();
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     string fname = Application.StartupPath + "\\00记录模板\\线路设备责任区划分明白表.xls";
     ex.Open(fname);
     string sdtrorg=" ";
     if (orgid != "")
     {
         
         sdtrorg += "  and OrgCode='" + orgid + "'";
     }
     bool iszero = true;
     IList mclist = ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct zrr  from PJ_xlsbzrqhfmbb where  1=1 " + sdtrorg);
     foreach (string mc in mclist)
     {
         string str = " where 1=1 and zrr='"+mc+"' ";
         if (orgid != "")
         {
             str += "  and OrgCode='" + orgid + "' ";
         }
         if (isWorkflowCall)
         {
             str = str + " and ( id in  (select ModleRecordID from WF_ModleRecordWorkTaskIns where "
                 + "    RecordID='" + currRecord.ID + "')) "
                 ;
         }
         IList<PJ_xlsbzrqhfmbb> datalist = Client.ClientHelper.PlatformSqlMap.GetListByWhere<PJ_xlsbzrqhfmbb>(
            str
             );
         if (datalist.Count > 0)
         {
             iszero = false;
             ExportExcel(ex, datalist, mc);
         }
     }
     if (!iszero) ex.DeleteSheet(1);
     ex.ShowExcel();
    
 }
Ejemplo n.º 26
0
        public static bool Save(BarcodeSample sample, TestResult technic, TestResult reality, string saveFilename, string templateFile)
        {
            ExcelAccess access = new ExcelAccess();

            access.Open(templateFile);
            access.IsVisibledExcel = true;
            access.FormCaption     = "商品条码符号检测数据";
            bool flag = false;

            access.SetCellText(2, "F", sample.SerialNumber);
            access.SetCellText(3, "F", sample.CustomerName);
            access.SetCellText(3, "Z", reality.BarcodeType);
            access.SetCellText(4, "F", sample.SampleName);
            access.SetCellText(4, "Z", sample.PrintFormat);
            access.SetCellText(6, "F", sample.CustomerContactPersoner);
            access.SetCellText(6, "N", sample.CustomerContactNumber);
            access.SetCellText(0x11, "J", "代办点" + sample.RegisterPoint);
            access.SetCellText(10, "J", technic.SymbolLevel);
            access.SetCellText(11, "J", technic.DecodingData);
            access.SetCellText(12, "J", "≥" + technic.LeftBlank);
            access.SetCellText(13, "J", "≥" + technic.RightBlank);
            access.SetCellText(14, "J", "≥" + technic.BarHeight.ToString());
            access.SetCellText(15, "J", technic.SizeOfZ);
            access.SetCellText(0x10, "J", technic.IsValidBarcode);
            access.SetCellText(10, "V", reality.SymbolLevel);
            access.SetCellText(11, "V", reality.DecodingData);
            access.SetCellText(12, "V", reality.LeftBlank);
            access.SetCellText(13, "V", reality.RightBlank);
            access.SetCellText(14, "V", reality.BarHeight.ToString());
            access.SetCellText(15, "V", reality.SizeOfZ.ToString());
            access.SetCellText(0x10, "V", reality.IsValidBarcode);
            access.SetCellText(6, "Z", reality.TestDate.ToString("yyyyMMdd"));
            if (access.SaveAs(saveFilename, false))
            {
                flag = true;
            }
            access.Close();
            return(flag);
        }
Ejemplo n.º 27
0
        public void ImportExcelMethodHandler(Object obj, ImportExcelArgs ev)
        {
            #region 实现...

            ExcelAccess excel = new ExcelAccess();
            excel.Open();

            excel.MergeCells(1, 1, 1, this._body.Cols);             //合并单元格写标题,并设置字体
            excel.SetFont(1, 1, 1, this._body.Cols, this._title.Font);
            excel.SetCellText(1, 1, 1, this._body.Cols, this._title.Text);

            //打印网格及网格线
            excel.SetCellText((System.Data.DataTable) this.DataSource, 3, 1, true);

            System.Windows.Forms.FileDialog fileDlg = new System.Windows.Forms.SaveFileDialog();
            fileDlg.AddExtension = true;
            fileDlg.DefaultExt   = ".xls";

            //fileDlg.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
            fileDlg.Title  = "保存到Excel文件";
            fileDlg.Filter = "Microsoft Office Excel 工作簿(*.xls)|*.xls|模板(*.xlt)|*.xlt";

            if (fileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (excel.SaveAs(fileDlg.FileName, true))
                {
                    System.Windows.Forms.MessageBox.Show("数据成功保存到Excel文件!", "GoldPrinter", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                }
            }

            fileDlg.Dispose();

            excel.Close();

            #endregion
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
        public static void ExportExcel(PJ_25 obj) {
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\25双自备电源协议书.xls";

            ex.Open(fname);
            //此处写填充内容代码

            IList<PJ_25zbdymx> list = Client.ClientHelper.PlatformSqlMap.GetList<PJ_25zbdymx>("where ParentID='" + obj.ID + "'and Type='发电机'");
            IList<PJ_25zbdymx> list1 = Client.ClientHelper.PlatformSqlMap.GetList<PJ_25zbdymx>("where ParentID='" + obj.ID + "'and Type='原动机'");

            ex.SetCellValue("甲 方:"+obj.jf, 4, 1);
            ex.SetCellValue("乙 方:" + obj.cqdw, 5, 1);
            ex.SetCellValue(obj.qdrq.Year.ToString(), 42, 6);
            ex.SetCellValue(obj.qdrq.Month.ToString(), 42, 8);
            ex.SetCellValue(obj.qdrq.Day.ToString(), 42, 10);
            for (int i = 0; i < list.Count; i++)
            {
                ex.SetCellValue(list[i].xh, 26 + i, 1);
                ex.SetCellValue(list[i].gl.ToString() + "/" + list[i].ts.ToString(), 26 + i, 2);
                ex.SetCellValue(list[i].dy.ToString(), 26 + i, 3);
                ex.SetCellValue(list[i].azrq.ToString("yyyy-MM-dd"), 26 + i, 4);
                ex.SetCellValue(list[i].sccj, 26 + i, 5);
            }
            for (int i = 0; i < list1.Count; i++)
            {
                ex.SetCellValue(list1[i].xh, 26 + i, 8);
                ex.SetCellValue(list1[i].gl.ToString() + "/" + list[i].ts.ToString(), 26 + i, 11);
                ex.SetCellValue(list1[i].dy.ToString(), 26 + i, 12);
                ex.SetCellValue(list1[i].azrq.ToString("yyyy-MM-dd"), 26 + i, 13);
                ex.SetCellValue(list1[i].sccj, 26 + i, 14);
            }
            ex.SetCellValue(obj.bszz, 30, 2);
            ex.SetCellValue(obj.fzcs, 31, 2);
            ex.ShowExcel();
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
      
        public static void ExportExcel(PS_tqbyq obj)
        {
            //lgm
            //页数
            int pagecount =1;
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\11配电变压器卡片.xls";
            ex.Open(fname);
            //此处写填充内容代码
            int row = 1;
            string strwhere1=" where byqID='"+obj.byqID+"'";
            IList<PJ_11byqbd> pjbdlist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_11byqbd>("SelectPJ_11byqbdList", strwhere1);
            IList<PJ_11byqdydl> pjdydllist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_11byqdydl>("SelectPJ_11byqdydlList", strwhere1);
            IList<PJ_11byqdzcl> pjdzcllist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_11byqdzcl>("SelectPJ_11byqdzclList", strwhere1);
            if (pjbdlist.Count == 0) {
                pjbdlist.Add(new PJ_11byqbd() { azrq = obj.byqInstallDate, azdd = obj.byqInstallAdress });
            }
           //计算页数
            int byqhdpage = Ecommon.GetPagecount(pjbdlist.Count, 3);
            if (byqhdpage > pagecount)
            {
                pagecount = byqhdpage;
            }
            int byqdypage = Ecommon.GetPagecount(pjdydllist.Count, 22);
            if (byqdypage > pagecount)
            {
                pagecount = byqdypage;
            }
            int byqdzpage  = Ecommon.GetPagecount(pjdzcllist.Count, 9);
            if (byqdzpage > pagecount)
            {
                pagecount = byqdzpage;
            }
            //复制空模版
            if (pagecount>1)
            {
                for (int i = 1; i < pagecount; i++)
                {
                    ex.CopySheet(1, i);
                    ex.ReNameWorkSheet(i + 1, "Sheet" + (i + 1));
                }
            }

            PS_tq temptq = Client.ClientHelper.PlatformSqlMap.GetOneByKey<PS_tq>(obj.tqID);
            //固定内容
            ex.ActiveSheet(1);
            //变压器内容
            row = 4;
            ex.SetCellValue(obj.byqModle, row, 4);
            ex.SetCellValue(obj.byqFactory, row, 14);
            ex.SetCellValue(obj.byqVolOne + "KV", row, 23);
            row++;
            ex.SetCellValue(obj.byqPhase, row, 4);
            ex.SetCellValue(obj.byqNumber, row, 14);
            ex.SetCellValue(obj.byqVolTwo + "KV", row, 23);
            row++;//6
            ex.SetCellValue(obj.byqCapcity.ToString(), row, 4);
            ex.SetCellValue(obj.byqMadeDate.Year.ToString(), row, 14);
            ex.SetCellValue(obj.byqMadeDate.Month.ToString(), row, 16);
            ex.SetCellValue(obj.byqMadeDate.Day.ToString(), row, 18);
            ex.SetCellValue(obj.byqCurrentOne.ToString(), row, 23);

            row += 2;//8
            ex.SetCellValue(obj.byqLineGroup, row, 4);
            ex.SetCellValue(obj.byqCycle, row, 14);
            ex.SetCellValue(obj.byqCurrentTwo.ToString(), row, 23);

            //活动页

            //标题 
            ex.SetCellValue("配电变压器卡片(" + temptq.tqName + ")", 2, 1);

            
            for (int k = 0; k < pagecount; k++)
            {
               
                ex.ActiveSheet(k + 1);
                //标题 
                ex.SetCellValue("配电变压器卡片(" + temptq.tqName + ")", 2, 1);


                //变压器变动内容
                row = 12;
                for (int i = 0; i < 3; i++)
                {
                    if (k * 3 + i >= pjbdlist.Count)
                    {
                        break;
                    }
                    PJ_11byqbd tempobj = pjbdlist[k * 3 + i];
                    ex.SetCellValue(tempobj.azrq.Year.ToString(), row + i, 1);
                    ex.SetCellValue(tempobj.azrq.Month.ToString(), row + i, 3);
                    ex.SetCellValue(tempobj.azrq.Day.ToString(), row + i, 5);

                    ex.SetCellValue(tempobj.azdd, row + i, 7);
                    if (tempobj.ccrq.Year != 1900) {
                        ex.SetCellValue(tempobj.ccrq.Year.ToString(), row + i, 14);
                        ex.SetCellValue(tempobj.ccrq.Month.ToString(), row + i, 16);
                        ex.SetCellValue(tempobj.ccrq.Day.ToString(), row + i, 18);

                        ex.SetCellValue(tempobj.ccyy, row + i, 20);
                    }
                }

                //电压电流内容
                row = 6;
                for (int j = 0; j < 22; j++)
                {
                    if (k * 22 + j >= pjdydllist.Count)
                    {
                        break;
                    }
                    PJ_11byqdydl tempobj = pjdydllist[k * 22 + j];
                    ex.SetCellValue(tempobj.clrq.Year.ToString(), row + j, 26);
                    ex.SetCellValue(tempobj.clrq.Month.ToString(), row + j, 28);
                    ex.SetCellValue(tempobj.clrq.Day.ToString(), row + j, 30);

                    ex.SetCellValue(tempobj.fjtwz, row + j, 32);
                    ex.SetCellValue(tempobj.ao.ToString(), row + j, 33);
                    ex.SetCellValue(tempobj.bo.ToString(), row + j, 34);
                    ex.SetCellValue(tempobj.co.ToString(), row + j, 35);

                    ex.SetCellValue(tempobj.a.ToString(), row + j, 36);
                    ex.SetCellValue(tempobj.b.ToString(), row + j, 37);
                    ex.SetCellValue(tempobj.c.ToString(), row + j, 38);

                    ex.SetCellValue(tempobj.ao2.ToString(), row + j, 39);
                    ex.SetCellValue(tempobj.bo2.ToString(), row + j, 40);
                    ex.SetCellValue(tempobj.co2.ToString(), row + j, 41);   
                  
                }
                //绝缘电阻测量内容
                row = 16;
                for (int l = 0; l < 9; l++)
                {
                    if (k*9+l>=pjdzcllist.Count)
                    {
                        break;
                    }
                    if (l % 3 == 0 && l > 0)
                    {
                        row = 16 - l;
                    }
                    PJ_11byqdzcl tempobj = pjdzcllist[k * 9 + l];
                    if (l < 3)
                    {
                        ex.SetCellValue(tempobj.clrq.Year.ToString(), row + l, 7);
                        ex.SetCellValue(tempobj.clrq.Month.ToString(), row + l, 10);
                        ex.SetCellValue(tempobj.clrq.Day.ToString(), row + l, 12);
                        ex.SetCellValue(tempobj.one2one.ToString(), row + l + 1, 7);
                        ex.SetCellValue(tempobj.one2d.ToString(), row + l + 2, 7);
                        ex.SetCellValue(tempobj.two2d.ToString(), row + l + 3, 7);
                        row++;
                    }
                    else if (3 <= l && l < 6)
                    {
                        ex.SetCellValue(tempobj.clrq.Year.ToString(), row + l, 14);
                        ex.SetCellValue(tempobj.clrq.Month.ToString(), row + l, 16);
                        ex.SetCellValue(tempobj.clrq.Day.ToString(), row + l, 18);
                        ex.SetCellValue(tempobj.one2one.ToString(), row + l + 1, 14);
                        ex.SetCellValue(tempobj.one2d.ToString(), row + l + 2, 14);
                        ex.SetCellValue(tempobj.two2d.ToString(), row + l + 3, 14);
                        row++;
                    }
                    else if (6 <= l && l < 9)
                    {
                        ex.SetCellValue(tempobj.clrq.Year.ToString(), row + l, 20);
                        ex.SetCellValue(tempobj.clrq.Month.ToString(), row + l, 22);
                        ex.SetCellValue(tempobj.clrq.Day.ToString(), row + l, 24);
                        ex.SetCellValue(tempobj.one2one.ToString(), row + l + 1, 20);
                        ex.SetCellValue(tempobj.one2d.ToString(), row + l + 2, 20);
                        ex.SetCellValue(tempobj.two2d.ToString(), row + l + 3, 20);
                        row++;

                    }

                }

            }
            //设第一工作表为当前工作表
            ex.ActiveSheet(1);
           ex.ShowExcel();
        }
Ejemplo n.º 30
0
        private void btView_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (gridView1.FocusedRowHandle > -1)
            {
                PJ_24 OBJECT = gridView1.GetRow(gridView1.FocusedRowHandle) as PJ_24;
                if (OBJECT.BigData != null)
                {
                    if (OBJECT.BigData.Length != 0)
                    {
                        DSOFramerControl ds1 = new DSOFramerControl();
                        ds1.FileData = OBJECT.BigData;
                        string fname = ds1.FileName;
                        ds1.FileClose();
                        // ds1.FileOpen(ds1.FileName);
                        ExcelAccess ex = new ExcelAccess();


                        ex.Open(fname);
                        //此处写填充内容代码

                        ex.ShowExcel();
                    }
                    else
                    {
                        Export24.ExportExcel(OBJECT);
                    }

                }
                else
                {
                    Export24.ExportExcel(OBJECT);
                }
            }
        }
Ejemplo n.º 31
0
        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
        public static void ExportExcel(IList<PJ_21gzbxdh> objlist)
        {
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\21电力故障电话接听记录.xls";

            ex.Open(fname);
            //此处写填充内容代码
            int rowcount = 7;
            //加页
            int pageindex = 1;
            if (pageindex < Ecommon.GetPagecount(objlist.Count, 19))
            {
                pageindex = Ecommon.GetPagecount(objlist.Count, 19);
            }
            for (int j = 1; j <= pageindex; j++)
            {
                if (j > 1)
                {
                    ex.CopySheet(1, 1);
                }
            }
            ex.ShowExcel();
            for (int j = 1; j <= pageindex; j++)
            {

                ex.ActiveSheet(j);
                ex.ReNameWorkSheet(j, "Sheet" + (j));
                int prepageindex = j - 1;
                //主题
                int starow = prepageindex * 19 + 1;
                int endrow = j * 19;
                if (objlist.Count > endrow)
                {
                    for (int i = 0; i < 19; i++)
                    {


                        ex.SetCellValue(objlist[starow - 1 + i].rq.Month.ToString(), rowcount + i, 1);
                        ex.SetCellValue(objlist[starow - 1 + i].rq.Day.ToString(), rowcount + i, 2);
                        ex.SetCellValue(objlist[starow - 1 + i].rq.Hour.ToString(), rowcount + i, 3);
                        ex.SetCellValue(objlist[starow - 1 + i].rq.Minute.ToString(), rowcount + i, 4);
                        ex.SetCellValue(objlist[starow - 1 + i].lxfs, rowcount + i, 5);
                        ex.SetCellValue(objlist[starow - 1 + i].yhdz, rowcount + i, 6);
                        ex.SetCellValue(objlist[starow - 1 + i].gzjk, rowcount + i, 9);
        //                ex.SetCellValue(objlist[starow - 1 + i].djr, rowcount + i,12);
        //                ex.SetCellValue(objlist[starow - 1 + i].clr, rowcount + i, 13);

                    }
                }
                else if (objlist.Count <= endrow && objlist.Count >= starow)
                {
                    for (int i = 0; i < objlist.Count - starow + 1; i++)
                    {
                        ex.SetCellValue(objlist[starow - 1 + i].rq.Month.ToString(), rowcount + i, 1);
                        ex.SetCellValue(objlist[starow - 1 + i].rq.Day.ToString(), rowcount + i, 2);
                        ex.SetCellValue(objlist[starow - 1 + i].rq.Hour.ToString(), rowcount + i, 3);
                        ex.SetCellValue(objlist[starow - 1 + i].rq.Minute.ToString(), rowcount + i, 4);
                        ex.SetCellValue(objlist[starow - 1 + i].lxfs, rowcount + i, 5);
                        ex.SetCellValue(objlist[starow - 1 + i].yhdz, rowcount + i, 6);
                        ex.SetCellValue(objlist[starow - 1 + i].gzjk, rowcount + i, 9);
          //              ex.SetCellValue(objlist[starow - 1 + i].djr, rowcount + i, 12);
          //              ex.SetCellValue(objlist[starow - 1 + i].clr, rowcount + i, 13);

                    }
                }
            }
            ex.ActiveSheet(1);
             string orgname="";
            if (objlist.Count>0)
            {
                orgname = objlist[0].OrgName;
            }
         
            //变电所内容
            ex.SetCellValue(orgname, 4, 5);
           
            //记录
            //for (int i = 0; i < objlist.Count;i++ )
            //{
            //    ex.SetCellValue(objlist[i].rq.Month.ToString(), rowcount + i, 1);
            //    ex.SetCellValue(objlist[i].rq.Day.ToString(), rowcount + i, 2);
            //    ex.SetCellValue(objlist[i].rq.Hour.ToString(), rowcount + i, 3);
            //    ex.SetCellValue(objlist[i].rq.Minute.ToString(), rowcount + i, 4);
            //    ex.SetCellValue(objlist[i].lxfs, rowcount + i, 5);
            //    ex.SetCellValue(objlist[i].yhdz, rowcount + i, 6);
            //    ex.SetCellValue(objlist[i].gzjk, rowcount + i, 7);
            //    ex.SetCellValue(objlist[i].djr, rowcount + i,8);
            //    ex.SetCellValue(objlist[i].clr, rowcount + i,9);
            //}
            ex.ShowExcel();
        }
Ejemplo n.º 32
0
 /// <summary>
 /// 文档格式预定义好的,只填写内容
 /// </summary>
 /// <param name="obj"></param>
 public static void ExportExcel(IList<sdjl_07jdzz> objlist) {
     ExcelAccess ex = new ExcelAccess();
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
     string fname = Application.StartupPath + "\\00记录模板\\送电08接地装置检测.xls";
     ex.Open(fname);
     //此处写填充内容代码
     int rowcount = 6;
     //加页
     int pageindex = 1;
     if (pageindex < Ecommon.GetPagecount(objlist.Count, 16))
     {
         pageindex = Ecommon.GetPagecount(objlist.Count, 16);
     }
     for (int j = 1; j <= pageindex; j++)
     {
         ex.SetCellValue(objlist[0].LineName, 4, 3);
         if (j > 1)
         {
             ex.CopySheet(1, 1);
         }
     }
     for (int j = 1; j <= pageindex; j++)
     {
         ex.ActiveSheet(j);
         ex.ReNameWorkSheet(j, "Sheet" + (j));
         int prepageindex = j - 1;
         //主题
         int starow = prepageindex * 16 + 1;
         int endrow = j * 16;
         if (objlist.Count > endrow)
         {
             for (int i = 0; i < 16; i++)
             {
                 ex.SetCellValue(objlist[starow - 1 + i].gth, rowcount + 1 + i, 1);
                 ex.SetCellValue(objlist[starow - 1 + i].gzwz, rowcount + 1 + i, 2);
                 ex.SetCellValue(objlist[starow - 1 + i].sbmc, rowcount + 1 + i, 3);
                 ex.SetCellValue(objlist[starow - 1 + i].jddz.ToString(), rowcount + 1 + i, 4);
                 ex.SetCellValue(objlist[starow - 1 + i].CreateDate.Year.ToString(), rowcount + 1 + i, 5);
                 ex.SetCellValue(objlist[starow - 1 + i].CreateDate.Month.ToString(), rowcount + 1 + i, 6);
                 ex.SetCellValue(objlist[starow - 1 + i].CreateDate.Day.ToString(), rowcount + 1 + i, 7);
                 ex.SetCellValue(objlist[starow - 1 + i].trdzr.ToString(), rowcount + 1 + i, 8);
                 ex.SetCellValue(objlist[starow - 1 + i].tz.ToString(), rowcount + 1 + i, 9);
                 ex.SetCellValue(objlist[starow - 1 + i].xhgg, rowcount + 1 + i, 10);
                 ex.SetCellValue(objlist[starow - 1 + i].fzxl, rowcount + 1 + i, 11);
                 ex.SetCellValue(objlist[starow - 1 + i].CreateMan, rowcount + 1 + i, 12);
             }
         }
         else if (objlist.Count <= endrow && objlist.Count >= starow)
         {
             for (int i = 0; i < objlist.Count - starow + 1; i++)
             {
                 ex.SetCellValue(objlist[starow - 1 + i].gth, rowcount + 1 + i, 1);
                 ex.SetCellValue(objlist[starow - 1 + i].gzwz, rowcount + 1 + i, 2);
                 ex.SetCellValue(objlist[starow - 1 + i].sbmc, rowcount + 1 + i, 3);
                 ex.SetCellValue(objlist[starow - 1 + i].jddz.ToString(), rowcount + 1 + i, 4);
                 ex.SetCellValue(objlist[starow - 1 + i].CreateDate.Year.ToString(), rowcount + 1 + i, 5);
                 ex.SetCellValue(objlist[starow - 1 + i].CreateDate.Month.ToString(), rowcount + 1 + i, 6);
                 ex.SetCellValue(objlist[starow - 1 + i].CreateDate.Day.ToString(), rowcount + 1 + i, 7);
                 ex.SetCellValue(objlist[starow - 1 + i].trdzr.ToString(), rowcount + 1 + i, 8);
                 ex.SetCellValue(objlist[starow - 1 + i].tz.ToString(), rowcount + 1 + i, 9);
                 ex.SetCellValue(objlist[starow - 1 + i].xhgg, rowcount + 1 + i, 10);
                 ex.SetCellValue(objlist[starow - 1 + i].fzxl, rowcount + 1 + i, 11);
                 ex.SetCellValue(objlist[starow - 1 + i].CreateMan, rowcount + 1 + i, 12);
                 //ex.SetCellValue(objlist[starow - 1 + i].Remark, rowcount + i, 10);
             }
         }
     }
    ex.ActiveSheet(1);
    ex.ShowExcel();
 }
Ejemplo n.º 33
0
        /// <summary>
        /// 文档格式预定义好的,动态填写内容
        /// </summary>
        /// <param name="obj"></param>
        public static void ExportExceldt(string obj)
        {
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\10配电变压器汇总表.xls";
            ex.Open(fname );
            IList list=new  ArrayList ();
            int pagecount=0;
            //obj = "317";
            string strfilter = " and 1=1";
            if (obj != "") strfilter = strfilter + " and a.OrgCode='" + obj+"' ";
            IList caplist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneInt", "select distinct  b.byqCapcity    from dbo.mOrg a,dbo.PS_tqbyq b,dbo.PS_xl c, dbo.PS_tq d where a.OrgCode=c.OrgCode and c.LineCode=d.xlCode and d.tqID=b.tqID  " + strfilter + " order by b.byqCapcity");
            //caplist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", string.Format("select nr from pj_dyk where  len(parentid)>1 and dx='{0}' and sx='{1}'", "11配电变压器卡片", "容量"));
            //IList modmflist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct  UPPER(replace(b.byqModle,'-'+cast(b.byqCapcity as nvarchar(50))+'/'+cast(b.byqVol  as nvarchar(50)),'')) from dbo.mOrg a,dbo.PS_tqbyq b,dbo.PS_xl c, dbo.PS_tq d where a.OrgCode=c.OrgCode and c.LineCode=d.xlCode and d.tqID=b.tqID   " + strfilter + " and b.omniseal='true'");
            //IList modtmlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct  UPPER(replace(b.byqModle,'-'+cast(b.byqCapcity as nvarchar(50))+'/'+cast(b.byqVol  as nvarchar(50)),'')) from dbo.mOrg a,dbo.PS_tqbyq b,dbo.PS_xl c, dbo.PS_tq d where a.OrgCode=c.OrgCode and c.LineCode=d.xlCode and d.tqID=b.tqID   " + strfilter + " and (b.omniseal!='true' or b.omniseal is null)");
            IList modmflist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct  UPPER(b.byqModle) from dbo.mOrg a,dbo.PS_tqbyq b,dbo.PS_xl c, dbo.PS_tq d where a.OrgCode=c.OrgCode and c.LineCode=d.xlCode and d.tqID=b.tqID   " + strfilter + " and b.omniseal='true'");
            IList modtmlist = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select distinct  UPPER(b.byqModle) from dbo.mOrg a,dbo.PS_tqbyq b,dbo.PS_xl c, dbo.PS_tq d where a.OrgCode=c.OrgCode and c.LineCode=d.xlCode and d.tqID=b.tqID   " + strfilter + " and (b.omniseal!='true' or b.omniseal is null)");
            int jmax = 18;
            int i = 0;
            for ( i = 0; i < modmflist.Count; i++)
            {
                if (modmflist[i].ToString().IndexOf("-")>-1)
                {
                    modmflist[i] = modmflist[i].ToString().Substring(0,modmflist[i].ToString().IndexOf("-"));
                }
            }
            for (i = 0; i < modtmlist.Count; i++)
            {
                if (modtmlist[i].ToString().IndexOf("-")>-1)
                {
                    modtmlist[i] = modtmlist[i].ToString().Substring(0, modtmlist[i].ToString().IndexOf("-"));
                }
            }
            string modtemp = "";
            for (i = 0; i < modmflist.Count; i++)
            {
                if (modtemp.IndexOf(modmflist[i].ToString())==-1)
                {
                    if (modtemp!="")
                        modtemp+=","+modmflist[i];
                    else
                        modtemp = modmflist[i].ToString();
                }
            }
            if (modtemp != "")
            {
                string[] strli = modtemp.Split(',');
                modmflist.Clear();
                
                for (i = 0; i < strli.Length; i++)
                {
                    modmflist.Add(strli[i]);
                }
            }
            for (i = 0; i < modtmlist.Count; i++)
            {
                if (modtemp.IndexOf(modtmlist[i].ToString()) == -1)
                {
                    if (modtemp!="")
                        modtemp += "," + modtmlist[i];
                    else
                        modtemp = modtmlist[i].ToString();
                }
            }
            if (modtemp != "")
            {
                string[] strli = modtemp.Split(',');
                modtmlist.Clear();
                for (i = 0; i < strli.Length; i++)
                {
                    modtmlist.Add(strli[i]);
                }
            }
                pagecount = (int)Math.Ceiling(caplist.Count / (jmax + 0.0));
            int itemp = modtmlist.Count / 6.0 > modmflist.Count / 3.0 ? (int)Math.Ceiling(modtmlist.Count / 6.0) : (int)Math.Ceiling(modmflist.Count / 3.0 );
            
            pagecount = itemp * pagecount;
            if (pagecount > 1)
            {
                ex.DeleteWorkSheet("Sheet2");
                ex.DeleteWorkSheet("Sheet3"); 
            }
            /////计算需要多少个工作表
            for (i = 1; i < pagecount; i++)
            {
               
               
                ex.CopySheet(1,i);
                ex.ReNameWorkSheet((i + 1), "Sheet" + (i + 1));
               
            }
            int istart = 7, istart2 = 19, jstart = 4, j=0;
            string jstrfilter="";
            mOrg org = Client.ClientHelper.PlatformSqlMap.GetOneByKey<mOrg>(obj);
            for ( j = 0; j < caplist.Count; j++)
            {
                ex.ActiveSheet("Sheet" + (j / jmax == 0 ? 1 : (int)Math.Ceiling(j / (jmax + 0.0))));
                //ex.ActiveSheet("Sheet" + (1 + (j / jmax) * (int)Math.Ceiling(j / (jmax + 0.0))));
                if (j % jmax == 0)
                {

                    jstrfilter = " and 1=1";
                    ex.ActiveSheet("Sheet" + (1+(j / jmax)*(int)Math.Ceiling(j / (jmax + 0.0))));
                    list = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneInt", "select   b.byqCapcity from dbo.mOrg a,dbo.PS_tqbyq b,dbo.PS_xl c, dbo.PS_tq d where a.OrgCode=c.OrgCode and c.LineCode=d.xlCode and d.tqID=b.tqID  " + strfilter + jstrfilter);
                    if (list.Count >0) ex.SetCellValue(list.Count.ToString(), 5, jstart + j % jmax);
                    list = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneInt", "select   sum(b.byqCapcity) from dbo.mOrg a,dbo.PS_tqbyq b,dbo.PS_xl c, dbo.PS_tq d where a.OrgCode=c.OrgCode and c.LineCode=d.xlCode and d.tqID=b.tqID    " + strfilter + jstrfilter);
                    //if (list[0] == null) list[0] = 0;
                    if (list[0] != null)
                    ex.SetCellValue(list[0].ToString(), 6, jstart + j % jmax);
                    setExceldt(ex, list, caplist, modtmlist, modmflist, jstrfilter, strfilter, jstart, j, jmax, istart, istart2);    
                }
                ex.ActiveSheet("Sheet" + ((j+1) / jmax == 0 ? 1 : (int)Math.Ceiling((j+1) / (jmax + 0.0))));
               
                    jstrfilter = " and 1=1 and b.byqCapcity='" + caplist[j] + "'";
                    //ex.SetCellValue(caplist[j].ToString(), 4, jstart + j % jmax + 1);
                    setExceldt(ex, list, caplist, modtmlist, modmflist, jstrfilter, strfilter, jstart+1, j, jmax, istart, istart2);    
                
               
            }
            for (i = 0; i < pagecount; i++)
            {
                ex.ActiveSheet("Sheet" + (i+1));
                int jzu=caplist.Count/jmax+1;
                int itempmin = 0, itempmax = 0;
                    itempmax = (i % jzu+1) * jmax;
                    itempmin = (i % jzu) * jmax;

                    if (org != null)
                        ex.SetCellValue(org.OrgName, 3, 3);
                    else
                        ex.SetCellValue("全局", 3, 3);

                for (j = itempmin; j < itempmax && j < caplist.Count ; j++)
                {
                    ex.SetCellValue(caplist[j].ToString(), 4, jstart + j % jmax + 1);
                
                }
                //ex.SetCellValue(caplist[j].ToString(), 4, jstart + j % jmax + 1);

            }
            ex.ActiveSheet(1);
            ex.ShowExcel();
        }