Example #1
0
        public void ExportToExcel(string SaveFileName)
        {
            Excel mexportExcel = new Excel(SaveFileName, false);

            string datetime = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "  " +
                              DateTime.Now.Hour.ToString() + "'" + DateTime.Now.Minute.ToString() + "'" + DateTime.Now.Second.ToString();
            string sheetname = "计算转正天数" + datetime;

            mexportExcel.AddWorksheet(sheetname);
            mexportExcel.SetCurrentWorksheet(sheetname);
            for (int i = 0; i < AssessSourcecollection.Count; i++)
            {
                if (AssessSourcecollection[i].TimePercent == "无")
                {
                    continue;
                }
                mexportExcel.SetCell(i + 1, 1, AssessSourcecollection[i].OrderNumber.ToString());
                mexportExcel.SetCell(i + 1, 2, AssessSourcecollection[i].StaffName);
                mexportExcel.SetCell(i + 1, 3, AssessSourcecollection[i].StaffDep);
                mexportExcel.SetCell(i + 1, 4, AssessSourcecollection[i].StaffPostion);
                mexportExcel.SetSelFormatText(i + 1, 5);
                mexportExcel.SetCell(i + 1, 5, AssessSourcecollection[i].TimePercent);
                mexportExcel.SetCell(i + 1, 6, AssessSourcecollection[i].mNewStaffSalary.ProbationSalary);
                mexportExcel.SetCell(i + 1, 7, AssessSourcecollection[i].mNewStaffSalary.FullSalary);
                mexportExcel.SetCell(i + 1, 8, AssessSourcecollection[i].mNewStaffSalary.balance);
                mexportExcel.SetCell(i + 1, 9, AssessSourcecollection[i].CompanyInfo);
            }
            for (int i = 1; i < 10; i++)
            {
                mexportExcel.ColumnAutoFit(1, i);
            }
            mexportExcel.SaveAs2003(SaveFileName);
            mexportExcel.Save();
            mexportExcel.Visible = true;
        }
Example #2
0
        public int ExcelOutResult()
        {
            TargetValues = mTargetProjectInfoArray;
            mExcel.AddWorksheet(StartMonth + "-" + EndMonth + "汇总");
            int          Row = 1;
            float        ProjectTotalMoney = (float)0.0;
            List <float> SingelSumList     = new List <float>();

            for (int i = 0; i < mTargetProjectInfoArray.Count; i++)
            {
                if (mTargetProjectInfoArray[i].ProjectId.IndexOf("项目名称") != -1)
                {
                    mExcel.SetCell(Row, 1, mTargetProjectInfoArray[i].ProjectName + splitchar);
                }
                else
                {
                    mExcel.SetCell(Row, 1, mTargetProjectInfoArray[i].ProjectName + splitchar + mTargetProjectInfoArray[i].ProjectId);
                }
                mExcel.SetRangeBackground(Row, 1, Row, 8, 33);
                mExcel.SetCell(++Row, 1, "姓名");
                mExcel.SetCell(Row, 2, "部门");
                mExcel.SetCell(Row, 3, "加班费");
                mExcel.SetRangeBackground(Row, 3, Row, 3, 6);
                float sum = (float)0.000;

                for (int j = 0; j < mTargetProjectInfoArray[i].MyProjectDetailCollection.Count; j++)
                {
                    sum += mTargetProjectInfoArray[i].MyProjectDetailCollection[j].ProjectStaffMoney;
                    mExcel.SetCell(++Row, 1, mTargetProjectInfoArray[i].MyProjectDetailCollection[j].ProjectStaffName);
                    mExcel.SetCell(Row, 2, mTargetProjectInfoArray[i].MyProjectDetailCollection[j].ProjectStaffDep);
                    mExcel.SetCell(Row, 3, mTargetProjectInfoArray[i].MyProjectDetailCollection[j].ProjectStaffMoney.ToString());
                }
                SingelSumList.Add(sum);
                ProjectTotalMoney += sum;
                mExcel.SetCell(++Row, 1, "总计:");
                mExcel.SetCell(Row, 3, sum.ToString());
                mExcel.SetRangeBackground(Row, 1, Row, 3, 34);
                mExcel.SetCell(++Row, 1, "费用百分比:");
                mExcel.SetRangeBackground(Row, 1, Row, 3, 34);
                ++Row;
                ++Row;
            }
            mExcel.SetCell(++Row, 1, "项目总数:  " + mTargetProjectInfoArray.Count);
            mExcel.SetRangeBackground(Row, 1, Row, 5, 48);
            mExcel.SetCell(++Row, 1, "项目全部支出:  " + ProjectTotalMoney.ToString());
            mExcel.SetRangeBackground(Row, 1, Row, 5, 48);

            Row = 1;
            for (int i = 0; i < mTargetProjectInfoArray.Count; i++)
            {
                float precentproject = (SingelSumList[i] / ProjectTotalMoney) * (float)100.00;
                Row = GetPrecentRow(Row, mTargetProjectInfoArray[i]);
                mExcel.SetCell(Row, 3, precentproject.ToString() + "%");
                Row += 2;
            }
            MessageBox.Show("合并完成!");
            mExcel.Visible = true;
            return(1);
        }
Example #3
0
        public int ExcelOutResult()
        {
            TargetValues = mTargetProjectInfoArray;
            mExcel.AddWorksheet(StartMonth + "-" + EndMonth + "汇总");
            int          Row = 1;
            float        ProjectTotalMoney = (float)0.0;
            List <float> SingelSumList     = new List <float>();

            mExcel.SetCell(Row, 1, StartMonth + "-" + EndMonth + " 项目总数:  " + mTargetProjectInfoArray.Count + "个");
            mExcel.SetCell(Row, 6, StartMonth + "-" + EndMonth + " 项目全部支出:  " + TotalMoneyOnAllProject.ToString() + "元");
            mExcel.SetRangeBackground(Row, 1, Row, 16, 48);
            mExcel.SetRangeFontColor(Row, 1, Row, 16, 2);
            ++Row;
            ++Row;
            for (int i = 0; i < mTargetProjectInfoArray.Count; i++)
            {
                if (mTargetProjectInfoArray[i].ProjectId.IndexOf("项目名称") != -1)
                {
                    mExcel.SetCell(Row, 1, "No " + (i + 1).ToString() + ". " + mTargetProjectInfoArray[i].ProjectName + splitchar);
                }
                else
                {
                    mExcel.SetCell(Row, 1, "No " + (i + 1).ToString() + ". " + mTargetProjectInfoArray[i].ProjectName + splitchar + mTargetProjectInfoArray[i].ProjectId);
                }
                mExcel.SetRangeBackground(Row, 1, Row, 16, 33);
                mExcel.SetCell(++Row, 1, "姓名");
                mExcel.SetCell(Row, 2, "部门");
                mExcel.SetCell(Row, 3, "加班费");
                mExcel.SetRangeBackground(Row, 3, Row, 3, 6);
                for (int j = 0; j < mTargetProjectInfoArray[i].MyProjectDetailCollection.Count; j++)
                {
                    mExcel.SetCell(++Row, 1, mTargetProjectInfoArray[i].MyProjectDetailCollection[j].ProjectStaffName);
                    mExcel.SetCell(Row, 2, mTargetProjectInfoArray[i].MyProjectDetailCollection[j].ProjectStaffDep);
                    mExcel.SetCell(Row, 3, mTargetProjectInfoArray[i].MyProjectDetailCollection[j].ProjectStaffMoney.ToString());
                }
                mExcel.SetCell(++Row, 1, "项目人数:");
                mExcel.SetCell(Row, 3, mTargetProjectInfoArray[i].MyProjectDetailCollection.Count.ToString() + "人");
                mExcel.SetRangeBackground(Row, 1, Row, 3, 34);
                mExcel.SetCell(++Row, 1, "项目费用:");
                mExcel.SetCell(Row, 3, mTargetProjectInfoArray[i].TotalMoney.ToString() + "元");
                mExcel.SetRangeBackground(Row, 1, Row, 3, 34);
                mExcel.SetCell(++Row, 1, "费用百分比:");
                mExcel.SetCell(Row, 3, mTargetProjectInfoArray[i].TotalPercent.ToString() + "%");
                mExcel.SetRangeBackground(Row, 1, Row, 3, 34);
                ++Row;
                ++Row;
            }

            return(1);
        }