I was recently using powershell to automate some things with Excel, and i could simply just use A1, A2 etc. With C#, it seems to be a requirement to use [1,1], (coordinate style) or else you get a type mismatch. Here is the code I am working with:
//Generating User and Password
int startCoordI = Int32.Parse(startCoord);
int endCoordI = Int32.Parse(endCoord);
int userCoordI = Int32.Parse(userCoord);
int passwordCoordI = Int32.Parse(passwordCoord);
int value = startCoordI;
string Username = Convert.ToString(workSheet.Cells[userCoord, startCoordI].Value);
MessageBox.Show(Username);
string Password = Convert.ToString(workSheet.Cells[passwordCoord, startCoordI].Value);
MessageBox.Show(Password);
try
{
for (I = startCoordI; I <= endCoordI; I++)
{
System.Diagnostics.ProcessStartInfo proccessStartInfo = new System.Diagnostics.ProcessStartInfo("net", "user " + Username + " " + Password + " /add /passwordchg:no");
System.Diagnostics.Process proc = new System.Diagnostics.Process { StartInfo = proccessStartInfo };
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proccessStartInfo.CreateNoWindow = true;
proc.Start();
//new user
value++;
Username = Convert.ToString(workSheet.Cells[userCoord, value].Value);
Password = Convert.ToString(workSheet.Cells[passwordCoord, value].Value);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
This isn't inherently a problem, but it would be nice to be able to use A1 style coordinates. Thanks!