我正在使用 DataReader 将数据写入 excelsheet 单元格。在单元格写入特权之前,我没有问题。但在一种情况下,只有一个单元格是只读的,其余单元格是可写的。
例如:10 * 10 个单元格,只有第一个单元格是只读的。所以,我应该离开这个单元格并将其写入其他单元格。但是使用数据读取器,它一次写入整行..那么我如何使用 C# 来实现这一点?
Team Leader (required) , , , , , , , , ,
, , , , , , , , , ,
, , , , , , , , , ,
, , , , , , , , , ,
, , , , , , , , , ,
所以,第一个单元格不应该由 datareader 写入。请帮我这样做
if (reader.HasRows)
{
minRow = 0;
minCol = 0;
// Process each result in the result set
while (reader.Read())
{
// Create an array big enough to hold the column values
object[] values = new object[reader.FieldCount];
// Add the array to the ArrayList
rowList.Add(values);
// Get the column values into the array
reader.GetValues(values);
int iValueIndex = 0;
// If the Reading Format is by ColumnByColumn
if (CurTaskNode.ReadFormat == "ColumnbyColumn")
{
minCol = 0;
// minRow = 0;
for (int iCol = 0; iCol < CurTaskNode.HeaderData.Length; iCol++)
{
// Checking whether the Header data exists or not
if (CurTaskNode.HeaderData[minCol] != "")
{
// Assigning the Value from reader to the particular cell in excel sheet
excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol] = values[iValueIndex];
iValueIndex++;
}
minCol++;
}
minRow++;
}
}
}
谢谢你,拉姆