So erhalten Sie eine bestimmte Zeile nach Arbeitsblatt und RowIndex in Excel -DateiC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 So erhalten Sie eine bestimmte Zeile nach Arbeitsblatt und RowIndex in Excel -Datei

Post by Anonymous »

Ich muss eine bestimmte Zelle in meiner Excel -Datei mit OpenXML auswählen: < /p>

Worksheet workSheet = workSheetPart.Worksheet;
Cell cell = GetCell(workSheet, "B", 2);

private static Cell GetCell(Worksheet worksheet,
string columnName, uint rowIndex)
{
Row row = GetRow(worksheet, rowIndex);

if (row == null)
return null;

return row.Elements().Where(c => string.Compare
(c.CellReference.Value, columnName +
rowIndex, true) == 0).First();
}

private static Row GetRow(Worksheet worksheet, uint rowIndex)
{
var test = worksheet.GetFirstChild().
Elements().Where(r => r.RowIndex == rowIndex).First(); //Here is the problem.

return worksheet.GetFirstChild().
Elements().Where(r => r.RowIndex == rowIndex).First();
}
< /code>

Beim Debuggen habe ich festgestellt>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post