麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

[WinForm]項目開發中NPOI使用小計

2019-11-14 16:43:50
字體:
來源:轉載
供稿:網友
        PRivate void ExportMergeExcel()        {            if (File.Exists(templateXlsPath))            {                int i = 4, _recordNo = 1;                using (FileStream file = new FileStream(templateXlsPath, FileMode.Open, Fileaccess.Read))                {                    HSSFWorkbook _excel = new HSSFWorkbook(file);                    ICellStyle _cellStyle = CreateCellStly(_excel);                    ISheet _sheetBasic = _excel.GetSheet(ExcelReadHelper.sheet_BasicInfo.Replace("$", ""));                    ISheet _sheetStreatLamp = _excel.GetSheet(ExcelReadHelper.sheet_LampMoreLess.Replace("$", ""));                    ISheet _sheetBasicEx = _excel.GetSheet(ExcelReadHelper.sheet_BasicExInfo.Replace("$", ""));                    ISheet _sheetStreatLampEx = _excel.GetSheet(ExcelReadHelper.sheet_LampMoreLessExInfo.Replace("$", ""));                    ISheet _sheetBasicTeamEx = _excel.GetSheet(ExcelReadHelper.sheet_BasicTeamStatistics.Replace("$", ""));                    ISheet _sheetBasicLampTypeEx = _excel.GetSheet(ExcelReadHelper.sheet_BasicTypeStatistics.Replace("$", ""));                    ISheet _sheetStreetLampMLEx = _excel.GetSheet(ExcelReadHelper.sheet_LampMoreLessTeamStatistics.Replace("$", ""));                    ISheet _sheetStreetLampTeamML = _excel.GetSheet(ExcelReadHelper.sheet_LampMoreLessTypeStatistics.Replace("$", ""));                    file.Close();                    FillBasicSheetDb(_sheetBasic, i, _recordNo);                    _recordNo = 1; i = 4;                    FillStreetLampDb(_sheetStreatLamp, i, _recordNo);                    _recordNo = 1; i = 4;                    FillBasicExSheetDb(_sheetBasicEx, i, _recordNo);                    _recordNo = 1; i = 4;                    FillStreetLampExDb(_sheetStreatLampEx, i, _recordNo);                    i = 1; IRow _rowSum = null; int _lampTotalLampCnt = 0, _colLampCnt = 0, _ncolLampCnt = 0; double _lampTotalLampPw = 0, _colLampPw = 0, _ncolLampPw = 0;                    FillBasicTeamExSheetDb(_excel, _rowSum, _sheetBasicTeamEx, _cellStyle, i, _lampTotalLampCnt, _colLampCnt, _ncolLampCnt, _lampTotalLampPw, _colLampPw, _ncolLampPw);                    i = 1; _lampTotalLampCnt = 0; _colLampCnt = 0; _ncolLampCnt = 0; _lampTotalLampPw = 0; _colLampPw = 0; _ncolLampPw = 0;                    FillbasicLampTypeExSheetDb(_excel, _rowSum, _sheetBasicLampTypeEx, _cellStyle, i, _lampTotalLampCnt, _colLampCnt, _ncolLampCnt, _lampTotalLampPw, _colLampPw, _ncolLampPw);                    _lampTotalLampCnt = 0; _lampTotalLampPw = 0; i = 1;                    FillsheetStreetLampMLSheetDb(_excel, _rowSum, _sheetStreetLampMLEx, _cellStyle, i, _lampTotalLampCnt, _lampTotalLampPw);                    _lampTotalLampCnt = 0; _lampTotalLampPw = 0; i = 1;                    FillStreetLampTeamMLSheetDb(_excel, _rowSum, _sheetStreetLampTeamML, _cellStyle, i, _lampTotalLampCnt, _lampTotalLampPw);                    OutPutMergeExcel(_excel);                }            }        }
private void FillBasicTeamExSheetDb(HSSFWorkbook _excel, IRow _rowSum, ISheet _sheetBasicTeamEx, ICellStyle _cellStyle, int i, int _lampTotalLampCnt, int _colLampCnt, int _ncolLampCnt, double _lampTotalLampPw, double _colLampPw, double _ncolLampPw)        {            foreach (ExcelStatistics excelBasicEx in basicTeamExList)            {                IRow _row = _sheetBasicTeamEx.CreateRow(i);                ExcelWriteHelper.CreateStatisticsExcelRow(_row, excelBasicEx, "BasicTeam");                #region 總燈數                int _lTotalLampCnt = 0;                int.TryParse(excelBasicEx.LampCount, out _lTotalLampCnt);                _lampTotalLampCnt += _lTotalLampCnt;                #endregion                #region 總計算功率(KW)                double _lTotalLampPw = 0;                double.TryParse(excelBasicEx.LampPower, out _lTotalLampPw);                _lampTotalLampPw += _lTotalLampPw;                #endregion                #region 匯總燈數                int _cLampCount = 0;                int.TryParse(excelBasicEx.CollectCount, out _cLampCount);                _colLampCnt += _cLampCount;                #endregion                #region 匯總功率(KW)                double _cLampPw = 0;                double.TryParse(excelBasicEx.CollectPower, out _cLampPw);                _colLampPw += _cLampPw;                #endregion                #region 非匯總燈數                int _ncLampCount = 0;                int.TryParse(excelBasicEx.NotCollectCount, out _ncLampCount);                _ncolLampCnt += _ncLampCount;                #endregion                #region 非匯總功率(KW)                double _ncLampPw = 0;                double.TryParse(excelBasicEx.NotCollectPower, out _ncLampPw);                _ncolLampPw += _ncLampPw;                #endregion                i++;            }            _rowSum = _sheetBasicTeamEx.CreateRow(i);            _rowSum.HeightInPoints = 20;            _rowSum.CreateCell(0).SetCellValue("合計:");            _rowSum.CreateCell(1).SetCellValue(_lampTotalLampCnt);            _rowSum.CreateCell(2).SetCellValue(_lampTotalLampPw);            _rowSum.CreateCell(3).SetCellValue(_colLampCnt);            _rowSum.CreateCell(4).SetCellValue(_colLampPw);            _rowSum.CreateCell(5).SetCellValue(_ncolLampCnt);            _rowSum.CreateCell(6).SetCellValue(_ncolLampPw);            SetRowStyle(_rowSum, _cellStyle);        }
2.定義樣式
        /// <summary>        /// 樣式創建        /// eg:        ///private ICellStyle CreateCellStly(HSSFWorkbook _excel)        ///{        ///    IFont _font = _excel.CreateFont();        ///    _font.FontHeightInPoints = 11;        ///    _font.FontName = "宋體";        ///    _font.Boldweight = (short)FontBoldWeight.Bold;        ///    ICellStyle _cellStyle = _excel.CreateCellStyle();        ///    //_cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightGreen.Index;        ///    //_cellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;        ///    _cellStyle.SetFont(_font);        ///    return _cellStyle;        ///}        /// 為行設置樣式        /// </summary>        /// <param name="row">IRow</param>        /// <param name="cellStyle">ICellStyle</param>        public static void SetRowStyle(this IRow row, ICellStyle cellStyle)        {            if (row != null && cellStyle != null)            {                for (int u = row.FirstCellNum; u < row.LastCellNum; u++)                {                    ICell _cell = row.GetCell(u);                    if (_cell != null)                        _cell.CellStyle = cellStyle;                }            }        }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 最新在线黄色网址 | 一本一本久久a久久精品综合小说 | 蜜桃av网| 日韩每日更新 | 精品久久久久久综合日本 | 国产99久久久国产精品 | 在线区 | 国产精品成人av片免费看最爱 | 奇米888一区二区三区 | 亚欧美一区二区 | 久久老司机 | 蜜桃精品视频 | 免费黄色小网站 | 青青草免费观看 | 亚州综合图片 | 国产精品视频免费在线观看 | 久久免费观看一级毛片 | 狠狠操视频网站 | 成人国产免费观看 | 欧美国产精品一区二区 | 国产成人精品自拍视频 | 免费午夜视频在线观看 | 91av国产在线 | 国产精品久久久久久久久久久久午夜 | 久久久一区二区三区四区 | av不卡免费观看 | 男女羞羞视频在线观看免费 | 精品999www| 亚洲精品久久久久久久久久 | 国产精品久久久久一区二区 | 国产精品自在线拍 | 看a级毛片| 欧美日本色 | 午夜天堂在线视频 | 99seav| 国产精品一区网站 | 一本到免费视频 | 欧美老外a级毛片 | 国产精品影视 | 高清在线观看av | 国产精品久久久久久久午夜片 |