当前位置: 首页>>代码示例>>C#>>正文


C# ExcelAccess.ReNameWorkSheet方法代码示例

本文整理汇总了C#中ExcelAccess.ReNameWorkSheet方法的典型用法代码示例。如果您正苦于以下问题:C# ExcelAccess.ReNameWorkSheet方法的具体用法?C# ExcelAccess.ReNameWorkSheet怎么用?C# ExcelAccess.ReNameWorkSheet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExcelAccess的用法示例。


在下文中一共展示了ExcelAccess.ReNameWorkSheet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportExcel10KV

        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();
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:59,代码来源:Export12.cs

示例2: ExportExcel

        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
        public static void ExportExcel(PJ_02aqhd obj) {
            //lgm
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\02安全活动记录.xls";

            ex.Open(fname);
            //每行显示文字长度
            int zc = 58;
            //与会人员之间的间隔符号
            char[] jksign = new char[1] { ';' };
            int row = 1;
            int col = 1;

            //计算页码
            int pagecount = 1;
            //活动内容


            string hdstr = Ecommon.Comparestring(obj.hdnr, "活动内容") ? "" : "活动内容:";
            List<string> hdlist = Ecommon.ResultStrListByPage(hdstr, obj.hdnr, zc, 8);
            //if (Ecommon.GetPagecount(hdlist.Count, 8) > pagecount)
            //{
            //    pagecount = Ecommon.GetPagecount(hdlist.Count, 8);
            //}
            //活动小结
            string hdxjstr = Ecommon.Comparestring(obj.hdxj, "活动小结") ? "" : "活动小结:";
            List<string> hdxlist = Ecommon.ResultStrListByPage(hdxjstr, obj.hdxj, zc, 5);
            //if (Ecommon.GetPagecount(hdxlist.Count, 5) > pagecount)
            //{
            //    pagecount = Ecommon.GetPagecount(hdxlist.Count, 5);
            //}
            //发言简要记录
            //领导评语
            string ldpystr = Ecommon.Comparestring(obj.py, "领导检查评语") ? "" : "领导检查评语:";
            List<string> ldpylist = Ecommon.ResultStrListByPage(ldpystr, obj.py, zc, 2);
            if (Ecommon.GetPagecount(ldpylist.Count + hdxlist.Count + hdlist.Count, 15) > pagecount) {
                pagecount = Ecommon.GetPagecount(ldpylist.Count + hdxlist.Count + hdlist.Count, 15);
            }
            List<string> fyjyjllist = Ecommon.ResultStrListByPage("", obj.fyjyjl, zc, 21);
            if (Ecommon.GetPagecount(fyjyjllist.Count, 21) > pagecount) {
                pagecount = Ecommon.GetPagecount(fyjyjllist.Count, 21);
            }

            //复制空模版
            if (pagecount > 1) {
                for (int i = 1; i < pagecount; i++) {
                    ex.CopySheet(1, i);
                    ex.ReNameWorkSheet(i + 1, "Sheet" + (i + 1));
                }
            }

            for (int p = 0; p < pagecount; p++) {
                ex.ActiveSheet(p + 1);
                //改造后的
                for (int i = 0; i < 15; i++) {

                    if (p * 15 + i < hdlist.Count) {

                        string tempstr = hdlist[p * 15 + i];
                        ex.SetCellValue(tempstr, 10 + i, 1);
                        if (p == 0 && i == 0) {
                            //设定活动内容为粗体
                            ex.SetFontBold(10 + i, 1, 10 + i, 1, true, 0, 5);
                        }
                    }
                    if (p * 15 + i >= hdlist.Count && p * 15 + i < hdlist.Count + hdxlist.Count) {

                        string tempstr = hdxlist[p * 15 + i - hdlist.Count];
                        ex.SetCellValue(tempstr, 10 + i, 1);
                        if (p * 15 + i == hdlist.Count) {
                            ex.SetFontBold(10 + i, 1, 10 + i, 1, true, 0, 5);
                        }
                        //break;
                    }

                    if (p * 15 + i >= hdlist.Count + hdxlist.Count && p * 15 + i < hdlist.Count + hdxlist.Count + ldpylist.Count) {

                        string tempstr = ldpylist[p * 15 + i - hdlist.Count - hdxlist.Count];

                        ex.SetCellValue(tempstr, 10 + i, 1);
                        if (p * 15 + i == hdlist.Count + hdxlist.Count)
                            ex.SetFontBold(10 + i, 1, 10 + i, 1, true, 0, 7);
                        //break;
                    }
                    if (p * 15 + i >= hdlist.Count + hdxlist.Count + ldpylist.Count) {
                        break;
                    }
                }
                ////活动内容
                //for (int i = 0; i < 8; i++)
                //{
                //    if (p * 8 + i>=hdlist.Count)
                //    {
                //        break;
                //    }
//.........这里部分代码省略.........
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:101,代码来源:Export02.cs

示例3: CreatandWritesheet1

        /// <summary>
        ///创建工作表并将数据加入到工作表中
        /// </summary>
        /// <param name="ex">操作EXCEL表</param>
        /// <param name="bdzlist">填入的数据</param>
        ///  <param name="hs">一页对应的总行数</param>
        ///  <param name="stawz">一页中填入的开始的位置</param>
        ///  <param name="pageindex">一页填入的列位置</param>
        ///  <param name="strnumcol">第一个字符开始的行数</param>
        ///  <param name="boldnum">加粗的数量</param>
        public static void CreatandWritesheet1(ExcelAccess ex, List<string> bdzlist, int hs, int star, int clm,int[] strnumcol,int[] boldnum)
        {
            int pageindex = 1;
            if (pageindex < Ecommonjh.GetPagecount(bdzlist.Count, hs))
            {
                pageindex = Ecommonjh.GetPagecount(bdzlist.Count, hs);
            }
            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 * hs + 1;
                int endrow = j * hs;
                if (bdzlist.Count > endrow)
                {
                    for (int i = 0; i < hs; i++)
                    {

                        ex.SetCellValue(bdzlist[starow - 1 + i], star + i, clm);
                        //加粗过程
                        for (int n = 0; n < strnumcol.Length;n++ )
                        {
                            if (starow-1+i==strnumcol[n])
                            {
                                ex.SetFontBold(star + i, clm, star + i, clm, true, 0, boldnum[n]);
                            }
                          
                        }

                        //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, 7);
                        //ex.SetCellValue(objlist[starow - 1 + i].djr, rowcount + i, 8);
                        //ex.SetCellValue(objlist[starow - 1 + i].clr, rowcount + i, 9);

                    }
                }
                else if (bdzlist.Count <= endrow && bdzlist.Count >= starow)
                {
                    for (int i = 0; i < bdzlist.Count - starow + 1; i++)
                    {
                        ex.SetCellValue(bdzlist[starow - 1 + i], star + i, clm);
                        //加粗过程
                        for (int n = 0; n < strnumcol.Length; n++)
                        {
                            if (starow - 1 + i == strnumcol[n])
                            {
                                ex.SetFontBold(star + i, clm, star + i, clm, true, 0, boldnum[n]);
                            }

                        }

                        //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, 7);
                        //ex.SetCellValue(objlist[starow - 1 + i].djr, rowcount + i, 8);
                        //ex.SetCellValue(objlist[starow - 1 + i].clr, rowcount + i, 9);

                    }
                }
            }
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:92,代码来源:Ecommonjh.cs

示例4: ExportExcel

 /// <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();
 }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:74,代码来源:ExportSD08.cs

示例5: ExportExcel

        public void ExportExcel(ExcelAccess ex ,IList<PJ_clcrkd> datalist)
        {
            
            //此处写填充内容代码
            int row = 7;
            int col = 1;
            int rowcount = 10;

            //

            if (datalist.Count < 1) return;
            Regex r1 = new Regex("[0-9]+");
            string str = r1.Match(datalist[0].num).Value;
            if (str == "")
            {
                str = datalist[0].num;
            }
            string tablename = datalist[0].ssgc + datalist[0].ssxm + str;
            if (tablename.Length > 30)
            {
                tablename = tablename.Substring(tablename.Length - 31);
            }
            //加页
            int pageindex = 1;
            if (pageindex < Ecommon.GetPagecount(datalist.Count, rowcount))
            {
                pageindex = Ecommon.GetPagecount(datalist.Count, rowcount);
            }
            for (int j = 1; j <= pageindex; j++)
            {

                ex.CopySheet(1, j);
                if (j == 1) ex.ReNameWorkSheet(j + 1, tablename);
                else
                    ex.ReNameWorkSheet(j + 1, tablename + "(" + (j) + ")");
            }
            for (int j = 0; j < datalist.Count; j++)
            {

                if (j % rowcount == 0)
                {
                    if (j == 0) ex.ActiveSheet(tablename);
                    else ex.ActiveSheet(tablename + "(" + (j / rowcount + 1) + ")");
                    ex.SetCellValue(datalist[j].ssgc, 2, 3);
                    ex.SetCellValue(datalist[j].ssxm, 4, 2);
                    ex.SetCellValue(datalist[j].ckdate.ToString("yyyy"), 4, 7);
                    ex.SetCellValue(datalist[j].ckdate.ToString("MM"), 4, 9);
                    ex.SetCellValue(datalist[j].ckdate.ToString("dd"), 4, 11);

                    ex.SetCellValue(datalist[j].ssgc, 22, 3);
                    ex.SetCellValue(datalist[j].ssxm, 24, 2);
                    ex.SetCellValue(datalist[j].ckdate.ToString("yyyy"), 24, 7);
                    ex.SetCellValue(datalist[j].ckdate.ToString("MM"), 24, 9);
                    ex.SetCellValue(datalist[j].ckdate.ToString("dd"), 24, 11);

                    ex.SetCellValue(datalist[j].ssgc, 42, 3);
                    ex.SetCellValue(datalist[j].ssxm, 44, 2);
                    ex.SetCellValue(datalist[j].ckdate.ToString("yyyy"), 44, 7);
                    ex.SetCellValue(datalist[j].ckdate.ToString("MM"), 44, 9);
                    ex.SetCellValue(datalist[j].ckdate.ToString("dd"), 44, 11);

                    ex.SetCellValue(datalist[j].ssgc, 62, 3);
                    ex.SetCellValue(datalist[j].ssxm, 64, 2);
                    ex.SetCellValue(datalist[j].indate.ToString("yyyy"), 64, 7);
                    ex.SetCellValue(datalist[j].indate.ToString("MM"), 64, 9);
                    ex.SetCellValue(datalist[j].indate.ToString("dd"), 64, 11);
                }

                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount , col);
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount , col + 2);
                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount, col + 4);

                ex.SetCellValue(datalist[j].cksl, row + j % rowcount, col + 5);
                ex.SetCellValue(datalist[j].wpdj, row + j % rowcount , col + 7);

                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount+20, col);
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount + 20, col + 2);
                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount + 20, col + 4);

                ex.SetCellValue(datalist[j].cksl, row + j % rowcount + 20, col + 5);
                ex.SetCellValue(datalist[j].wpdj, row + j % rowcount + 20, col + 7);

                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount + 40, col);
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount + 40, col + 2);
                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount + 40, col + 4);
                ex.SetCellValue(datalist[j].cksl, row + j % rowcount + 40, col + 5);
                ex.SetCellValue(datalist[j].wpdj, row + j % rowcount + 40, col + 7);

                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount + 60, col);
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount + 60, col + 2);
                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount + 60, col + 4);
                ex.SetCellValue(datalist[j].cksl, row + j % rowcount + 60, col + 5);
                ex.SetCellValue(datalist[j].wpdj, row + j % rowcount + 60, col + 7);
                if (datalist[j].wpdj != "")
                {
                    long value = Convert.ToInt64(Math.Round(Convert.ToDouble(datalist[j].cksl) * Convert.ToDouble(datalist[j].wpdj), 2) * 100);
                    int index = 19;
                    while (value > 0)
                    {
                        long ifen = value % 10;
//.........这里部分代码省略.........
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:101,代码来源:ExportCJCLCKEdit.cs

示例6: ExportExcel

        public void ExportExcel(ExcelAccess ex, IList<PJ_clcrkd> datalist, string wpmc)
        {
            //此处写填充内容代码
            int row = 5;
            int col = 2;
            int rowcount = 18;

            //

            //加页
            int pageindex = 1;
            if (pageindex < Ecommon.GetPagecount(datalist.Count, rowcount))
            {
                pageindex = Ecommon.GetPagecount(datalist.Count, rowcount);
            }
            for (int j = 1; j <= pageindex; j++)
            {

                ex.CopySheet(1, j);
                if (j == 1) ex.ReNameWorkSheet(j + 1, wpmc);
                else
                    ex.ReNameWorkSheet(j + 1, wpmc + (j));
            }
            for (int j = 0; j < datalist.Count; j++)
            {

                if (j % rowcount == 0)
                {
                    if (j == 0) ex.ActiveSheet(wpmc);
                    else ex.ActiveSheet(wpmc + (j / rowcount + 1));

                }
                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount, col );
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount, col + 1);

                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount, col + 2);
                ex.SetCellValue(datalist[j].wpsl, row + j % rowcount, col + 3);
                ex.SetCellValue(datalist[j].wpdj, row + j % rowcount, col + 4);
                ex.SetCellValue(datalist[j].wpcj, row + j % rowcount, col + 5);
                ex.SetCellValue(datalist[j].indate.ToString("yyyy年MM月dd日"), row + j % rowcount, col + 6);
                ex.SetCellValue(datalist[j].ssgc, row + j % rowcount, col + 7);
                if(datalist[j].type.IndexOf ("入库单")==-1)
                ex.SetCellValue(datalist[j].ckdate.ToString("yyyy年MM月dd日"), row + j % rowcount, col + 8);
                ex.SetCellValue(datalist[j].yt, row + j % rowcount, col + 9);
                ex.SetCellValue(datalist[j].cksl, row + j % rowcount, col + 10);
                ex.SetCellValue(datalist[j].cksl, row + j % rowcount, col + 11);
                ex.SetCellValue(datalist[j].lqdw, row + j % rowcount, col + 12);
                //ex.SetCellValue(datalist[j].zrr, row + j % rowcount, col + 7);
                if (datalist[j].wpmc == "出库合计")
                {
                    return;
                }


            }
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:56,代码来源:ExportSCTZEdit.cs

示例7: ExportExcel

        public void ExportExcel(ExcelAccess ex ,IList<PJ_anqgjcrkd> datalist)
        {
            //此处写填充内容代码
            int row = 5;
            int col = 1;
            int rowcount = 41;

            //
            //加页
            int pageindex = 1;
            if (pageindex < Ecommon.GetPagecount(datalist.Count, rowcount))
            {
                pageindex = Ecommon.GetPagecount(datalist.Count, rowcount);
            }
            for (int j = 1; j <= pageindex; j++)
            {

                ex.CopySheet(1, j);
                if (j == 1)
                {

                    ex.ReNameWorkSheet(j + 1,   datalist[0].num);
                }
                else
                    ex.ReNameWorkSheet(j + 1, datalist[0].num+"(" + (j)+")");
            }
            for (int j = 0; j < datalist.Count; j++)
            {

                if (j % rowcount == 0)
                {
                    if (j == 0) ex.ActiveSheet( datalist[0].num);
                    else ex.ActiveSheet( datalist[0].num + "(" + (j / rowcount + 1)+")");
                    
                    ex.SetCellValue(datalist[j].indate.ToString("yyyy年MM月dd日"), 3, 2);
                    ex.SetCellValue(datalist[j].indate.ToString("yyyy年MM月dd日"), 3, 6);
                }
                ex.SetCellValue((j+1).ToString(), row + j % rowcount, col);
                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount, col+1 );
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount, col + 3);
                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount, col + 4);

                ex.SetCellValue(datalist[j].wpsl, row + j % rowcount, col + 5);
                ex.SetCellValue(datalist[j].wpdj, row + j % rowcount, col + 6);
                ex.SetCellValue((Convert.ToDouble(datalist[j].wpsl)*Convert.ToDouble(datalist[j].wpdj)).ToString()
                    , row + j % rowcount, col + 7);
                 
                //ex.SetCellValue(datalist[j].zrr, row + j % rowcount, col + 7);


            }
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:52,代码来源:ExportAQGJSRKEdit.cs

示例8: ExportExcel

        public void ExportExcel(ExcelAccess ex ,IList<PJ_anqgjcrkd> datalist)
        {
            
            //此处写填充内容代码
            int row = 4;
            int col = 1;
            int rowcount = 23;

            //

            //加页
            int pageindex = 1;
            if (pageindex < Ecommon.GetPagecount(datalist.Count, rowcount))
            {
                pageindex = Ecommon.GetPagecount(datalist.Count, rowcount);
            }
            for (int j = 1; j <= pageindex; j++)
            {

                ex.CopySheet(1, j);
                if (j == 1) ex.ReNameWorkSheet(j + 1,  datalist[0].num);
                else
                    ex.ReNameWorkSheet(j + 1, datalist[0].num + "(" + (j) + ")");
            }
            for (int j = 0; j < datalist.Count; j++)
            {

                if (j % rowcount == 0)
                {
                    if (j == 0) ex.ActiveSheet(datalist[0].num);
                    else ex.ActiveSheet( datalist[0].num + "(" + (j / rowcount + 1) + ")");
                    ex.SetCellValue(datalist[j].OrgName, 2, 2);

                    
                }

                ex.SetCellValue((j + 1).ToString(), row + j % rowcount, col);
                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount, col + 1);
                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount, col + 2);
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount, col + 3);

                ex.SetCellValue(datalist[j].cksl, row + j % rowcount, col + 4);
                ex.SetCellValue(datalist[j].lqdw, row + j % rowcount, col + 5);
                ex.SetCellValue(datalist[j].Remark, row + j % rowcount, col + 6);
                //ex.SetCellValue(datalist[j].zrr, row + j % rowcount, col + 7);


            }
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:49,代码来源:ExportAQGJSCKEdit.cs

示例9: ExportExcel

        public void ExportExcel(ExcelAccess ex, IList<PJ_anqgjcrkd> datalist, string wpmc)
        {
            //此处写填充内容代码
            int row = 4;
            int col = 2;
            int rowcount = 18;

            //

            //加页
            int pageindex = 1;
            if (pageindex < Ecommon.GetPagecount(datalist.Count, rowcount))
            {
                pageindex = Ecommon.GetPagecount(datalist.Count, rowcount);
            }
            for (int j = 1; j <= pageindex; j++)
            {

                ex.CopySheet(1, j);
                if (j == 1) ex.ReNameWorkSheet(j + 1, wpmc);
                else
                    ex.ReNameWorkSheet(j + 1, wpmc + (j));
            }
            for (int j = 0; j < datalist.Count; j++)
            {

                if (j % rowcount == 0)
                {
                    if (j == 0) ex.ActiveSheet(wpmc);
                    else ex.ActiveSheet(wpmc + (j / rowcount + 1));

                }
                ex.SetCellValue((j + 1).ToString(), row + j % rowcount, col);
                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount, col );
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount, col + 1);

                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount, col + 2);
                ex.SetCellValue(datalist[j].wpsl, row + j % rowcount, col + 3);
                ex.SetCellValue(datalist[j].wpsl, row + j % rowcount, col + 4);
                ex.SetCellValue(datalist[j].indate.ToString("yyyy年MM月dd日"), row + j % rowcount, col +5);
                ex.SetCellValue(datalist[j].cksl, row + j % rowcount, col + 6);
                ex.SetCellValue(datalist[j].ckdate.ToString("yyyy年MM月dd日"), row + j % rowcount, col + 7);
                ex.SetCellValue(datalist[j].OrgName, row + j % rowcount, col + 8);
                ex.SetCellValue(datalist[j].zkcsl, row + j % rowcount, col + 10);


            }
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:48,代码来源:ExportAQGJTZEdit.cs

示例10: ExportExcel

        public void ExportExcel(ExcelAccess ex, Object datalist, string orgid, string sheetname)
        {
            //此处写填充内容代码
            int row = 6;
            int col = 1;
            int rowcount = 15;
            int i = 0, sheetindex = 0;
            //
            Excel.Workbook wb = ex.MyWorkBook as Excel.Workbook;
            //加页
            int pageindex = 1;
            if (pageindex < Ecommon.GetPagecount(((IList)datalist).Count, rowcount))
            {
                pageindex = Ecommon.GetPagecount(((IList)datalist).Count, rowcount);
            }
            for (i = 1; i <= wb.Application.Worksheets.Count; i++)
            {
                Excel.Worksheet sheet = wb.Application.Worksheets[i] as Excel.Worksheet;
                if (sheet.Name == sheetname)
                {
                    sheetindex = sheet.Index;
                    break;
                }
            }
            int itemp = sheetindex;
            //for (int j = 1; j <pageindex; j++)
            //{

            //    ex.CopySheet(1, j);
               
            //}
            for (i = 1; i < pageindex; i++)
            {

                ex.CopySheet(sheetindex, itemp);
                ex.ReNameWorkSheet(itemp + 1, sheetname + (i + 1));
                itemp++;

            }
            for (int j = 0; j < ((IList)datalist).Count; j++)
            {

                if (j % rowcount == 0)
                {
                    if (j == 0) ex.ActiveSheet(sheetname);
                    else ex.ActiveSheet(sheetname+(j / rowcount + 1));

                    if (orgid != "")
                    {
                        if (datalist is IList<PJ_sbbzqsbgmxb1>)
                        {
                            ex.SetCellValue(((PJ_sbbzqsbgmxb1)((IList)datalist)[j]).OrgName, 4, 2);
                        }
                        else if (datalist is IList<PJ_sbbzqsbgmxb2>)
                        {
                            ex.SetCellValue(((PJ_sbbzqsbgmxb2)((IList)datalist)[j]).OrgName, 4, 2);
                        }
                        else if (datalist is IList<PJ_sbbzqsbgmxb3>)
                        {
                            ex.SetCellValue(((PJ_sbbzqsbgmxb3)((IList)datalist)[j]).OrgName, 4, 2);
                        }
                        else if (datalist is IList<PJ_sbbzqsbgmxb4>)
                        {
                            ex.SetCellValue(((PJ_sbbzqsbgmxb4)((IList)datalist)[j]).OrgName, 4, 2);
                        }
                        else if (datalist is IList<PJ_sbbzqsbgmxb5>)
                        {
                            ex.SetCellValue(((PJ_sbbzqsbgmxb5)((IList)datalist)[j]).OrgName, 4, 2);
                        }

                    }

                    else
                        ex.SetCellValue(MainHelper.UserCompany, 4, 2);
                  
                    ex.SetCellValue(DateTime.Now.ToString("yyyy年MM月dd日"), 4,5);

                }
                
                ex.SetCellValue((j + 1).ToString(), row + j % rowcount, col);
                if (datalist is IList<PJ_sbbzqsbgmxb1>)
                {

                    ex.SetCellValue(((PJ_sbbzqsbgmxb1)((IList)datalist)[j]).sssbmc, row + j % rowcount, col + 1);
                    ex.SetCellValue(((PJ_sbbzqsbgmxb1)((IList)datalist)[j]).sssswz, row + j % rowcount, col + 2);

                    ex.SetCellValue(((PJ_sbbzqsbgmxb1)((IList)datalist)[j]).sssbbh, row + j % rowcount, col + 3);
                    ex.SetCellValue(((PJ_sbbzqsbgmxb1)((IList)datalist)[j]).statuts, row + j % rowcount, col + 4);
                    ex.SetCellValue(((PJ_sbbzqsbgmxb1)((IList)datalist)[j]).Remark, row + j % rowcount, col + 5);
                }
                else
                    if (datalist is IList<PJ_sbbzqsbgmxb2>)
                    {

                        ex.SetCellValue(((PJ_sbbzqsbgmxb2)((IList)datalist)[j]).sssbmc, row + j % rowcount, col + 1);
                        ex.SetCellValue(((PJ_sbbzqsbgmxb2)((IList)datalist)[j]).sssswz, row + j % rowcount, col + 2);

                        ex.SetCellValue(((PJ_sbbzqsbgmxb2)((IList)datalist)[j]).sssbbh, row + j % rowcount, col + 3);
                        ex.SetCellValue(((PJ_sbbzqsbgmxb2)((IList)datalist)[j]).statuts, row + j % rowcount, col + 4);
                        ex.SetCellValue(((PJ_sbbzqsbgmxb2)((IList)datalist)[j]).Remark, row + j % rowcount, col + 5);
//.........这里部分代码省略.........
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:101,代码来源:ExportSBBZQSBGMXB1Edit.cs

示例11: ExportExcel

        public void ExportExcel(ExcelAccess ex, IList<PJ_xlsbzrqhfmbb> datalist, string wpmc)
        {
            //此处写填充内容代码
            int row = 5;
            int col = 1;
            int rowcount = 6;
            int rowspan = 8;


            //

            //加页
            int pageindex = 1;
            if (pageindex < Ecommon.GetPagecount(datalist.Count, rowcount))
            {
                pageindex = Ecommon.GetPagecount(datalist.Count, rowcount);
            }
            //for (int j = 1; j <= pageindex; j++)
            //{
            //    if (j > 1)
            //    {
            //        ex.CopySheet(1, 1);
            //    }
            //}
            Excel.Workbook wb = ex.MyWorkBook as Excel.Workbook;
            for (int j = 1; j <= pageindex; j++)
            {

                ex.CopySheet(1, wb.Application.Worksheets.Count);
                if (j == 1) ex.ReNameWorkSheet( wb.Application.Worksheets.Count, wpmc);
                else
                    ex.ReNameWorkSheet( wb.Application.Worksheets.Count, wpmc + (j));
            }
            //DateTime dt = DateTime.Now;
            //dt=dt.AddMonths(1);
            //ex.SetCellValue(dt.Year + "年" + (dt.Month) + "月份配电设备停电检修计划表", 1, 1);
        
            for (int j = 0; j < datalist.Count; j++)
            {

                if (j % rowcount == 0)
                {
                    if (j == 0) ex.ActiveSheet(wpmc);
                    else ex.ActiveSheet(wpmc + (j / rowcount + 1));
                    //ex.SetCellValue(datalist[j].OrgName, 2, 3);
                    //ex.SetCellValue(DateTime.Now.Year.ToString(), 2, 9);
                    //ex.SetCellValue(DateTime.Now.Month.ToString(), 2, 11);
                    //ex.SetCellValue(DateTime.Now.Day.ToString(), 2, 13);
                    ex.SetCellValue(DateTime.Now.ToString("yyyy年MM月dd日"), 4, 13);
                }
               
                ex.SetCellValue(datalist[j].jsxl, row + j % rowcount, col );
                ex.SetCellValue(datalist[j].zjxl, row + j % rowcount, col + 1);

                ex.SetCellValue(datalist[j].gytq, row + j % rowcount + rowspan, col);
                ex.SetCellValue(datalist[j].zytq, row + j % rowcount + rowspan, col + 1);
                ////停送电时间
                //ex.SetCellValue(datalist[j].TDtime.Month.ToString(), row + j % rowcount, col + 4);
                //ex.SetCellValue(datalist[j].TDtime.Day.ToString(), row + j % rowcount, col + 5);
                //ex.SetCellValue(datalist[j].TDtime.Hour.ToString(), row + j % rowcount, col + 6);
                //ex.SetCellValue(datalist[j].TDtime.Minute.ToString(), row + j % rowcount, col + 7);

                //ex.SetCellValue(datalist[j].SDtime.Month.ToString(), row + j % rowcount, col + 8);
                //ex.SetCellValue(datalist[j].SDtime.Day.ToString(), row + j % rowcount, col + 9);
                //ex.SetCellValue(datalist[j].SDtime.Hour.ToString(), row + j % rowcount, col + 10);
                //ex.SetCellValue(datalist[j].SDtime.Minute.ToString(), row + j % rowcount, col + 11);
                ////配合检修单位
                //ex.SetCellValue(datalist[j].ASSOrgname, row + j % rowcount, col + 12);
                //ex.SetCellValue(datalist[j].Remark, row + j % rowcount, col + 13);


            }
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:73,代码来源:ExportXLSBZRQHFMXB.cs

示例12: ExportExcel

        public void ExportExcel(ExcelAccess ex ,IList<PJ_wgclcrkd> datalist)
        {
            
            //此处写填充内容代码
            int row = 8;
            int col = 2;
            int rowcount = 25;

            if (datalist.Count < 1) return;
            Regex r1 = new Regex("[0-9]+");
            string str = r1.Match(datalist[0].num).Value;
            if (str == "")
            {
                str = datalist[0].num;
            }
            string tablename = datalist[0].ssgc + datalist[0].ssxm + str;
            if (tablename.Length > 30)
            {
                tablename = tablename.Substring(tablename.Length - 31);
            }
            //

            //加页
            int pageindex = 1;
            if (pageindex < Ecommon.GetPagecount(datalist.Count, rowcount))
            {
                pageindex = Ecommon.GetPagecount(datalist.Count, rowcount);
            }
            for (int j = 1; j <= pageindex; j++)
            {

                ex.CopySheet(1, j);
                if (j == 1) ex.ReNameWorkSheet(j + 1, tablename);
                else
                    ex.ReNameWorkSheet(j + 1, tablename + "(" + (j) + ")");
            }
            for (int j = 0; j < datalist.Count; j++)
            {

                if (j % rowcount == 0)
                {
                    if (j == 0) ex.ActiveSheet(tablename);
                    else ex.ActiveSheet(tablename + "(" + (j / rowcount + 1) + ")");
                    ex.SetCellValue(datalist[j].ssgc, 3, 4);
                    ex.SetCellValue(datalist[j].lqdw, 6, 3);
                    ex.SetCellValue(datalist[j].ghdw, 6, 14);

                    ex.SetCellValue(datalist[j].ckdate.ToString("yyyy"), 4, 4);
                    ex.SetCellValue(datalist[j].ckdate.ToString("MM"), 4, 7);
                    ex.SetCellValue(datalist[j].ckdate.ToString("dd"), 4, 9);

                    ex.SetCellValue(datalist[j].ssgc, 36, 4);
                    ex.SetCellValue(datalist[j].lqdw, 39, 3);
                    ex.SetCellValue(datalist[j].ghdw, 39, 14);
                    ex.SetCellValue(datalist[j].ckdate.ToString("yyyy"), 37, 7);
                    ex.SetCellValue(datalist[j].ckdate.ToString("MM"), 37, 9);
                    ex.SetCellValue(datalist[j].ckdate.ToString("dd"), 37, 11);

                    ex.SetCellValue(datalist[j].ssgc, 69, 4);
                    ex.SetCellValue(datalist[j].lqdw, 72, 3);
                    ex.SetCellValue(datalist[j].ghdw, 72, 14);
                    ex.SetCellValue(datalist[j].ckdate.ToString("yyyy"), 70, 7);
                    ex.SetCellValue(datalist[j].ckdate.ToString("MM"), 70, 9);
                    ex.SetCellValue(datalist[j].ckdate.ToString("dd"), 70, 11);

                   
                }

                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount , col);
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount , col + 4);
                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount, col + 8);
                ex.SetCellValue(datalist[j].cksl, row + j % rowcount, col + 10);
                ex.SetCellValue(datalist[j].Remark, row + j % rowcount, col + 12);

                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount+33, col);
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount + 33, col + 4);
                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount + 33, col + 8);

                ex.SetCellValue(datalist[j].cksl, row + j % rowcount + 33, col + 10);
                ex.SetCellValue(datalist[j].Remark, row + j % rowcount + 33, col + 12);

                ex.SetCellValue(datalist[j].wpmc, row + j % rowcount + 66, col);
                ex.SetCellValue(datalist[j].wpgg, row + j % rowcount + 66, col + 4);
                ex.SetCellValue(datalist[j].wpdw, row + j % rowcount + 66, col + 8);
                ex.SetCellValue(datalist[j].cksl, row + j % rowcount + 66, col + 10);
                ex.SetCellValue(datalist[j].Remark, row + j % rowcount + 66, col + 12);

                //long value = Convert.ToInt64(Math.Round(Convert.ToDouble(datalist[j].cksl) * Convert.ToDouble(datalist[j].wpdj), 2) * 100);
                //int index = 19;
                //while (value > 0)
                //{
                //    long ifen = value % 10;
                //    ex.SetCellValue(ifen.ToString(), row + j % rowcount, index);
                //    ex.SetCellValue(ifen.ToString(), row + j % rowcount + 20, index);
                //    ex.SetCellValue(ifen.ToString(), row + j % rowcount + 40, index);
                //    ex.SetCellValue(ifen.ToString(), row + j % rowcount + 60, index);
                //    value = value/ 10;
                //    index--;
                //}
                //ex.SetCellValue(datalist[j].zrr, row + j % rowcount, col + 7);
//.........这里部分代码省略.........
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:101,代码来源:ExportWGCJGCCLDEdit.cs

示例13: ExportToExcel


//.........这里部分代码省略.........


        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);
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:67,代码来源:UCPJ_17.cs

示例14: ExportExcel

        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
        public static void ExportExcel(IList<sdjl_gjyb> objlist) {
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = Application.StartupPath + "\\00记录模板\\送电14工具仪表台账.xls";

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

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

                        ex.SetCellValue(bh.ToString(),rowcount + i, 1);

                        ex.SetCellValue(objlist[starow - 1 + i].sbName, rowcount + i, 2);
                        ex.SetCellValue(objlist[starow - 1 + i].jdgg, rowcount + i, 3);
                        ex.SetCellValue(objlist[starow - 1 + i].dw, rowcount + i, 4);
                        ex.SetCellValue(objlist[starow - 1 + i].sl.ToString(), rowcount + i, 5);
                        ex.SetCellValue(objlist[starow - 1 + i].cj, rowcount + i, 6);
                        if (objlist[starow - 1 + i].sbCode.Contains(objlist[starow - 1 + i].sbName))
                        {
                            ex.SetCellValue(objlist[starow - 1 + i].sbCode, rowcount + i, 7);
                        }
                        else
                        {
                  //          ex.SetCellValue(objlist[starow - 1 + i].sbCode+objlist[starow - 1 + i].sbCode, rowcount + i, 7);
                            ex.SetCellValue(objlist[starow - 1 + i].sbName +objlist[starow - 1 + i].sbCode, rowcount + i, 7);
                        }
                        ex.SetCellValue(objlist[starow - 1 + i].lqsj.ToShortDateString(), rowcount + i, 8);
                        
                        ex.SetCellValue(objlist[starow - 1 + i].Remark, rowcount + i, 10);
                    }
                }
                else if (objlist.Count <= endrow && objlist.Count >= starow)
                {
                    for (int i = 0; i < objlist.Count - starow + 1; i++)
                    {
                        bh++;
                        ex.SetCellValue(bh.ToString(), rowcount + i, 1);
                        ex.SetCellValue(objlist[starow - 1 + i].sbName, rowcount + i, 2);
                        ex.SetCellValue(objlist[starow - 1 + i].jdgg, rowcount + i, 3);
                        ex.SetCellValue(objlist[starow - 1 + i].dw, rowcount + i, 4);
                        ex.SetCellValue(objlist[starow - 1 + i].sl.ToString(), rowcount + i, 5);
                        ex.SetCellValue(objlist[starow - 1 + i].cj, rowcount + i, 6);
                        if (objlist[starow - 1 + i].sbCode.Contains(objlist[starow - 1 + i].sbName))
                        {
                            ex.SetCellValue(objlist[starow - 1 + i].sbCode, rowcount + i, 7);
                        }
                        else
                        {
                            ex.SetCellValue(objlist[starow - 1 + i].sbName+ objlist[starow - 1 + i].sbCode, rowcount + i, 7);
                        }
                        ex.SetCellValue(objlist[starow - 1 + i].lqsj.ToShortDateString(), rowcount + i, 8);
                        //ex.SetCellValue(objlist[starow - 1 + i].lqsj.Month.ToString(), rowcount + i, 9);
                        ex.SetCellValue(objlist[starow - 1 + i].Remark, rowcount + i, 10);
                    }
                }
            }
            ex.ActiveSheet(1);
            string gdsname = "";
            //记录变电所
            if (objlist.Count>0)
            {
                 IList<mOrg> list = Client.ClientHelper.PlatformSqlMap.GetList<mOrg>("where orgcode='" + objlist[0].OrgID + "'");
             
            if (list.Count > 0)

                gdsname = list[0].OrgName;
            }
            ex.SetCellValue(gdsname, 3, 2);
//.........这里部分代码省略.........
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:101,代码来源:ExportSD15.cs

示例15: ExportExcel

        /// <summary>
        /// 文档格式预定义好的,只填写内容
        /// </summary>
        /// <param name="obj"></param>
        public static void ExportExcel(PJ_18gysbpj obj) 
        {
            //lgm
            ExcelAccess ex = new ExcelAccess();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname0 = Application.StartupPath + "\\00记录模板\\18高压设备评级表.xls";
            string fname = Path.GetTempPath() + obj.OrgName + "设备评级表.xls";
            try {
                File.Copy(fname0, fname, true);
            } catch { }
            IList<PJ_18gysbpjmx> objlist = Client.ClientHelper.PlatformSqlMap.GetList<PJ_18gysbpjmx>("SelectPJ_18gysbpjmxList", "where PJ_ID='" + obj.PJ_ID + "'");



            ex.Open(fname);
            //此处写填充内容代码
            int pagecout = Ecommon.GetPagecount(objlist.Count, 29);

            //复制空模板并重命名
            for (int m = 1; m < pagecout; m++)
            {
                ex.CopySheet(1, m);
                ex.ReNameWorkSheet(m + 1, "Sheet" + (m + 1));
            }
            for (int p = 0; p < pagecout; p++)
            {
                ex.ActiveSheet(p + 1);
                ex.SetCellValue(Ebada.Client.Platform.MainHelper.UserCompany+"  " + obj.OrgName, 4, 1);

                for (int i = 0; i < 29; i++)
                {
                    if (p*29+i>=objlist.Count)
                    {
                        break;
                    }
                    PJ_18gysbpjmx tempobj = objlist[p * 29 + i];
                    //ex.SetCellValue((p * 29 + i).ToString(), 7 + i, 1);
                    ex.SetCellValue(tempobj.xh.ToString(), 7 + i, 1);
                    ex.SetCellValue(tempobj.sbdy, 7 + i, 2);
                    if (tempobj.one > 1) {
                        ex.SetCellValue(Math.Round(tempobj.one / 1000d, 2).ToString(), 7 + i, 5);
                        ex.SetCellValue(Math.Round(tempobj.two / 1000d, 2).ToString(), 7 + i, 6);
                        ex.SetCellValue(Math.Round(tempobj.three / 1000d, 2).ToString(), 7 + i, 9);
                    } else {
                        ex.SetCellValue(tempobj.one.ToString(), 7 + i, 5);
                        ex.SetCellValue(tempobj.two.ToString(), 7 + i, 6);
                        ex.SetCellValue(tempobj.three.ToString(), 7 + i, 9);
                    }
                    ex.SetCellValue(tempobj.whl*100 + "%", 7 + i, 12);
                    ex.SetCellValue(tempobj.qxnr==""?"无":tempobj.qxnr, 7 + i, 13);
                    ex.SetCellValue(tempobj.fzdw, 7 + i, 14);

                }
    //            ex.SetCellValue(obj.fzr, 36, 2);
                ex.SetCellValue(obj.zbr, 36, 4);
                ex.SetCellValue(obj.rq.Year.ToString(), 36, 6);
                ex.SetCellValue(obj.rq.Month.ToString(), 36, 8);
                ex.SetCellValue(obj.rq.Day.ToString(), 36, 10);
            }
           ex.ActiveSheet(1);
           ex.ShowExcel();
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:66,代码来源:Export18.cs


注:本文中的ExcelAccess.ReNameWorkSheet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。