private void Init()
        {
            worker.ReportProgress(0,
                string.Format(Properties.Resources.StartingEachReportMsg, this.filespec)
                );
            valid_VESTA = true;
            WorkbookWrapper bk = new WorkbookWrapper(this.filespec);
            if (bk == null)
            {
                worker.ReportProgress(0,
                    string.Format(Properties.Resources.InvalidWorksheetMsg, this.filespec)
                    );
                valid_VESTA = false;
                return;
            }

            this.sheet = bk.SheetByName(this.sheet_name);
            if (this.sheet == null)
            {
                worker.ReportProgress(0,
                    string.Format(Properties.Resources.SheetNotFoundInFileMsg, this.sheet_name, this.filespec)
                    );
                valid_VESTA = false;
                return;
            }
            this.report_type = VestaImporterUtils.ReportType(this.sheet);
            if (this.report_type == ReportTypes.Unknown)
            {
                worker.ReportProgress(0,
                    string.Format(Properties.Resources.UnknownReportTypeMsg, this.filespec)
                    );
                valid_VESTA = false;
                return;
            }
        }
示例#2
0
        public void WorkbookInsert()
        {
            List <SumAnalysisX> SumAnalysisXs = new List <SumAnalysisX>();

            for (int i = 0; i < 8; i++)
            {
                SumAnalysisX SumAnalysisX1 = new SumAnalysisX()
                {
                    ClassName = i.ToString() + "班级", MaxScore = 100 + i, Total = 1000 + i, TotalAverage = 10 + i
                };

                List <SubjectScoreDetailX> ssd = new List <SubjectScoreDetailX>();

                for (int j = 0; j < 4; j++)
                {
                    ssd.Add(new SubjectScoreDetailX()
                    {
                        Score = 10000 + j, TypeName = "kemu " + j.ToString(), TypeId = j
                    });
                }

                SumAnalysisX1.SubjectScoreDetails = ssd;

                SumAnalysisXs.Add(SumAnalysisX1);
            }

            WorkbookWrapper w = new WorkbookWrapper();

            SheetDetail sd = new SheetDetail("sxf");

            SheetDetailDataWrapper sheetDetailDataWrapper = new SheetDetailDataWrapper("No.1", SumAnalysisXs.Cast <IExcelModelBase>());

            sd.SheetDetailDataWrappers.Add(sheetDetailDataWrapper);

            w.AddSheetDetail(sd);

            w.Save(@"C:\sxf.xls");
        }