0
我有一個問題。有沒有一種方法可以使用for循環遍歷電子表格中的所有列/行?現在我在我的代碼中使用這樣的foreach循環:(你可以忽略裏面發生了什麼)。GemBox - For循環行和列?
foreach (ExcelRow row in w1.Rows)
{
foreach (ExcelCell cell in row.AllocatedCells)
{
Console.Write("row: {0}", globalVar.iRowActual);
if (globalVar.iRowActual > 1)
{
cellValue = SafeCellValue(cell);
Console.WriteLine("value is: {0}", cellValue);
}
}
globalVar.iRowActual++;
}
問題是我想將每個單元格的值分配給一個新變量並將其傳遞給另一個方法。我想使用for循環爲此,我知道我可以使用CalculateMaxUsedColumns作爲cols的限制,但是有那樣的屬性,我可以用於行?!
這是我想怎樣做:
int columnCount = ws.CalculateMaxUsedColumns();
int rowCount = ws.CalculateMaxUsedRows(); ------> PART I NEED HELP WITH
for(int i=0; i <columnCount; i++){
for(int j = 0; j<rowCount; j++){
.....
}
}
任何形式的幫助將不勝感激。謝謝!!!
我正在使用Gembox軟件來處理電子表格。 – jansyb04