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


C# ExcelAccess.UnitCells方法代码示例

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


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

示例1: ExportToExcel


//.........这里部分代码省略.........
                        {
                            ex.SetCellValue(lxlist[0].ToString(), ihang, jlie);
                        }
                    }
                    ihang += lxRowCount;

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

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

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

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

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

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

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


                }
                ex.ActiveSheet(1);

            } catch (Exception exmess) {
                MsgBox.ShowTipMessageBox(exmess.Message.ToString());
            }
            dsoFramerWordControl1.FileSave();
            pj17.BigData = dsoFramerWordControl1.FileDataGzip;
            dsoFramerWordControl1.FileClose();
            dsoFramerWordControl1.Dispose();
            //#endregion
            //System.Diagnostics.Process.Start(outfname);
            return 1;
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:101,代码来源:UCSD_21.cs

示例2: ExportToExcel


//.........这里部分代码省略.........
                //if (lieindex < 1)
                //    range = (Excel.Range)xx.get_Range(xx.Cells[5, 1], xx.Cells[RowCount, ColumnCount]);
                //else
                //    range = (Excel.Range)xx.get_Range(xx.Cells[5, 1], xx.Cells[RowCount, lieindex + 2]);

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


                #region 填写导线排列方式
                foreach (int key in Dic.Keys)
                {
                    int page = 1;
                    int page1 = 1;
                    DXPLFS nzlength = Dic[key];

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

                    ex.ActiveSheet(page);

                    //int endcolumn = (nzlength.End + 1) * 2;
                    if (nzlength.End % 15 == 0)
                    {
                        page1 = nzlength.End / 15;
                    }
                    else
                    {
                        page1 = nzlength.End / 15 + 1;
                    }
                    if (page == page1)
                    {
                        ex.ActiveSheet(page);
                        try
                        {                            
                            ex.UnitCells(12, ((nzlength.Start % 15)+1)*2-1, 12, ((nzlength.End % 15)+1)*2 );
                            
                        }
                        catch (Exception ex11)
                        {

                        }

                        ex.SetCellValue(nzlength.Name, 12, ((nzlength.Start % 15)+1)*2-1);
                    }
                    else
                    {
                        ex.ActiveSheet(page);
                        ex.UnitCells(12, ((nzlength.Start % 15)+1)*2-1, 12, 32);
                        ex.SetCellValue(nzlength.Start + "到" + nzlength.End + "杆塔:" + nzlength.Name, 12, ((nzlength.Start % 15)+1)*2-1);
                        for (int tmp = 1; tmp <= page1 - page; tmp++)
                        {
                            ex.ActiveSheet(page + tmp);
                            if (tmp < page1 - page)
                            {
                                ex.UnitCells(12, 3, 12, 32);
                                ex.SetCellValue(nzlength.Start + "到" + nzlength.End + "杆塔:" + nzlength.Name, 12, 3);
                            }
                            if (tmp == page1 - page)
                            {
                                ex.UnitCells(12, 3, 12, ((nzlength.End % 15)+1)*2);
                                ex.SetCellValue(nzlength.Start + "到" + nzlength.End + "杆塔:" + nzlength.Name, 12, 3);
                            }
                            
                            
                        }
                    }


                }
                #endregion


                ex.ActiveSheet(1);


            }
            catch (Exception exmess)
            {
                MsgBox.ShowTipMessageBox(exmess.Message.ToString());
            }
            dsoFramerWordControl1.FileSave();
            pj17.BigData = dsoFramerWordControl1.FileDataGzip;
            dsoFramerWordControl1.FileClose();
            dsoFramerWordControl1.Dispose();
            //#endregion
            //System.Diagnostics.Process.Start(outfname);
            return 1;
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:101,代码来源:UCPJ_17.cs


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