// 選擇題-題目 private DataBindedSheet GetQuestion(XElement xElement, UDT.Hierarchy Hierarchy, Workbook wb) { DataBindedSheet DataBindedSheet = new DataBindedSheet(); DataBindedSheet.Worksheet = wb.Worksheets[Hierarchy.Title + "-選擇題-題目"]; DataBindedSheet.DataTables = new List<DataTable>(); // 項次 DataBindedSheet.DataTables.Add((xElement.Attribute("No").Value + ".").ToDataTable("項次", "項次")); // 題目 DataBindedSheet.DataTables.Add(HttpUtility.HtmlDecode(xElement.Attribute("Content").Value).ToDataTable("題目", "題目")); // 題目高度 CellObject co = new CellObject(0, 0, "題目", DataBindedSheet.Key, this.WorksheetName); CellStyle cs = new CellStyle(); cs.SetAutoFitRow(true).Merge(1, 1); // 題目背景色 if (this._DicQuestionBackgroundColor.ContainsKey(SurveyID)) { if (this._DicQuestionBackgroundColor[SurveyID].ContainsKey(xElement.Attribute("No").Value)) { cs.SetFontBackGroundColor(this._DicQuestionBackgroundColor[SurveyID][xElement.Attribute("No").Value]); this.dicCellStyles.Add(co, cs); goto Outline; } } this.dicCellStyles.Add(co, cs); Outline: IEnumerable<XElement> Options = xElement.Descendants("Option"); if (Options.Count() > 0) Options = Options.OrderBy(x => int.Parse(x.Attribute("No").Value)); string question_content = string.Empty; int i = 0; foreach (XElement xOption in Options) { i = i + 1; // 選項做答人數 DataBindedSheet.DataTables.Add(xOption.Attribute("AnswerCount").Value.ToDataTable("做答人數-" + xOption.Attribute("No").Value, "做答人數-" + xOption.Attribute("No").Value)); question_content += "(" + xOption.Attribute("No").Value + ")" + HttpUtility.HtmlDecode(xOption.Attribute("Content").Value); // 做答背景色 co = new CellObject(0, 0, "做答人數-" + xOption.Attribute("No").Value, DataBindedSheet.Key, this.WorksheetName); cs = new CellStyle(); if (this._DicQuestionBackgroundColor.ContainsKey(SurveyID)) { if (this._DicQuestionBackgroundColor[SurveyID].ContainsKey(xElement.Attribute("No").Value)) { cs.SetFontBackGroundColor(this._DicQuestionBackgroundColor[SurveyID][xElement.Attribute("No").Value]); this.dicCellStyles.Add(co, cs); } } } for (int j = i; j < 6; j++) { // 補選項6背景色 DataBindedSheet.DataTables.Add("".ToDataTable("做答人數-" + (j + 1), "做答人數-" + (j + 1))); co = new CellObject(0, 0, "做答人數-" + (j+1), DataBindedSheet.Key, this.WorksheetName); cs = new CellStyle(); if (this._DicQuestionBackgroundColor.ContainsKey(SurveyID)) { if (this._DicQuestionBackgroundColor[SurveyID].ContainsKey(xElement.Attribute("No").Value)) { cs.SetFontBackGroundColor(this._DicQuestionBackgroundColor[SurveyID][xElement.Attribute("No").Value]); this.dicCellStyles.Add(co, cs); } } } // 題目+選項 DataBindedSheet.DataTables.Add(HttpUtility.HtmlDecode(xElement.Attribute("Content").Value + question_content).ToDataTable("題目+選項", "題目+選項")); // 評鑑值 DataBindedSheet.DataTables.Add(xElement.Attribute("Score").Value.ToDataTable("評鑑值", "評鑑值")); // 評鑑值背景色 co = new CellObject(0, 0, "評鑑值", DataBindedSheet.Key, this.WorksheetName); cs = new CellStyle(); if (this._DicQuestionBackgroundColor.ContainsKey(SurveyID)) { if (this._DicQuestionBackgroundColor[SurveyID].ContainsKey(xElement.Attribute("No").Value)) { cs.SetFontBackGroundColor(this._DicQuestionBackgroundColor[SurveyID][xElement.Attribute("No").Value]); this.dicCellStyles.Add(co, cs); } } return DataBindedSheet; }
// 問答題-做答 private DataBindedSheet GetEssayAnswer(string DisplayOrder, XElement xEssay, UDT.Hierarchy Hierarchy, Workbook wb) { DataBindedSheet DataBindedSheet = new DataBindedSheet(); DataBindedSheet.Worksheet = wb.Worksheets[Hierarchy.Title + "-問答題-做答"]; DataBindedSheet.DataTables = new List<DataTable>(); // 項次 DataBindedSheet.DataTables.Add(DisplayOrder.ToDataTable("項次", "項次")); // 做答 DataBindedSheet.DataTables.Add(xEssay.Value.ToDataTable("內容", "內容")); // 題目高度 CellObject co = new CellObject(0, 0, "內容", DataBindedSheet.Key, this.WorksheetName); CellStyle cs = new CellStyle(); cs.SetAutoFitRow(true).Merge(1, 1); this.dicCellStyles.Add(co, cs); return DataBindedSheet; }
// 問答題-題目 private DataBindedSheet GetEssayQuestion(XElement xElement, UDT.Hierarchy Hierarchy, Workbook wb) { DataBindedSheet DataBindedSheet = new DataBindedSheet(); DataBindedSheet.Worksheet = wb.Worksheets[Hierarchy.Title + "-問答題-題目"]; DataBindedSheet.DataTables = new List<DataTable>(); // 項次 DataBindedSheet.DataTables.Add((xElement.Attribute("No").Value + ".").ToDataTable("項次", "項次")); // 題目 DataBindedSheet.DataTables.Add(HttpUtility.HtmlDecode(xElement.Attribute("Content").Value).ToDataTable("題目", "題目")); // 題目高度 CellObject co = new CellObject(0, 0, "題目", DataBindedSheet.Key, this.WorksheetName); CellStyle cs = new CellStyle(); cs.SetAutoFitRow(true).Merge(1, 1); this.dicCellStyles.Add(co, cs); return DataBindedSheet; }
// 個案題-做答 private DataBindedSheet GetCaseAnswer(string DisplayOrder, XElement xCase, UDT.Hierarchy Hierarchy, Workbook wb) { DataBindedSheet DataBindedSheet = new DataBindedSheet(); DataBindedSheet.Worksheet = wb.Worksheets[Hierarchy.Title + "-個案題-做答"]; DataBindedSheet.DataTables = new List<DataTable>(); // 項次 DataBindedSheet.DataTables.Add(DisplayOrder.ToDataTable("項次", "項次")); // 題目 DataBindedSheet.DataTables.Add(HttpUtility.HtmlDecode(xCase.Attribute("Content").Value).ToDataTable("題目", "題目")); // 題目高度 CellObject co = new CellObject(0, 0, "題目", DataBindedSheet.Key, this.WorksheetName); CellStyle cs = new CellStyle(); cs.SetAutoFitRow(true).Merge(1, 1); this.dicCellStyles.Add(co, cs); // 評鑑值 DataBindedSheet.DataTables.Add(xCase.Attribute("Score").Value.ToDataTable("評鑑值", "評鑑值")); IEnumerable<XElement> Options = xCase.Descendants("Option"); if (Options.Count() > 0) Options = Options.OrderBy(x => int.Parse(x.Attribute("No").Value)); string question_content = string.Empty; foreach (XElement xOption in Options) { // 選項做答人數 DataBindedSheet.DataTables.Add(xOption.Attribute("AnswerCount").Value.ToDataTable("做答人數-" + xOption.Attribute("No").Value, "做答人數-" + xOption.Attribute("No").Value)); question_content += "(" + xOption.Attribute("No").Value + ")" + HttpUtility.HtmlDecode(xOption.Attribute("Content").Value); } // 題目+選項 DataBindedSheet.DataTables.Add(HttpUtility.HtmlDecode(xCase.Attribute("Content").Value + question_content).ToDataTable("題目+選項", "題目+選項")); // 題目高度 co = new CellObject(0, 0, "題目+選項", DataBindedSheet.Key, this.WorksheetName); cs = new CellStyle(); cs.SetAutoFitRow(true).Merge(1, 1); this.dicCellStyles.Add(co, cs); return DataBindedSheet; }