/// <summary> /// 寻找数据根据条件 /// </summary> private IEnumerator FindByCondition() { BmobQuery query = new BmobQuery(); query.WhereGreaterThan("PlayerScore", 500); query.OrderByDescending("PlayerScore"); bool isFindOver = false; StartCoroutine(BmobManager.Instance.ConditionFind <BmobTab_RankingList>(query, BmobTab_RankingList.TABLENAME, (List <BmobTab_RankingList> list, bool isOver) => { mPlayerInfoList = list; isFindOver = isOver; })); while (!isFindOver) { Debug.Log("list is null"); yield return(0); } if (isFindOver) { for (int i = 0; i < mPlayerInfoList.Count; i++) { // Debug.Log(mPlayerInfoList[i].objectId + " " + mPlayerInfoList[i].id + " " + mPlayerInfoList[i].playerName + " " + mPlayerInfoList[i].score); } } }
private void bomoToexcel() { DataTable _px = new DataTable(); var query = new BmobQuery(); query.WhereGreaterThan("indexID", 2651); //分数大于60岁 query.OrderBy("indexID"); query.Limit(600); var childfuture = Bmob.FindTaskAsync <computerTiKu>("computerTiKu", query); if (childfuture.Result.results.Count != 0) { _px = ToDataTable <computerTiKu>(childfuture.Result.results); // MessageBox.Show("总行数" + _px.Rows.Count); } //_dspx = AdDispatchManage.GetValue(sqlstr); int row; row = 2; int b; b = 0; string PathStr; string SourceFileName; string DestinationFileName; PathStr = Application.StartupPath.Trim(); // MakeBigWord.MakeBigWord.KillExcelProcess(); DestinationFileName = PathStr + @"\plantmp.xls"; SourceFileName = PathStr + @"\yhygzpx.xls"; try { File.Delete(DestinationFileName); File.Copy(SourceFileName, DestinationFileName); } catch (Exception ee) { MessageBox.Show(ee.Message); return; } Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook xlBook = xlApp.Workbooks.Add(DestinationFileName); Microsoft.Office.Interop.Excel.Worksheet xlSheet = xlBook.Worksheets[1]; xlSheet.Activate(); xlSheet.Application.Visible = true; try { for (int i = 0; i < _px.Rows.Count; i++) { if (_px.Rows[i]["titleSubject"].ToString() != null) { xlSheet.Cells[i + row, 1] = _px.Rows[i]["titleSubject"].ToString(); } else { MessageBox.Show(i + "titleSubject"); } if (_px.Rows[i]["titleSubject"].ToString() != null) { xlSheet.Cells[i + row, 1] = _px.Rows[i]["titleSubject"].ToString(); } else { MessageBox.Show(i + "titleSubject"); } if (_px.Rows[i]["optionA"].ToString() != null && _px.Rows[i]["optionB"].ToString() != null && _px.Rows[i]["optionC"].ToString() != null && _px.Rows[i]["optionD"].ToString() != null) { Choice[] student = new Choice[4]; student[0] = new Choice(); student[0].key = "A"; student[0].content = _px.Rows[i]["optionA"].ToString(); student[1] = new Choice(); student[1].key = "B"; student[1].content = _px.Rows[i]["optionB"].ToString(); student[2] = new Choice(); student[2].key = "C"; student[2].content = _px.Rows[i]["optionC"].ToString(); student[3] = new Choice(); student[3].key = "D"; student[3].content = _px.Rows[i]["optionD"].ToString(); string aa = Newtonsoft.Json.JsonConvert.SerializeObject(student); xlSheet.Cells[i + row, 2] = aa; //设置一个Person类 //Choice p = new Choice(); //p.key = _px.Rows[i]["optionA"].ToString(); //p.content = _px.Rows[i]["optionB"].ToString(); //p.C = _px.Rows[i]["optionC"].ToString(); //p.D = _px.Rows[i]["optionD"].ToString(); //string json1 = JsonConvert.SerializeObject(p); //Console.WriteLine(json1 + "\n"); ////缩进输出 //string json2 = JsonConvert.SerializeObject(p, Formatting.Indented); //Console.WriteLine(json2 + "\n"); // {"A":"+价格发现功能+","B":"+套利功能+","C":"+投机功能+","D":"+套期保值功能"} } else { MessageBox.Show(i + "A=" + _px.Rows[i]["optionA"].ToString() + "B=" + _px.Rows[i]["optionB"].ToString() + "C=" + _px.Rows[i]["optionC"].ToString() + "D=" + _px.Rows[i]["optionD"].ToString()); } xlSheet.Cells[i + row, 3] = "3RcsJ77J"; if (_px.Rows[i]["answer"].ToString() != null) { String title = _px.Rows[i]["answer"].ToString().Substring(4, _px.Rows[i]["answer"].ToString().Length - 4); ///去掉两个字符串 xlSheet.Cells[i + row, 4] = "[\"" + title + "\"]"; } else { MessageBox.Show(i + "answer"); } if (_px.Rows[i]["explain"].ToString() != null) { xlSheet.Cells[i + row, 5] = _px.Rows[i]["explain"].ToString(); } else { MessageBox.Show(i + "explain"); } xlSheet.Cells[i + row, 6] = 500 + i; xlSheet.Cells[i + row, 7] = "P0Vm666E"; b = i; //xlSheet.Cells[i + row, 2] = _px.Rows[i]["indexID"].ToString(); //xlSheet.Cells[i + row, 3] = _px.Rows[i]["titleSubject"].ToString(); //xlSheet.Cells[i + row, 4] = _px.Rows[i]["answer"].ToString(); //xlSheet.Cells[i + row, 5] = _px.Rows[i]["optionA"].ToString(); //xlSheet.Cells[i + row, 6] = _px.Rows[i]["chapterflag"].ToString(); //xlSheet.Cells[i + row, 7] = _px.Rows[i]["core"].ToString(); //xlSheet.Cells[i + row, 8] = _px.Rows[i]["answerCode"].ToString(); //xlSheet.Cells[i + row, 9] = "'" + _px.Rows[i]["optionB"].ToString() + "/" + _px.Rows[i]["optionC"].ToString(); //xlSheet.Cells[i + row, 10] = _px.Rows[i]["optionD"].ToString(); //xlSheet.Cells[i + row, 11] = _px.Rows[i]["questiontype"].ToString(); //xlSheet.Cells[i + row, 12] = _px.Rows[i]["subjectType"].ToString() + "/" + _px.Rows[i]["explain"].ToString(); } } catch { } try { Microsoft.Office.Interop.Excel.Range r1 = xlSheet.Range[xlSheet.Cells[3, 1], xlSheet.Cells[b + row + 4, 6]]; r1.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].LineStyle = 7; r1.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight].LineStyle = 7; r1.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft].LineStyle = 7; r1.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = 7; r1.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideVertical].LineStyle = 7; } catch { } }