C#读取Excel文件总是读不出第1列,是什么原因
if(openFileDialog1.ShowDialog()==DialogResult.OK){DataTabledt=ImportFile(openFileDial...
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
DataTable dt=ImportFile(openFileDialog1.FileName); //读取Excel文件
int[,] ret = new int[dt.Rows.Count+1, dt.Columns.Count]
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
ret[i, j+1] = dt.Rows[j][i];
}
}
int n=dt.Rows.Count+1;
int[,] aa= [n,n];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
aa[i, j]=ret[i,j];
}
}
}
上面的代码中你哪里有问题? 展开
{
DataTable dt=ImportFile(openFileDialog1.FileName); //读取Excel文件
int[,] ret = new int[dt.Rows.Count+1, dt.Columns.Count]
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
ret[i, j+1] = dt.Rows[j][i];
}
}
int n=dt.Rows.Count+1;
int[,] aa= [n,n];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
aa[i, j]=ret[i,j];
}
}
}
上面的代码中你哪里有问题? 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询