我正在从 Excel 导入工作表。我需要在网格末尾添加一个新单元格,其中包含有关空单元格的消息,我将它们保存在一个名为 msg 的数组中;
private void simpleButton1_Click(object sender, System.EventArgs e)
{
try
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:\\Users\\pc\\Documents\\Emp.xlsx;Extended Properties=\"Excel 12.0;HDR=Yes\"";
con.Open();
DataTable dtSchema;
dtSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
OleDbCommand Command = new OleDbCommand ("select * FROM [" + dtSchema.Rows[0]["TABLE_NAME"].ToString() + "]", con);
OleDbDataAdapter da = new OleDbDataAdapter(Command);
DataSet ds = new DataSet ();
da.Fill(ds);
dataGrid1.DataSource = ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
string[] msg = new string[50];
for (int i = 0; i < gridView3.RowCount ; i++)
{
System.Data.DataRow Rows = gridView3.GetDataRow(i);
string cellvalue = Rows[0].ToString();
if (cellvalue == "")
{
msg[0] = "Missing 'First Name'";
}
cellvalue = Rows[1].ToString();
if (cellvalue == "")
{
msg[1] = "Missing 'Father Name'";
}
cellvalue = Rows[2].ToString();
if (cellvalue == "")
{
msg[2] = "Missing 'Last Name'";
}
}
我正在使用 XtraGrid Control.. 如何添加此列添加 抱歉,我是 DevExpress 的新手,谢谢..