ExcelReaderを使用してExcelシートセルにデータを書き込みます。セルに先行書き込みができるまでは問題ありません。しかし、1つのケースでは、1つのセルのみが読取り専用であり、残りのセルは書込み可能である。特定のセルがC#を使用して "ReadOnly"である場合、DataReaderを使用してExcelセルに書き込む方法
例: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++;
}
}
}
は、 RAMM