Copy the codeThe code is as follows:
//Create Excel
object missing = ;
app = new ();
(true);
book = ();
sheet = ();
#region First line
[1, 1] = "Loginname (loginID)";
[1, 2] = "password (passWord)";
[1, 3] = "Secret (familyName)";
[1, 4] = "name(firstName)";
[1, 5] = "gender (gender)";
[1, 6] = "date of birth (date of Birth)";
[1, 7] = "cellphone number (cellphoneNum)";
[1, 8] = "ID number (identityID)";
[1, 9] = "jobStatus";
[1, 10] = "Company TelephoneNum";
[1, 11] = "email(email);
[1, 12] = "NativeHome";
[1, 13] = "graduateSchool";
[1, 14] = "major";
[1, 15] = "graduateTime";
[1, 16] = "education";
[1, 17] = "Zip Code (zipCode)";
[1, 18] = "address";
[1, 19] = "Entermination Time (entryTime)";
[1, 20] = "leaveTime";
[1, 21] = "remarks";
[1, 22] = "departmentID";
[1, 23] = "JobTypeID";
#endregion
#region Loop to write content
int count = 1;
foreach (EmployeeInfo_tbl item in )
{
count = count+1;
[count, 1] = ;
[count, 2] = ;
[count, 3] = ;//"Secret (familyName)";
[count, 4] = ; //"name(firstName)";
[count, 5] = ; //"Gender";
[count, 6] = ; //"date of birth (date of Birth)";
[count, 7] = ;//"Cellphone number (cellphoneNum)";
[count, 8] = ;//"ID number (identityID)";
[count, 9] = ;//"JobStatus";
[count, 10] = ;//"Company phone number (telephoneNum)";
[count, 11] = ;//"Email(email)";
[count, 12] = ;//"NativeHome";
[count, 13] = ;// "graduateSchool";
[count, 14] = ;// "major";
[count, 15] = ;//"graduateTime";
[count, 16] = ;// "education";
[count, 17] = ;// "Zip Code (zipCode)";
[count, 18] = ;//"Address(address)";
[count, 19] = ;//"Enterprise Time (entryTime)";
[count, 20] = ;// "LeaveTime";
[count, 21] = ;// "Remarks";
[count, 22] = ;// "departmentID";
[count, 23] = ;// "JobTypeID";
}
#endregion
//save
//(_FolderBrowserDialog.SelectedPath + @"\");
//Close the file
//(false, missing, missing);
//Exit excel
//();
Need to reference Microsoft Excel 14.0 Object Library in com (the other versions are roughly the same)
Of course, it means that you must install office Excel for this.
If you need to spare office Excel, then it depends on my final implementation method~!
My final implementation is the third party
It is understood that this dll has always been free (third parties have risks, so be cautious when using it)
Copy the codeThe code is as follows:
//Create Excel
workbook = new ();
sheet = [0];
(1, 1, 1, 0);//Freeze the first line
#region First line
["A1"].PutValue("Loginname(loginID)");
["B1"].PutValue("PassWord)");
["C1"].PutValue("Subject(familyName)");
["D1"].PutValue("name(firstName)");
["E1"].PutValue("Gender");
["F1"].PutValue("date of Birth");
["G1"].PutValue("Cellphone number(cellphoneNum)");
["H1"].PutValue("ID number (identityID)");
["I1"].PutValue("Inaugural Status(jobStatus)");
["J1"].PutValue("Company Telephone(telephoneNum)");
["K1"].PutValue("Email(email)");
["L1"].PutValue("NativeHome");
["M1"].PutValue("graduateSchool");
["N1"].PutValue("Professional(major)");
["O1"].PutValue("graduateTime");
["P1"].PutValue("Education");
["Q1"].PutValue("ZipCode(zipCode)");
["R1"].PutValue("Address(address)");
["S1"].PutValue("Enterprise Time(entryTime)");
["T1"].PutValue("LeaveTime");
["U1"].PutValue("Remarks)");
["V1"].PutValue("DepartmentID)");
["W1"].PutValue("JobTypeID");
#endregion
#region Loop to write content
int count = 1;
foreach (EmployeeInfo_tbl item in )
{
count = count + 1;
["A" + count].PutValue();
["B" + count].PutValue();
["C" + count].PutValue();//"Secret(familyName)";
["D" + count].PutValue(); //"name(firstName)";
["E" + count].PutValue( == 0 ? "Female" : "Male"); //"Gender (gender)";
["F" + count].PutValue(() == "" ? null : ()); //"Date of Birth (date of Birth)";
["G" + count].PutValue(());//"Mobile phone number (cellphoneNum)";
["H" + count].PutValue();//"ID ID number (identityID)";
["I" + count].PutValue( == 1 ? "On-job" : "Resignation");//"Inaugural status (jobStatus)";
["J" + count].PutValue();//"Company phone number (telephoneNum)";
["K" + count].PutValue();//"Email(email)";
["L" + count].PutValue();//"Ancestor (nativeHome)";
["M" + count].PutValue();// "graduateSchool";
["N" + count].PutValue();// "Professional (major)";
["O" + count].PutValue(() == "" ? null : ());//"GraduateTime(graduateTime);
string ed = "";
switch ()
{
case 1:
ed = "Junior High School/Elementary School";
break;
case 2:
ed = "high school/secondary school";
break;
case 3:
ed = "undergraduate/junior degree";
break;
case 4:
ed = "graduate student or above";
break;
default:
ed = null;
break;
}
["P" + count].PutValue(ed);// "Education";
["Q" + count].PutValue();// "Zip Code (zipCode)";
["R" + count].PutValue();//"Address(address)";
["S" + count].PutValue(() == "" ? null : ());//"Enterprise Time(entryTime)";
["T" + count].PutValue(() == "" ? null : ());// "LeaveTime";
["U" + count].PutValue();// "Remarks(remarks)";
["V" + count].PutValue();// "DepartmentID";
["W" + count].PutValue();// "JobTypeID";
}
#endregion
//save
(_FolderBrowserDialog.SelectedPath + @"\");