public void PrintClientList(List <Student> studentList) { //Cursor.Current = Cursors.WaitCursor; CExcel MyXls = new CExcel(); MyXls.NewFile(false); string sheetName = "Students"; MyXls.AddSheet(sheetName, "L", 10, 10, 10, 10); MyXls.SetActiveSheet(sheetName); int currentRow = 1; MyXls.WriteCell(currentRow, 1, "XYZ COLLEGE", string.Empty); MyXls.SetCellsFont(currentRow, currentRow, currentRow, currentRow, "Arial Black", 12, "Black", true, false, false); currentRow++; MyXls.WriteCell(currentRow, 1, "STUDENTS REPORT - AS ON DATE: " + DateTime.Now.ToString(), string.Empty); MyXls.SetCellsFont(currentRow, currentRow, currentRow, currentRow, "Arial Black", 10, "Black", true, false, false); MyXls.SetCellsColor(1, 1, 2, 7, "LightYellow", 0); currentRow++; MyXls.WriteCell(currentRow, 1, "Sl#", string.Empty); MyXls.WriteCell(currentRow, 2, "Name", string.Empty); MyXls.WriteCell(currentRow, 3, "Email", string.Empty); MyXls.WriteCell(currentRow, 4, "Mobile", string.Empty); MyXls.WriteCell(currentRow, 5, "Fees Paid", string.Empty); MyXls.WriteCell(currentRow, 6, "Code", string.Empty); MyXls.WriteCell(currentRow, 7, "Status", string.Empty); MyXls.SetCellsFont(3, 1, 3, 7, "Arial", 10, "Black", true, false, false); MyXls.SetCellsColor(3, 1, 3, 7, "LightBlue", 0); //int i = 2; //int iRow = currentRow+1; //while (iRow < Dt.Rows.Count) //{ // dr = Dt.Rows[iRow]; // MyXls.WriteCell(i, 1, dr["ClientID"].ToString(), string.Empty); // MyXls.WriteCell(i, 2, dr["Client Name"].ToString(), string.Empty); // //MyXls.WriteCell(i, 3, dr["Nationality"].ToString(), string.Empty); // MyXls.WriteCell(i, 3, dr["Email"].ToString(), string.Empty); // MyXls.WriteCell(i, 4, dr["Mobile#"].ToString(), string.Empty); // MyXls.WriteCell(i, 5, dr["Account Manager"].ToString(), string.Empty); // MyXls.WriteCell(i, 6, dr["Status"].ToString(), string.Empty); // iRow++; // i++; //} int ctr = 0; foreach (Student s in studentList) { ctr++; currentRow++; MyXls.WriteCell(currentRow, 1, ctr.ToString(), string.Empty); MyXls.WriteCell(currentRow, 2, s.StudentName, string.Empty); MyXls.WriteCell(currentRow, 3, s.EMailID, string.Empty); MyXls.WriteCell(currentRow, 4, s.Mobile, string.Empty); MyXls.WriteCell(currentRow, 5, s.TotalFeesPaid, string.Empty); MyXls.WriteCell(currentRow, 6, s.StudentCode, string.Empty); MyXls.WriteCell(currentRow, 7, s.Status, string.Empty); } MyXls.SetColumnWidth(1, 1, 6); MyXls.SetColumnWidth(2, 2, 30); MyXls.SetColumnWidth(3, 3, 40); MyXls.SetColumnWidth(4, 4, 15); MyXls.SetColumnWidth(5, 5, 15); MyXls.SetColumnWidth(6, 6, 10); MyXls.SetColumnWidth(7, 7, 5); //MyXls.SetCellsBorder(1, 1, i - 1, 6, 1); //MyXls.SetCellsFont(2, 1, i - 1, 6, "Ariel", 9, "Black", false, false, false); //MyXls.SetTitleRows("$1:$1"); MyXls.Show(); MyXls.Dispose(); //Cursor.Current = Cursors.Default; }
public void copyWorkBook(CExcel XLS) { XLS.wb = wb; }